Add support for project name. Better rendering style.

This commit is contained in:
Glenn Y. Rolland 2016-06-29 10:36:20 +02:00
parent 469449a033
commit 52afe426c2
4 changed files with 84 additions and 51 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
Gemfile.lock
*.ods
*.ods#

View file

@ -5,3 +5,4 @@ gem 'thor'
gem 'minedig', git: "https://github.com/siman-man/minedig"
gem 'rspreadsheet'
gem 'pry'
gem 'semantic'

View file

@ -5,25 +5,33 @@ require 'minedig'
require 'yaml'
require 'rspreadsheet'
require 'pry'
require 'thor'
require 'semantic'
credential_file = ENV['HOME'] + '/.aoidos/redmine.yml'
class Aoidos < Thor
unless File.exist? credential_file
desc "export PROJECT", "Export project user stories"
def export(project)
target_version = make_version '2.0.0'
credential_file = ENV['HOME'] + '/.aoidos/redmine.yml'
unless File.exist? credential_file
sample_content = "home: 'http://redmine.example.com'\nkey: REDMINE_API_KEY"
raise Errno::ENOENT, "Please create %s file with:\n%s" % [
credential_file, sample_content
]
end
end
credential = YAML.load_file(credential_file)
redmine = Minedig::Redmine.new do |config|
credential = YAML.load_file(credential_file)
redmine = Minedig::Redmine.new do |config|
config.home = credential['home'] # ex: 'http://project.gnuside.com'
config.api_key = credential['key'] # ex: ...
end
end
book = Rspreadsheet::Workbook.new
tickets = redmine.project('catone-smb-device').tickets(count: :all)
tickets.each do |ticket|
book = Rspreadsheet::Workbook.new
tickets = redmine.project(project).tickets(count: :all)
tickets.each do |ticket|
type = case ticket.tracker_id
when 2 then :feature # feature
when 4 then :user_story # user story
@ -56,13 +64,35 @@ tickets.each do |ticket|
nextline = sheet.rows.size + 1
ticket_title = "%s%s" % [title[0].upcase, title[1..-1]]
ticket_version = (ticket.ticket['fixed_version'] || {'name' => ''})['name']
ticket_version =
(ticket.ticket['fixed_version'] || {'name' => ''})['name']
.split(/\s+-\s+/)[0]
ticket_version_obj = make_version ticket_version.gsub(/^v/,'')
puts "[ %- 8d | %- 30.30s | %- 50.50s ]" % [ticket.id, prefix, ticket_title]
[title, '', ticket_version, ticket.id].each_with_index do |txt,idx|
[ticket_title, '', ticket_version, ticket.id].each_with_index do |txt,idx|
cell = sheet.cell(nextline,idx+1)
cell.value = txt
if ticket_version_obj <= target_version then
cell.format.bold = true
cell.format.color = '#000000'
else
cell.format.color = '#888888'
end
end
end
book.save(project + '.ods')
end
private
def make_version str
return Semantic::Version.new str
rescue ArgumentError
make_version str + '.0'
end
end
book.save('report.ods')
Aoidos.start(ARGV)

Binary file not shown.