Class: Printer
- Inherits:
-
Object
- Object
- Printer
- Defined in:
- lib/printer.rb
Instance Method Summary collapse
- #get_dependency(story) ⇒ Object
- #github_issue_info(story) ⇒ Object
- #github_pr_info(story) ⇒ Object
- #html(stories) ⇒ Object
- #include_dependencies(dependencies) ⇒ Object
- #planbox_info(story) ⇒ Object
- #print(stories) ⇒ Object
- #title(text) ⇒ Object
Instance Method Details
#get_dependency(story) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/printer.rb', line 52 def get_dependency(story) # find dependency based on blocks unless story['blocks'].nil? story['blocks'].each do |block| if block.split("\n")[0].match(/(^(#* *depend(s|ent|ency|encies|encys)))/i) return block end end end # find a line starting with 'depends on' in body if story['body'] dependency = story['body'].match(/^(depend(s|ent)? +on.*)/i) return dependency[0] if dependency end return if story['labels'].nil? # else find dependency based on labels if story['labels'].to_s.match /Has Dependency/i return "has a dependency label" end return nil end |
#github_issue_info(story) ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/printer.rb', line 87 def github_issue_info story line = "" story['linked_issues'].each do |issue| line += ":ISSUE##{issue['number']}" line +=":Milestone #{issue['milestone']['title']}" if issue['milestone'] end line end |
#github_pr_info(story) ⇒ Object
81 82 83 84 85 |
# File 'lib/printer.rb', line 81 def github_pr_info story line = ":#{story['number']}:#{story['title']}" line += github_issue_info(story) if story['linked_issues'] line end |
#html(stories) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/printer.rb', line 5 def html stories $stories = stories file_path = File.('../../templates/template.html.haml', __FILE__) template = File.read(file_path) engine = Haml::Engine.new(template) File.write 'releasenotes.html',engine.render end |
#include_dependencies(dependencies) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/printer.rb', line 96 def include_dependencies dependencies release_notes = title "Dependencies" dependencies.each do |dependency| release_notes += dependency release_notes += "\n" end release_notes end |
#planbox_info(story) ⇒ Object
77 78 79 |
# File 'lib/printer.rb', line 77 def planbox_info story "#{story['id']}:#{story['status']}:#{story['name']}:#{story['project_name']}:#{story['project_alias']}" end |
#print(stories) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/printer.rb', line 13 def print stories dependencies = [] # Github stories only release_notes = "PR:TITLE:ISSUES:MILESTONE\n" stories.each do |story| next if Planbox.has_planbox?(story) dependency = get_dependency(story) dependencies << "PR ##{story['number']}: " + dependency unless dependency.nil? line = "" line += github_pr_info(story) unless story['number'].nil? release_notes += line + "\n" end # Planbox matching stories if Planbox.has_planbox?(stories) release_notes += title "Matched Planbox Stories" release_notes += "ID:STATUS:TITLE:PROJECT_NAME:PROJECT_ALIAS:PR:TITLE\n" stories.each do |story| next unless Planbox.has_planbox?(story) dependency = get_dependency(story) dependencies << "PR ##{story['number']}: " + dependency unless dependency.nil? line = "" line += planbox_info(story) line += github_pr_info(story) unless story['number'].nil? end end # print dependency blocks unless dependencies.empty? release_notes += include_dependencies dependencies end puts release_notes end |
#title(text) ⇒ Object
105 106 107 |
# File 'lib/printer.rb', line 105 def title text "\n---- #{text} ----\n\n" end |