Class: InvocaGems::GemfileLine
- Inherits:
-
Object
- Object
- InvocaGems::GemfileLine
- Defined in:
- lib/invoca_gems/gemfile_line.rb
Instance Attribute Summary collapse
-
#gem_git ⇒ Object
readonly
Returns the value of attribute gem_git.
-
#gem_github ⇒ Object
readonly
Returns the value of attribute gem_github.
-
#gem_name ⇒ Object
readonly
Returns the value of attribute gem_name.
-
#gem_options ⇒ Object
readonly
Returns the value of attribute gem_options.
-
#gem_ref ⇒ Object
readonly
Returns the value of attribute gem_ref.
-
#gem_version ⇒ Object
readonly
Returns the value of attribute gem_version.
-
#gemfile ⇒ Object
readonly
Returns the value of attribute gemfile.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #gem(name, *args) ⇒ Object
-
#initialize(gemfile, line, index) ⇒ GemfileLine
constructor
A new instance of GemfileLine.
- #save! ⇒ Object
-
#update_as_github(gem_version, uri, sha) ⇒ Object
TODO - Perfer branch before ref.
- #update_as_path(path) ⇒ Object
Constructor Details
#initialize(gemfile, line, index) ⇒ GemfileLine
Returns a new instance of GemfileLine.
5 6 7 8 9 10 11 12 |
# File 'lib/invoca_gems/gemfile_line.rb', line 5 def initialize(gemfile, line, index) @gemfile = gemfile @line = line @index = index @prefix = @line.match(/\A(\s*)gem/)[1] instance_eval(line) end |
Instance Attribute Details
#gem_git ⇒ Object (readonly)
Returns the value of attribute gem_git.
3 4 5 |
# File 'lib/invoca_gems/gemfile_line.rb', line 3 def gem_git @gem_git end |
#gem_github ⇒ Object (readonly)
Returns the value of attribute gem_github.
3 4 5 |
# File 'lib/invoca_gems/gemfile_line.rb', line 3 def gem_github @gem_github end |
#gem_name ⇒ Object (readonly)
Returns the value of attribute gem_name.
3 4 5 |
# File 'lib/invoca_gems/gemfile_line.rb', line 3 def gem_name @gem_name end |
#gem_options ⇒ Object (readonly)
Returns the value of attribute gem_options.
3 4 5 |
# File 'lib/invoca_gems/gemfile_line.rb', line 3 def @gem_options end |
#gem_ref ⇒ Object (readonly)
Returns the value of attribute gem_ref.
3 4 5 |
# File 'lib/invoca_gems/gemfile_line.rb', line 3 def gem_ref @gem_ref end |
#gem_version ⇒ Object (readonly)
Returns the value of attribute gem_version.
3 4 5 |
# File 'lib/invoca_gems/gemfile_line.rb', line 3 def gem_version @gem_version end |
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
2 3 4 |
# File 'lib/invoca_gems/gemfile_line.rb', line 2 def gemfile @gemfile end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
2 3 4 |
# File 'lib/invoca_gems/gemfile_line.rb', line 2 def index @index end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
2 3 4 |
# File 'lib/invoca_gems/gemfile_line.rb', line 2 def line @line end |
Instance Method Details
#gem(name, *args) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/invoca_gems/gemfile_line.rb', line 18 def gem(name, *args) @gem_name = name @gem_options = args.last.is_a?(Hash) ? args.pop.dup : {} @gem_version = args.first || ">= 0" @gem_branch = @gem_options[:branch] || 'master' @gem_ref = @gem_options.delete(:ref) @gem_git = @gem_options.delete(:git) @gem_github = @gem_options.delete(:github) end |
#save! ⇒ Object
14 15 16 |
# File 'lib/invoca_gems/gemfile_line.rb', line 14 def save! gemfile.save!(self) end |
#update_as_github(gem_version, uri, sha) ⇒ Object
TODO - Perfer branch before ref. TODO - handle local branch…
38 39 40 41 42 43 44 45 46 |
# File 'lib/invoca_gems/gemfile_line.rb', line 38 def update_as_github(gem_version, uri, sha) @line = [ "#{@prefix}gem ", "'#{gem_name}',".ljust(24), " '#{gem_version}', ".ljust(11), "git: '#{uri}',".ljust(56), "ref: '#{sha}'" ].join('') end |
#update_as_path(path) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/invoca_gems/gemfile_line.rb', line 28 def update_as_path(path) @line = [ "#{@prefix}gem ", "'#{gem_name}',".ljust(24), " path: '#{path}'" ].join('') end |