Class: Crackin::Changelog
- Inherits:
-
Object
- Object
- Crackin::Changelog
- Defined in:
- lib/crackin/changelog.rb
Instance Method Summary collapse
- #full ⇒ Object
-
#initialize(file, version, options = {}) ⇒ Changelog
constructor
A new instance of Changelog.
- #save ⇒ Object
- #to_s ⇒ Object
- #update ⇒ Object
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 = { first: false }.merge() @output = file @version = version @config = Crackin.config @source = @config.source @data = {} end |
Instance Method Details
#full ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/crackin/changelog.rb', line 32 def full = to = 'HEAD' name = @version .reverse_each do |from| @data[name] = between(from, to).uniq to = from name = from end end |
#save ⇒ Object
43 44 45 |
# File 'lib/crackin/changelog.rb', line 43 def save File.open(@output, "w+") {|f| f.write(to_s)} end |
#to_s ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/crackin/changelog.rb', line 14 def to_s = ([@version, , @data.keys].flatten.uniq).reverse out = "### Changelog\n\n" .each do |section| lines = @data[section] out += "##### #{section}:\n" out += lines.join("\n") if lines out += "\n\n" end out end |
#update ⇒ Object
26 27 28 29 30 |
# File 'lib/crackin/changelog.rb', line 26 def update = load @data[@version] = between(.last, 'HEAD').uniq end |