Add option for output file name.
This commit is contained in:
parent
52afe426c2
commit
4829c60d23
1 changed files with 15 additions and 10 deletions
25
bin/aoidos
25
bin/aoidos
|
@ -9,11 +9,9 @@ require 'thor'
|
||||||
require 'semantic'
|
require 'semantic'
|
||||||
|
|
||||||
class Aoidos < Thor
|
class Aoidos < Thor
|
||||||
|
def initialize *args
|
||||||
|
super
|
||||||
|
|
||||||
|
|
||||||
desc "export PROJECT", "Export project user stories"
|
|
||||||
def export(project)
|
|
||||||
target_version = make_version '2.0.0'
|
|
||||||
credential_file = ENV['HOME'] + '/.aoidos/redmine.yml'
|
credential_file = ENV['HOME'] + '/.aoidos/redmine.yml'
|
||||||
|
|
||||||
unless File.exist? credential_file
|
unless File.exist? credential_file
|
||||||
|
@ -22,25 +20,32 @@ class Aoidos < Thor
|
||||||
credential_file, sample_content
|
credential_file, sample_content
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
credential = YAML.load_file(credential_file)
|
credential = YAML.load_file(credential_file)
|
||||||
redmine = Minedig::Redmine.new do |config|
|
|
||||||
|
@redmine = Minedig::Redmine.new do |config|
|
||||||
config.home = credential['home'] # ex: 'http://project.gnuside.com'
|
config.home = credential['home'] # ex: 'http://project.gnuside.com'
|
||||||
config.api_key = credential['key'] # ex: ...
|
config.api_key = credential['key'] # ex: ...
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
option :output, aliases: "-o", desc: "Set ODS output file name"
|
||||||
|
desc "export PROJECT", "Export project user stories"
|
||||||
|
def export(project)
|
||||||
|
target_version = make_version '2.0.0'
|
||||||
|
|
||||||
|
book_filename = options[:output] || (project + '.ods')
|
||||||
|
|
||||||
book = Rspreadsheet::Workbook.new
|
book = Rspreadsheet::Workbook.new
|
||||||
tickets = redmine.project(project).tickets(count: :all)
|
tickets = @redmine.project(project).tickets(count: :all)
|
||||||
tickets.each do |ticket|
|
tickets.each do |ticket|
|
||||||
type = case ticket.tracker_id
|
type = case ticket.tracker_id
|
||||||
when 2 then :feature # feature
|
when 2 then :feature # feature
|
||||||
when 4 then :user_story # user story
|
when 4 then :user_story # user story
|
||||||
else :bug
|
else :bug
|
||||||
end
|
end
|
||||||
|
|
||||||
next if type != :user_story
|
next if type != :user_story
|
||||||
|
|
||||||
|
|
||||||
prefix = nil
|
prefix = nil
|
||||||
title = nil
|
title = nil
|
||||||
sheet = nil
|
sheet = nil
|
||||||
|
@ -83,7 +88,7 @@ class Aoidos < Thor
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
book.save(project + '.ods')
|
book.save(book_filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue