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
#initialize ⇒ ChangeLog
Returns a new instance of ChangeLog.
49 50 51 52 53 |
# File 'lib/ptlog/change_log.rb', line 49 def initialize @git ||= Git.open(Dir.getwd) @start = ENV['PTLOG_SINCE'] || git.lib.[-1] = PTLog::TagList.new(@git, @start) end |
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 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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# 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.span(class: 'date') do doc.text changelog.git.gcommit(tag).date.utc.strftime('(%I:%M%P %D UTC)') end 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.span(class: 'num') do doc.text num end end doc.span(class: 'name') do doc.text " " doc.text story.name end else doc.span(class: 'num') do doc.text num end doc.span(class: 'name error') do doc.text " " doc.text story.error end 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 |