Initial import.

This commit is contained in:
Glenn Y. Rolland 2016-06-28 19:02:07 +02:00
commit 076800e304
5 changed files with 82 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
Gemfile.lock

7
Gemfile Normal file
View file

@ -0,0 +1,7 @@
# A sample Gemfile
source "https://rubygems.org"
gem 'thor'
gem 'minedig', git: "https://github.com/siman-man/minedig"
gem 'rspreadsheet'
gem 'pry'

6
README.md Normal file
View file

@ -0,0 +1,6 @@
Aoidos (ἀοιδός)
==============
Export _users stories_ from your redmine into an OpenDocument Spreadsheet (ods) report.

68
bin/aoidos Executable file
View file

@ -0,0 +1,68 @@
#!/usr/bin/env ruby
# vim: syntax=ruby ts=4 sw=4 et nolist:
require 'minedig'
require 'yaml'
require 'rspreadsheet'
require 'pry'
credential_file = ENV['HOME'] + '/.sansa-report/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
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
book = Rspreadsheet::Workbook.new
tickets = redmine.project('catone-smb-device').tickets(count: :all)
tickets.each do |ticket|
type = case ticket.tracker_id
when 2 then :feature # feature
when 4 then :user_story # user story
else :bug
end
next if type != :user_story
prefix = nil
title = nil
sheet = nil
if ticket.subject.strip =~ /^(\s*As\s+.*?)\s*,\s+i\s+want\s+to\s+(.*)$/i then
prefix = $1.strip
title = $2.strip
else
raise "Invalid ticket #{ticket.id} - #{ticket.subject}"
end
sheet = book.sheet(prefix) || book.create_worksheet(prefix)
if sheet.rows.size == 0 then
[prefix, 'Description', 'Version', 'ID'].each_with_index do |txt,idx|
cell = sheet.cell(1,idx+1)
cell.value = txt
cell.format.bold = true
cell.format.color = '#FFFFFF'
cell.format.background_color = '#662D91'
end
end
nextline = sheet.rows.size + 1
ticket_title = "%s%s" % [title[0].upcase, title[1..-1]]
ticket_version = (ticket.ticket['fixed_version'] || {'name' => ''})['name']
puts "[ %- 8d | %- 30.30s | %- 50.50s ]" % [ticket.id, prefix, ticket_title]
[title, '', ticket_version, ticket.id].each_with_index do |txt,idx|
cell = sheet.cell(nextline,idx+1)
cell.value = txt
end
end
book.save('report.ods')

BIN
report.ods Normal file

Binary file not shown.