Class: Appraisal::Gemfile
- Inherits:
-
Object
- Object
- Appraisal::Gemfile
- Defined in:
- lib/appraisal/gemfile.rb
Overview
Load bundler Gemfiles and merge dependencies
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
Instance Method Summary collapse
- #dup ⇒ Object
- #gem(name, *requirements) ⇒ Object
- #gemspec(options = {}) ⇒ Object
-
#initialize ⇒ Gemfile
constructor
A new instance of Gemfile.
- #load(path) ⇒ Object
- #run(definitions) ⇒ Object
- #source(source) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Gemfile
Returns a new instance of Gemfile.
9 10 11 |
# File 'lib/appraisal/gemfile.rb', line 9 def initialize @dependencies = {} end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
7 8 9 |
# File 'lib/appraisal/gemfile.rb', line 7 def dependencies @dependencies end |
Instance Method Details
#dup ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/appraisal/gemfile.rb', line 33 def dup Gemfile.new.tap do |gemfile| gemfile.source @source dependencies.values.each do |dependency| gemfile.gem(dependency.name, *dependency.requirements) end gemfile.gemspec(@gemspec.) if @gemspec end end |
#gem(name, *requirements) ⇒ Object
21 22 23 |
# File 'lib/appraisal/gemfile.rb', line 21 def gem(name, *requirements) @dependencies[name] = Dependency.new(name, requirements) end |
#gemspec(options = {}) ⇒ Object
43 44 45 |
# File 'lib/appraisal/gemfile.rb', line 43 def gemspec( = {}) @gemspec = Gemspec.new() end |
#load(path) ⇒ Object
13 14 15 |
# File 'lib/appraisal/gemfile.rb', line 13 def load(path) run(IO.read(path)) end |
#run(definitions) ⇒ Object
17 18 19 |
# File 'lib/appraisal/gemfile.rb', line 17 def run(definitions) instance_eval(definitions, __FILE__, __LINE__) end |
#source(source) ⇒ Object
25 26 27 |
# File 'lib/appraisal/gemfile.rb', line 25 def source(source) @source = source end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/appraisal/gemfile.rb', line 29 def to_s [source_entry, dependencies_entry, gemspec_entry].join("\n\n") end |