trello2wr 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/trello2wr +22 -1
- data/lib/trello2wr.rb +52 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbd6bcc6972385e8f135e49a1385a1803c89e0f1
|
4
|
+
data.tar.gz: 3acd92c94a7599cb85fdc27e2120d6f63591ee2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcde24bebeffe678fd56c0ce0ecb57cc3d31ef457617876c4607f4cc0acf2a36f89e698d3f2698649342bfcf7ced6a62341eb588103e1103a411fb2d0ff410af
|
7
|
+
data.tar.gz: 4f00acba191f90d6729c6e1fb60a21f4558dcc40bfe2f8336e3a5e92376666bf34ff26a4ff9d3c0e03c623a1e7080c64844085608344474e1286b24fd77552da
|
data/bin/trello2wr
CHANGED
@@ -3,5 +3,26 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'trello2wr'
|
6
|
+
require 'optparse'
|
6
7
|
|
7
|
-
|
8
|
+
options = { week: Date.today.cweek-1 }
|
9
|
+
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: trello2wr [options]"
|
12
|
+
|
13
|
+
opts.on("-s", "--sprint [SPRINT NUMBER]", Numeric, "Generate a report for given sprint") do |s|
|
14
|
+
options[:sprint] = s
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-w", "--week [WEEK NUMBER]", Numeric, "Generate a report for given week") do |w|
|
18
|
+
options[:week] = w
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on("-h", "--help", "Prints this help") do
|
22
|
+
puts opts
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
end.parse!
|
27
|
+
|
28
|
+
Trello2WR.new(options[:sprint], options[:week]).export
|
data/lib/trello2wr.rb
CHANGED
@@ -2,58 +2,71 @@ require 'trello'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'uri'
|
4
4
|
|
5
|
-
if File.exist? File.expand_path("~/.trello2wr/config.yml")
|
6
|
-
CONFIG = YAML.load_file(File.expand_path("~/.trello2wr/config.yml"))
|
7
|
-
else
|
8
|
-
raise "ERROR: Config file not found!"
|
9
|
-
end
|
10
|
-
|
11
5
|
class Trello2WR
|
12
6
|
include Trello
|
13
7
|
include Trello::Authorization
|
14
8
|
|
15
|
-
attr_reader :user, :board, :
|
9
|
+
attr_reader :user, :board, :week
|
16
10
|
@@debug = true
|
17
11
|
|
18
|
-
def initialize
|
12
|
+
def initialize(sprint=nil, week)
|
13
|
+
@config = load_config
|
14
|
+
|
15
|
+
authenticate
|
16
|
+
|
17
|
+
@sprint = sprint
|
18
|
+
@week = week
|
19
|
+
|
20
|
+
@username = @config['trello']['username']
|
21
|
+
@user = find_member(@username)
|
22
|
+
@board = find_board
|
23
|
+
end
|
24
|
+
|
25
|
+
def authenticate
|
19
26
|
Trello::Authorization.const_set :AuthPolicy, OAuthPolicy
|
27
|
+
OAuthPolicy.consumer_credential = OAuthCredential.new @config['trello']['developer_public_key'], @config['trello']['developer_secret']
|
28
|
+
OAuthPolicy.token = OAuthCredential.new @config['trello']['member_token'], nil
|
29
|
+
end
|
20
30
|
|
31
|
+
def load_config
|
21
32
|
# Read keys from ~/trello2wr/config.yml
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
if File.exist? File.expand_path("~/.trello2wr/config.yml")
|
34
|
+
YAML.load_file(File.expand_path("~/.trello2wr/config.yml"))
|
35
|
+
else
|
36
|
+
raise "ERROR: Config file not found!"
|
37
|
+
end
|
38
|
+
end
|
28
39
|
|
29
|
-
|
40
|
+
def find_member(username)
|
41
|
+
self.log("*** Searching for user '#{username}'")
|
30
42
|
|
31
43
|
begin
|
32
|
-
|
44
|
+
Member.find(username)
|
33
45
|
rescue Trello::Error
|
34
|
-
raise "ERROR: user '#{
|
46
|
+
raise "ERROR: user '#{username}' not found!}"
|
35
47
|
end
|
48
|
+
end
|
36
49
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
# self.log("*** Getting lists for '#{CONFIG['trello']['boards'].first}' board")
|
42
|
-
@board = @user.boards.find{|b| b.name == CONFIG['trello']['boards'].first}
|
50
|
+
def find_board
|
51
|
+
board = @config['trello']['boards'].first
|
52
|
+
self.log("*** Getting lists for '#{board}' board")
|
53
|
+
@user.boards.find{|b| b.name == board}
|
43
54
|
end
|
44
55
|
|
45
56
|
def cards(board, list_name)
|
46
57
|
self.log("*** Getting cards for '#{list_name}' list")
|
47
58
|
|
48
59
|
if board
|
60
|
+
lists = board.lists
|
61
|
+
|
49
62
|
if list_name == 'Done'
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
63
|
+
lists = lists.select{|l| l.name.include?('Done')}
|
64
|
+
list = @sprint ? lists.select{|l| l.name.include?(@sprint.to_s) }.first : lists.sort_by{|l| l.id }.last
|
65
|
+
|
66
|
+
self.log("*** Getting cards for '#{list.name}' list (week #{@week})")
|
67
|
+
list.cards.select{|c| c.last_activity_date.to_datetime.cweek == @week && c.member_ids.include?(user.id) }
|
54
68
|
else
|
55
|
-
|
56
|
-
list.cards.select{|c| c.member_ids.include? self.user.id}
|
69
|
+
lists.find{|l| l.name == list_name}.cards.select{|c| c.member_ids.include? self.user.id}
|
57
70
|
end
|
58
71
|
else
|
59
72
|
raise "ERROR: Board '#{list_name}' not found!"
|
@@ -74,10 +87,10 @@ class Trello2WR
|
|
74
87
|
elsif list_name.downcase.include? 'review'
|
75
88
|
body += "\nIn review:\n"
|
76
89
|
elsif list_name.downcase.include? 'to do'
|
77
|
-
body += "\nObjectives:\n"
|
90
|
+
body += "\nObjectives:\n"
|
78
91
|
end
|
79
92
|
|
80
|
-
self.cards(
|
93
|
+
self.cards(board, list_name).each do |card|
|
81
94
|
if list_name.downcase.include? 'doing'
|
82
95
|
body += "- #{card.name} (##{card.short_id}) [WIP]\n"
|
83
96
|
else
|
@@ -87,15 +100,15 @@ class Trello2WR
|
|
87
100
|
end
|
88
101
|
|
89
102
|
body += "\n\nNOTE: (#<number>) are Trello board card IDs"
|
90
|
-
|
103
|
+
|
104
|
+
escape(body)
|
91
105
|
end
|
92
106
|
|
93
107
|
def construct_mail_to_url(recipient, subject, body)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
108
|
+
headers = { subject: subject, body: body }
|
109
|
+
headers[:cc] = @config['email']['cc'] if @config['email'].has_key?('cc') && @config['email']['cc'].present?
|
110
|
+
|
111
|
+
URI::MailTo.build({:to => recipient, :headers => headers.stringify_keys}).to_s.inspect
|
99
112
|
end
|
100
113
|
|
101
114
|
def escape(string)
|
@@ -103,10 +116,10 @@ class Trello2WR
|
|
103
116
|
end
|
104
117
|
|
105
118
|
def export
|
106
|
-
mailto = self.construct_mail_to_url(
|
119
|
+
mailto = self.construct_mail_to_url(@config['email']['recipient'], subject, body)
|
107
120
|
self.log("*** Preparing email, please wait ...")
|
108
121
|
|
109
|
-
system("#{
|
122
|
+
system("#{@config['email']['client']} #{mailto}")
|
110
123
|
|
111
124
|
self.log("*** DONE")
|
112
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trello2wr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Lewin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-trello
|