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
- #group(*names) ⇒ 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 12 13 |
# File 'lib/appraisal/gemfile.rb', line 9 def initialize @sources = [] @dependencies = [] @gemspec = nil 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
40 41 42 43 44 45 46 47 48 |
# File 'lib/appraisal/gemfile.rb', line 40 def dup gemfile = Gemfile.new @sources.each { |source| gemfile.source(source) } dependencies.each do |dependency| gemfile.gem(dependency.name, *dependency.requirements) end gemfile.gemspec(@gemspec.) if @gemspec gemfile end |
#gem(name, *requirements) ⇒ Object
23 24 25 26 |
# File 'lib/appraisal/gemfile.rb', line 23 def gem(name, *requirements) @dependencies.reject! { |dependency| dependency.name == name } @dependencies << Dependency.new(name, requirements) end |
#gemspec(options = {}) ⇒ Object
50 51 52 |
# File 'lib/appraisal/gemfile.rb', line 50 def gemspec( = {}) @gemspec = Gemspec.new() end |
#group(*names) ⇒ Object
28 29 30 |
# File 'lib/appraisal/gemfile.rb', line 28 def group(*names) # ignore the group end |
#load(path) ⇒ Object
15 16 17 |
# File 'lib/appraisal/gemfile.rb', line 15 def load(path) run(IO.read(path)) end |
#run(definitions) ⇒ Object
19 20 21 |
# File 'lib/appraisal/gemfile.rb', line 19 def run(definitions) instance_eval(definitions, __FILE__, __LINE__) end |
#source(source) ⇒ Object
32 33 34 |
# File 'lib/appraisal/gemfile.rb', line 32 def source(source) @sources << source end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/appraisal/gemfile.rb', line 36 def to_s [source_entry, dependencies_entry, gemspec_entry].join("\n\n") end |