Class: PTLog::ChangeLog
- Inherits:
-
Object
- Object
- PTLog::ChangeLog
- Defined in:
- lib/ptlog/change_log.rb
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ChangeLog
constructor
A new instance of ChangeLog.
- #log(from, to) ⇒ Object
- #stories(from, to) ⇒ Object
Constructor Details
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
47 48 49 |
# File 'lib/ptlog/change_log.rb', line 47 def git @git end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
47 48 49 |
# File 'lib/ptlog/change_log.rb', line 47 def @tags end |
Class Method Details
.generate ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/ptlog/change_log.rb', line 70 def self.generate raise GeneralError, "You have to specify Pivotal token with export PIVOTAL_TOKEN=xyz" unless ENV.has_key?('PIVOTAL_TOKEN') changelog = new @builder = Nokogiri::HTML::Builder.new(:encoding => 'UTF-8') do |doc| doc.body do doc.h1 "Change Log @ #{Time.new.utc.strftime('%I:%M%P %D UTC')}" changelog..each do |tag| doc.h2 do doc.text "Release #{tag} " doc.text changelog.git.gcommit(tag).date.utc.strftime('(%I:%M%P %D UTC)') end changelog.stories(changelog..prev_to(tag), tag).each do |num, | doc.div(class: 'story') do story = Pivotal::Story.get(num) doc.h3 do if story.valid? doc.a(href: story.url) do doc.text "##{num}" end doc.text " - #{story.name}" else doc.text "##{num} - #{story.error}" end end doc.ul(class: 'commits') do .each do || doc.li end end end end end end end @builder.to_html end |
Instance Method Details
#log(from, to) ⇒ Object
55 56 57 |
# File 'lib/ptlog/change_log.rb', line 55 def log(from, to) git.log.between(from, to) end |
#stories(from, to) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ptlog/change_log.rb', line 59 def stories(from, to) output = {} log(from, to).each do |commit| commit..scan(/\#(\d+)/).flatten.each do |num| output[num] ||= [] output[num] << commit. end end output end |