Class: Railslog::Changelog

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Changelog

Returns a new instance of Changelog.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/railslog.rb', line 23

def initialize(text)
  @releases = []

  current_release = nil
  current_entry = nil

  text.each_line do |line|
    if Release.recognize?(line)
      current_release = Release.new(line)
      @releases << current_release
    elsif Entry.recognize?(line)
      current_entry = Entry.new(line)
      current_release ||= Release.new('Unreleased')
      current_release.add_entry(current_entry)
    elsif !current_entry.nil?
      current_entry.add_line(line)
    end
  end
end

Instance Attribute Details

#releasesObject (readonly)

Returns the value of attribute releases.



21
22
23
# File 'lib/railslog.rb', line 21

def releases
  @releases
end

Instance Method Details

#to_sObject



43
44
45
# File 'lib/railslog.rb', line 43

def to_s
  "<#{self.class} releases:#{@releases.size}>"
end