Class: Bumpversion::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/bumpversion/reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Reader

Returns a new instance of Reader.



3
4
5
6
# File 'lib/bumpversion/reader.rb', line 3

def initialize(options)
  @options = options
  @files_to_write = []
end

Instance Attribute Details

#files_to_writeObject (readonly)

Returns the value of attribute files_to_write.



8
9
10
# File 'lib/bumpversion/reader.rb', line 8

def files_to_write
  @files_to_write
end

Instance Method Details

#reader!Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bumpversion/reader.rb', line 16

def reader!
  files_to_read = @options[:file].split(",")
  files_to_read.each do |file_to_read|
    files_to_write << {
      filename: file_to_read,
      content: File.read(file_to_read)
    }
  end

  validate!
end

#validate!Object



10
11
12
13
14
# File 'lib/bumpversion/reader.rb', line 10

def validate!
  files_to_write.each do |file_to_write|
    raise "Current Version not found in #{file_to_write[:filename]} file" unless file_to_write[:content].include? @options[:current_version]
  end
end