Skip to content

Instantly share code, notes, and snippets.

@tk3
Created October 31, 2015 03:12
Show Gist options
  • Save tk3/f89b6aff390c36457e30 to your computer and use it in GitHub Desktop.
Save tk3/f89b6aff390c36457e30 to your computer and use it in GitHub Desktop.
mrbgem.rake のパラメーターを parse する
#!/usr/bin/env ruby
class Foo
def self.parse(src)
instance_eval(src)
end
class MRuby
class Gem
class Specification
attr_accessor :license, :author, :summary, :dependencies
def initialize(name, &block)
@dependencies = []
block.call(self)
end
def add_dependency(name)
@dependencies << name
end
end
end
end
end
p Foo.parse DATA.read
# Foo::MRuby::Gem::Specification
# #<Foo::MRuby::Gem::Specification:0x007fb2a11f71a0 @dependencies=["mruby-string-ext"], @license="MIT", @author="mruby developers", @summary="Random class">
__END__
MRuby::Gem::Specification.new('mruby-random') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'Random class'
spec.add_dependency 'mruby-string-ext'
spec.add_dependency 'mruby-pack'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment