Class: Octopolo::Changelog
- Inherits:
-
Object
- Object
- Octopolo::Changelog
- Defined in:
- lib/octopolo/changelog.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#initialize(filename = "CHANGELOG.markdown") ⇒ Changelog
constructor
A new instance of Changelog.
- #open ⇒ Object
- #readlines ⇒ Object
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
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/octopolo/changelog.rb', line 5 def filename @filename end |
Instance Method Details
#open ⇒ Object
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 |
#readlines ⇒ Object
11 12 13 |
# File 'lib/octopolo/changelog.rb', line 11 def readlines File.readlines(@filename) end |