Class: Octopolo::Changelog

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename = "CHANGELOG.markdown") ⇒ Changelog

Returns a new instance of Changelog.



7
8
9
# File 'lib/octopolo/changelog.rb', line 7

def initialize(filename="CHANGELOG.markdown")
  @filename = filename
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



5
6
7
# File 'lib/octopolo/changelog.rb', line 5

def filename
  @filename
end

Instance Method Details

#openObject



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

def open
  FileUtils.touch(@filename) unless File.exists?(@filename)
  File.copy_stream(@filename,'old_changelog')
  File.open('old_changelog', 'r') do |old_changelog|
    File.open(@filename, 'w') do |changelog|
      yield changelog
      old_changelog.each_line { |line| changelog.puts line }
    end
  end
  File.delete('old_changelog')
end

#readlinesObject



11
12
13
# File 'lib/octopolo/changelog.rb', line 11

def readlines
  File.readlines(@filename)
end