Class: InvocaGems::GemspecLine

Inherits:
Object
  • Object
show all
Defined in:
lib/invoca_gems/gemspec_line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemspec, gem_name, line, index) ⇒ GemspecLine

Returns a new instance of GemspecLine.



4
5
6
7
8
9
10
# File 'lib/invoca_gems/gemspec_line.rb', line 4

def initialize(gemspec, gem_name, line, index)
  @gemspec = gemspec
  @gem_name = gem_name
  @line = line
  @index = index
  @prefix = @line.match(/\A(\s*\S+\s+)[\'\"]/)[1]
end

Instance Attribute Details

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



2
3
4
# File 'lib/invoca_gems/gemspec_line.rb', line 2

def gem_name
  @gem_name
end

#gemspecObject (readonly)

Returns the value of attribute gemspec.



2
3
4
# File 'lib/invoca_gems/gemspec_line.rb', line 2

def gemspec
  @gemspec
end

#indexObject (readonly)

Returns the value of attribute index.



2
3
4
# File 'lib/invoca_gems/gemspec_line.rb', line 2

def index
  @index
end

#lineObject (readonly)

Returns the value of attribute line.



2
3
4
# File 'lib/invoca_gems/gemspec_line.rb', line 2

def line
  @line
end

#prefixObject (readonly)

Returns the value of attribute prefix.



2
3
4
# File 'lib/invoca_gems/gemspec_line.rb', line 2

def prefix
  @prefix
end

Instance Method Details

#save!Object



12
13
14
# File 'lib/invoca_gems/gemspec_line.rb', line 12

def save!
  gemspec.save!(self)
end

#update_version(new_version) ⇒ Object



16
17
18
# File 'lib/invoca_gems/gemspec_line.rb', line 16

def update_version(new_version)
  @line = "#{@prefix}'#{gem_name}', '#{new_version}'"
end