Created
October 31, 2015 03:12
-
-
Save tk3/f89b6aff390c36457e30 to your computer and use it in GitHub Desktop.
mrbgem.rake のパラメーターを parse する
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
#!/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