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
- #git(source, options = {}, &block) ⇒ Object
- #group(*names, &block) ⇒ Object (also: #groups)
-
#initialize ⇒ Gemfile
constructor
A new instance of Gemfile.
- #load(path) ⇒ Object
- #path(source, options = {}, &block) ⇒ Object
- #platforms(*names, &block) ⇒ Object
- #ruby(ruby_version) ⇒ Object
- #run(definitions) ⇒ Object
- #source(source) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Gemfile
Returns a new instance of Gemfile.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/appraisal/gemfile.rb', line 13 def initialize @sources = [] @ruby_version = nil @dependencies = DependencyList.new @gemspec = nil @groups = {} @platforms = {} @git_sources = {} @path_sources = {} end |
Instance Attribute Details
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
11 12 13 |
# File 'lib/appraisal/gemfile.rb', line 11 def dependencies @dependencies end |
Instance Method Details
#dup ⇒ Object
77 78 79 80 81 |
# File 'lib/appraisal/gemfile.rb', line 77 def dup gemfile = Gemfile.new gemfile.run(to_s) gemfile end |
#gem(name, *requirements) ⇒ Object
32 33 34 |
# File 'lib/appraisal/gemfile.rb', line 32 def gem(name, *requirements) @dependencies.add(name, requirements) end |
#gemspec(options = {}) ⇒ Object
83 84 85 |
# File 'lib/appraisal/gemfile.rb', line 83 def gemspec( = {}) @gemspec = Gemspec.new() end |
#git(source, options = {}, &block) ⇒ Object
56 57 58 59 |
# File 'lib/appraisal/gemfile.rb', line 56 def git(source, = {}, &block) @git_sources[source] ||= GitSource.new(source, ) @git_sources[source].run(&block) end |
#group(*names, &block) ⇒ Object Also known as: groups
36 37 38 39 |
# File 'lib/appraisal/gemfile.rb', line 36 def group(*names, &block) @groups[names] ||= Group.new(names) @groups[names].run(&block) end |
#load(path) ⇒ Object
24 25 26 |
# File 'lib/appraisal/gemfile.rb', line 24 def load(path) run(IO.read(path)) end |
#path(source, options = {}, &block) ⇒ Object
61 62 63 64 |
# File 'lib/appraisal/gemfile.rb', line 61 def path(source, = {}, &block) @path_sources[source] ||= PathSource.new(source, ) @path_sources[source].run(&block) end |
#platforms(*names, &block) ⇒ Object
43 44 45 46 |
# File 'lib/appraisal/gemfile.rb', line 43 def platforms(*names, &block) @platforms[names] ||= Platform.new(names) @platforms[names].run(&block) end |
#ruby(ruby_version) ⇒ Object
52 53 54 |
# File 'lib/appraisal/gemfile.rb', line 52 def ruby(ruby_version) @ruby_version = ruby_version end |
#run(definitions) ⇒ Object
28 29 30 |
# File 'lib/appraisal/gemfile.rb', line 28 def run(definitions) instance_eval(definitions, __FILE__, __LINE__) if definitions end |
#source(source) ⇒ Object
48 49 50 |
# File 'lib/appraisal/gemfile.rb', line 48 def source(source) @sources << source end |
#to_s ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/appraisal/gemfile.rb', line 66 def to_s [source_entry, ruby_version_entry, git_sources_entry, path_sources_entry, dependencies_entry, groups_entry, platforms_entry, gemspec_entry].reject{ |s| s.nil? || s.empty? }.join("\n\n").strip end |