Created
October 3, 2016 07:40
-
-
Save manveru/dcd16bc85e05016869a517fd4ffa558c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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