Class: Gel::GemfileParser::ParseContext
- Inherits:
-
Object
- Object
- Gel::GemfileParser::ParseContext
- Defined in:
- lib/gel/gemfile_parser.rb
Instance Method Summary collapse
- #gem(name, *requirements, **options) ⇒ Object
- #gemspec ⇒ Object
- #git_source(name, &block) ⇒ Object
- #group(*names) ⇒ Object
-
#initialize(result, filename) ⇒ ParseContext
constructor
A new instance of ParseContext.
- #platforms(*names) ⇒ Object
- #ruby(version, engine: nil, engine_version: nil) ⇒ Object
- #source(uri) ⇒ Object
Constructor Details
#initialize(result, filename) ⇒ ParseContext
Returns a new instance of ParseContext.
18 19 20 21 22 |
# File 'lib/gel/gemfile_parser.rb', line 18 def initialize(result, filename) @result = result @stack = [] end |
Instance Method Details
#gem(name, *requirements, **options) ⇒ Object
53 54 55 56 |
# File 'lib/gel/gemfile_parser.rb', line 53 def gem(name, *requirements, **) = @result.flatten(, @stack) @result.add_gem(name, requirements, ) end |
#gemspec ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/gel/gemfile_parser.rb', line 58 def gemspec if file = Dir["#{File.dirname(@result.filename)}/*.gemspec"].first spec = Gel::GemspecParser.parse(File.read(file), file) gem spec.name, path: "." spec.development_dependencies.each do |name, constraints| gem name, constraints, group: :development end end end |
#git_source(name, &block) ⇒ Object
37 38 39 |
# File 'lib/gel/gemfile_parser.rb', line 37 def git_source(name, &block) @result.git_sources[name] = block end |
#group(*names) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/gel/gemfile_parser.rb', line 68 def group(*names) @stack << { group: names } yield ensure @stack.pop end |
#platforms(*names) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/gel/gemfile_parser.rb', line 75 def platforms(*names) @stack << { platforms: names } yield ensure @stack.pop end |
#ruby(version, engine: nil, engine_version: nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gel/gemfile_parser.rb', line 41 def ruby(version, engine: nil, engine_version: nil) req = Gel::Support::GemRequirement.new(version) raise "Running ruby version #{RUBY_VERSION} does not match requested #{version.inspect}" unless req.satisfied_by?(Gel::Support::GemVersion.new(RUBY_VERSION)) raise "Running ruby engine #{RUBY_ENGINE} does not match requested #{engine.inspect}" unless !engine || RUBY_ENGINE == engine if engine_version raise "Cannot specify :engine_version without :engine" unless engine req = Gel::Support::GemRequirement.new(version) raise "Running ruby engine version #{RUBY_ENGINE_VERSION} does not match requested #{engine_version.inspect}" unless req.satisfied_by?(Gel::Support::GemVersion.new(RUBY_ENGINE_VERSION)) end @result.ruby << [version, engine: engine, engine_version: engine_version] end |
#source(uri) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gel/gemfile_parser.rb', line 24 def source(uri) if block_given? begin @stack << { source: uri } yield ensure @stack.pop end else @result.sources << uri end end |