Class: Crackin::Changelog

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

Instance Method Summary collapse

Constructor Details

#initialize(file, version, options = {}) ⇒ Changelog

Returns a new instance of Changelog.



3
4
5
6
7
8
9
10
11
12
# File 'lib/crackin/changelog.rb', line 3

def initialize(file, version, options={})
  @options = {
      first: false
  }.merge(options)
  @output = file
  @version = version
  @config = Crackin.config
  @source = @config.source
  @data = {}
end

Instance Method Details

#fullObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/crackin/changelog.rb', line 32

def full
  tags = ordered_tags
  to = 'HEAD'
  name = @version
  tags.reverse_each do |from|
    @data[name] = between(from, to).uniq
    to = from
    name = from
  end
end

#saveObject



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

def save
  File.open(@output, "w+") {|f| f.write(to_s)}
end

#to_sObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/crackin/changelog.rb', line 14

def to_s
  tags = order_tags([@version, source_tags, @data.keys].flatten.uniq).reverse
  out = "### Changelog\n\n"
  tags.each do |section|
    lines = @data[section]
    out += "##### #{section}:\n"
    out += lines.join("\n") if lines
    out += "\n\n"
  end
  out
end

#updateObject



26
27
28
29
30
# File 'lib/crackin/changelog.rb', line 26

def update
  tags = ordered_tags
  load
  @data[@version] = between(tags.last, 'HEAD').uniq
end