Skip to content

Commit b18bc2f

Browse files
committed
Create public repository
0 parents  commit b18bc2f

36 files changed

+3631
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.gem
2+
Gemfile.lock
3+
tmp

.rspec

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--format=documentation

CONTRIBUTING.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Contributions are welcome.
2+
3+
To report bugs please open GitHub issues.
4+
5+
To contribute code please open pull requests.
6+
7+
To discuss anything please [contact me](mailto:[email protected]).

COPYING

+674
Large diffs are not rendered by default.

Gemfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
source "https://rubygems.org"
2+
3+
gemspec
4+
5+
group :test do
6+
gem 'rspec'
7+
gem 'aruba'
8+
gem 'webmock'
9+
gem 'given_filesystem'
10+
end

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Trollolo
2+
3+
Command line tool to extract data from Trello, in particular for creating
4+
burndown charts.
5+
6+
## Functionality
7+
8+
A detailed description of the functionality of the tool can be found in the
9+
[man page](http://github.com/openSUSE/trollolo/blob/master/man/trollolo.1.md).
10+
11+
## Expectations
12+
13+
For expectations how the board has to be structured to make the burndown chart
14+
functions work see the Trollolo man page. There is an
15+
[example Trello board](https://trello.com/b/CRdddpdy/trollolo-testing-board)
16+
which demonstrates the expected structure.
17+
18+
## Configuration
19+
20+
Trollolo reads a configuration file `.trollolorc` in the home directory of the
21+
user running the command line tool. It reads the data required to authenticate
22+
with the Trello server from it. It's two values (the example shows random data):
23+
24+
```yaml
25+
developer_public_key: 87349873487ef8732487234
26+
member_token: 87345897238957a29835789b2374580927f3589072398579820345
27+
```
28+
29+
These values have to be set with the personal access data for the Trello API
30+
and the id of the board, which is processed.
31+
32+
For creating a developer key go to the
33+
[Developer API Keys](https://trello.com/1/appKey/generate) page on Trello. It's
34+
the key in the first box.
35+
36+
For creating a member token go follow the
37+
[instructions](https://trello.com/docs/gettingstarted/index.html#getting-a-token-from-a-user)
38+
in the Trello API documentation.
39+
40+
The board id is the cryptic string in the URL of your board.

Rakefile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace :man_pages do
2+
task :build do
3+
puts " Building man pages"
4+
system "ronn man/*.md"
5+
end
6+
end
7+
8+
namespace :gem do
9+
task :build => ["man_pages:build"] do
10+
system "gem build trollolo.gemspec"
11+
end
12+
end

bin/trollolo

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env ruby
2+
# Copyright (c) 2013-2014 SUSE LLC
3+
#
4+
# This program is free software; you can redistribute it and/or
5+
# modify it under the terms of version 3 of the GNU General Public License as
6+
# published by the Free Software Foundation.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program; if not, contact SUSE LLC.
15+
#
16+
# To contact SUSE about this file by physical or electronic mail,
17+
# you may find current contact information at www.suse.com
18+
19+
require_relative '../lib/trollolo'
20+
21+
config_path = ENV["TROLLOLO_CONFIG_PATH"] || File.expand_path("~/.trollolorc")
22+
23+
Cli.settings = Settings.new(config_path)
24+
25+
# Set debug flag, so thor throws exceptions on error
26+
ENV["THOR_DEBUG"] = "1"
27+
begin
28+
Cli.check_unknown_options!
29+
result = Cli.start ARGV
30+
rescue Thor::Error => e
31+
STDERR.puts e
32+
exit 1
33+
end

lib/burndown_chart.rb

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Copyright (c) 2013-2014 SUSE LLC
2+
#
3+
# This program is free software; you can redistribute it and/or
4+
# modify it under the terms of version 3 of the GNU General Public License as
5+
# published by the Free Software Foundation.
6+
#
7+
# This program is distributed in the hope that it will be useful,
8+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
# GNU General Public License for more details.
11+
#
12+
# You should have received a copy of the GNU General Public License
13+
# along with this program; if not, contact SUSE LLC.
14+
#
15+
# To contact SUSE about this file by physical or electronic mail,
16+
# you may find current contact information at www.suse.com
17+
18+
class BurndownChart
19+
20+
attr_accessor :data
21+
22+
def initialize(settings)
23+
@settings = settings
24+
@burndown_data = BurndownData.new settings
25+
26+
@data = {
27+
"meta" => {
28+
"board_id" => nil,
29+
"sprint" => 1,
30+
"total_days" => 9,
31+
"weekend_lines" => [ 3.5, 7.5 ]
32+
},
33+
"days" => []
34+
}
35+
end
36+
37+
def sprint
38+
@data["meta"]["sprint"]
39+
end
40+
41+
def sprint= s
42+
@data["meta"]["sprint"] = s
43+
end
44+
45+
def board_id
46+
@data["meta"]["board_id"]
47+
end
48+
49+
def board_id= id
50+
@data["meta"]["board_id"] = id
51+
end
52+
53+
def days
54+
@data["days"]
55+
end
56+
57+
def add_data(burndown_data, date)
58+
new_entry = {
59+
"date" => date.to_s,
60+
"story_points" => {
61+
"total" => burndown_data.story_points.total,
62+
"open" => burndown_data.story_points.open
63+
},
64+
"tasks" => {
65+
"total" => burndown_data.tasks.total,
66+
"open" => burndown_data.tasks.open
67+
},
68+
"story_points_extra" => {
69+
"done" => burndown_data.extra_story_points.done
70+
},
71+
"tasks_extra" => {
72+
"done" => burndown_data.extra_tasks.done
73+
}
74+
}
75+
new_days = Array.new
76+
replaced_entry = false
77+
@data["days"].each do |entry|
78+
if entry["date"] == date.to_s
79+
new_days.push(new_entry)
80+
replaced_entry = true
81+
else
82+
new_days.push(entry)
83+
end
84+
end
85+
if !replaced_entry
86+
new_days.push(new_entry)
87+
end
88+
@data["days"] = new_days
89+
end
90+
91+
def read_data filename
92+
@data = YAML.load_file filename
93+
end
94+
95+
def write_data filename
96+
File.open( filename, "w" ) do |file|
97+
file.write @data.to_yaml
98+
end
99+
end
100+
101+
def burndown_data_filename
102+
"burndown-data-#{sprint.to_s.rjust(2,"0")}.yaml"
103+
end
104+
105+
def setup(burndown_dir, board_id)
106+
self.board_id = board_id
107+
FileUtils.mkdir_p burndown_dir
108+
write_data File.join(burndown_dir, burndown_data_filename)
109+
FileUtils.cp(File.expand_path("../../templates/create_burndown",__FILE__),
110+
burndown_dir)
111+
end
112+
113+
def update(burndown_dir)
114+
Dir.glob("#{burndown_dir}/burndown-data-*.yaml").each do |file|
115+
file =~ /burndown-data-(.*).yaml/
116+
current_sprint = $1.to_i
117+
if current_sprint > sprint
118+
self.sprint = current_sprint
119+
end
120+
end
121+
burndown_data_path = File.join(burndown_dir, burndown_data_filename)
122+
begin
123+
read_data burndown_data_path
124+
@burndown_data.board_id = board_id
125+
@burndown_data.fetch
126+
add_data(@burndown_data, Date.today)
127+
write_data burndown_data_path
128+
rescue Errno::ENOENT
129+
raise TrolloloError.new( "'#{burndown_data_path}' not found" )
130+
end
131+
end
132+
end

0 commit comments

Comments
 (0)