diff --git a/bin/git2pdf b/bin/git2pdf index 81f0557..07a5c43 100755 --- a/bin/git2pdf +++ b/bin/git2pdf @@ -11,7 +11,9 @@ class Git2PdfBash < Thor option :api, aliases: :a option :organisation, aliases: :o option :labels, aliases: :l - option :from_number, aliases: :f + option :from_number, aliases: :n + option :from_date, aliases: :d + option :quiet_labels, aliases: :q def gen(repositories="") repos = repositories.split(',').collect { |r| r.strip } @@ -31,7 +33,7 @@ class Git2PdfBash < Thor pass = pass.strip.gsub(/\n/,'') end - g = Git2Pdf.new repos: repos, basic_auth: [options[:user],pass], org: options[:organisation], user: options[:user], api: options[:api], labels: options[:labels], from_number: options[:from_number] + g = Git2Pdf.new repos: repos, basic_auth: [options[:user],pass], org: options[:organisation], user: options[:user], api: options[:api], labels: options[:labels], from_number: options[:from_number], from_date: options[:from_date], quiet_labels: options[:quiet_labels] done = g.execute puts "\n#{done} cards output to issues.pdf" end diff --git a/lib/git2pdf.rb b/lib/git2pdf.rb index 804cd1b..f6513bc 100644 --- a/lib/git2pdf.rb +++ b/lib/git2pdf.rb @@ -14,6 +14,8 @@ def initialize(options={}) @api = options[:api] || 'https://api.github.com' @labels = "&labels=#{options[:labels]}" || '' @from_number = options[:from_number] || nil + @from_date = options[:from_date] || nil + @quiet_labels = options[:quiet_labels] || [] end def execute @@ -41,13 +43,24 @@ def get_issues next end end - labels = val["labels"].collect { |l| l["name"].upcase }.join(', ') + if @from_date + from_date = DateTime.parse(@from_date) + issue_creation_date = DateTime.parse(val["created_at"]) + + if from_date > issue_creation_date + next + end + end + labels = val["labels"].reject { |l| @quiet_labels.include?(l["name"]) } + .collect { |l| l["name"].upcase } + .join(', ') + type = "" type = "BUG" if labels =~ /bug/i #not billable type = "FEATURE" if labels =~ /feature/i #billable type = "ENHANCEMENT" if labels =~ /enhancement/i #billable type = "AMEND" if labels =~ /amend/i #not billable - type = "TASK" if labels =~ /task/i #not billable + type = "TASK" if labels =~ /userstory/i #not billable milestone = val["milestone"] ? val["milestone"]["title"] : "" @@ -123,22 +136,22 @@ def pdf(batch) #text_box fields["due"] || "", :at=>[120,20], :width=>60, :overflow=>:shrink_to_fit y_offset = y_offset + 20 end - + fill_color "EEEEEE" - fill_color "D0021B" if issue[:type] == "BUG" - fill_color "1D8FCE" if issue[:type] == "TASK" + fill_color "D0021B" if issue[:type] == "BUG" + fill_color "1D8FCE" if issue[:type] == "TASK" fill_color "FBF937" if issue[:type] == "FEATURE" fill_color "F5B383" if issue[:type] == "AMEND" fill_color "FBF937" if issue[:type] == "ENHANCEMENT" if issue[:type] and issue[:type] != "" - fill{rectangle([0,220], margin-10, 220)} + fill{rectangle([0,220], margin-10, 220)} else - fill{rectangle([0,220], margin-10, 220)} + fill{rectangle([0,220], margin-10, 220)} end - + fill_color(0,0,0,100) - + # if issue[:type] and issue[:type] != "" # y_offset = y_offset - 20 # # Type @@ -159,8 +172,6 @@ def pdf(batch) #text_box fields[:due] || "", :at=>[120,20], :width=>60, :overflow=>:shrink_to_fit #end - - #if col == 1 # row = row + 1 # col = 0