Class: InvocaGems::Gemspec
- Inherits:
-
Object
- Object
- InvocaGems::Gemspec
- Defined in:
- lib/invoca_gems/gemspec.rb
Instance Method Summary collapse
- #find(gem_name) ⇒ Object
-
#initialize(path) ⇒ Gemspec
constructor
A new instance of Gemspec.
- #save!(gemspec) ⇒ Object
Constructor Details
#initialize(path) ⇒ Gemspec
Returns a new instance of Gemspec.
2 3 4 5 |
# File 'lib/invoca_gems/gemspec.rb', line 2 def initialize(path) @path = path @lines = File.readlines(path).map(&:chomp) end |
Instance Method Details
#find(gem_name) ⇒ Object
7 8 9 10 |
# File 'lib/invoca_gems/gemspec.rb', line 7 def find(gem_name) index = @lines.find_index { |l| l =~ /\A\s*\S+\s+[\'\"]#{gem_name}[\'\"]/ } or InvocaGems::Presenter. "could not find gem #{gem_name} in #{@path}" InvocaGems::GemspecLine.new(self, gem_name, @lines[index], index) end |
#save!(gemspec) ⇒ Object
12 13 14 15 |
# File 'lib/invoca_gems/gemspec.rb', line 12 def save!(gemspec) update_gemspec(gemspec) File.open(@path, "w") { |f| f.write(@lines.join("\n") + "\n") } end |