Skip to content

Instantly share code, notes, and snippets.

@manveru
Created October 3, 2016 07:40
Show Gist options
  • Save manveru/dcd16bc85e05016869a517fd4ffa558c to your computer and use it in GitHub Desktop.
Save manveru/dcd16bc85e05016869a517fd4ffa558c to your computer and use it in GitHub Desktop.
class DSL < BasicObject
RUBY_VERSION = ::RUBY_VERSION
attr_reader :envs
def initialize
@envs = ::Hash.new { |h, k| h[k] = [] }
@groups = [:default]
end
def method_missing(*args)
::Kernel.p(args)
end
def source(name, &block)
@source = name
yield if block
end
def group(*names, &block)
@groups = names || [:default]
yield if block
end
def gem(name, *args)
@groups.each do |group|
@envs[group] << [@source, name, args]
end
end
end
require 'pp'
dsl = DSL.new
dsl.instance_eval(File.read('Gemfile'))
pp dsl.envs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment