Class: Tumbler::Manager::Changelog
- Inherits:
-
Object
- Object
- Tumbler::Manager::Changelog
- Defined in:
- lib/tumbler/manager/changelog.rb
Constant Summary collapse
- DEFAULT_FILE =
'CHANGELOG'
Constants included from Informer
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Attributes included from Runner
Instance Method Summary collapse
- #base ⇒ Object
- #commit ⇒ Object
- #ensure_existence ⇒ Object
- #filename(file) ⇒ Object
-
#initialize(manager, &block) ⇒ Changelog
constructor
A new instance of Changelog.
- #prepend(data) ⇒ Object
- #update ⇒ Object
- #write_version_header ⇒ Object
Methods included from Informer
Methods included from Runner
Constructor Details
#initialize(manager, &block) ⇒ Changelog
Returns a new instance of Changelog.
14 15 16 17 |
# File 'lib/tumbler/manager/changelog.rb', line 14 def initialize(manager, &block) @manager = manager instance_eval(&block) if block end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
12 13 14 |
# File 'lib/tumbler/manager/changelog.rb', line 12 def file @file end |
Instance Method Details
#base ⇒ Object
64 65 66 |
# File 'lib/tumbler/manager/changelog.rb', line 64 def base @manager.base end |
#commit ⇒ Object
60 61 62 |
# File 'lib/tumbler/manager/changelog.rb', line 60 def commit sh "git commit #{@basefile} -m'Updated changelog'" end |
#ensure_existence ⇒ Object
56 57 58 |
# File 'lib/tumbler/manager/changelog.rb', line 56 def ensure_existence File.open(@file, 'w') {|f| f << ''} unless File.exist?(@file) end |
#filename(file) ⇒ Object
19 20 21 22 |
# File 'lib/tumbler/manager/changelog.rb', line 19 def filename(file) @basefile = file @file = File.join(@manager.base, file) end |
#prepend(data) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tumbler/manager/changelog.rb', line 30 def prepend(data) if @manager.noop @manager.dry "Prepending #{data} to `#{@basefile}'" else Tempfile.open('changelog') do |tmp| tmp.puts data File.open(@file) do |f| f.each do |line| tmp << line end end tmp.close FileUtils.copy(tmp.path, @file) File.unlink(tmp.path) end end end |
#update ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/tumbler/manager/changelog.rb', line 48 def update ensure_existence inform "Updating `#{@basefile}' with latest changes" do prepend("\n") prepend(@manager.latest_changes.inject('') { |changes, change| changes << "* #{change.summary} (#{change.}, #{change.hash})\n" }) end end |
#write_version_header ⇒ Object
24 25 26 27 28 |
# File 'lib/tumbler/manager/changelog.rb', line 24 def write_version_header inform "Writing version header to `#{@basefile}'" do prepend "== #{@manager.version}\n\n" end end |