trellohub 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +9 -0
- data/README.md +33 -7
- data/bin/trellohub +7 -0
- data/lib/trellohub.rb +10 -3
- data/lib/trellohub/card.rb +8 -79
- data/lib/trellohub/configurable.rb +75 -36
- data/lib/trellohub/core_ext/array.rb +10 -0
- data/lib/trellohub/core_ext/hash.rb +9 -1
- data/lib/trellohub/core_ext/string.rb +22 -0
- data/lib/trellohub/form.rb +142 -0
- data/lib/trellohub/form/card.rb +163 -0
- data/lib/trellohub/form/issue.rb +191 -0
- data/lib/trellohub/list.rb +18 -2
- data/lib/trellohub/member.rb +14 -2
- data/lib/trellohub/mocking.rb +87 -0
- data/lib/trellohub/repository.rb +47 -0
- data/lib/trellohub/synchronal.rb +22 -41
- data/lib/trellohub/version.rb +1 -1
- data/spec/helper.rb +59 -0
- data/spec/trellohub_spec.rb +51 -0
- metadata +20 -7
- data/lib/trellohub/cards.rb +0 -58
- data/lib/trellohub/lists.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3e0c1cd2aeef9e9fed641f72a69f7af0c079322
|
4
|
+
data.tar.gz: cc7b3945d5f13f745d7667d41416d7cf975dec7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bcd7fa80eef654f76073370b126dfd410560529bfea907c84c65d039e0b7b62f6343b373f1f495e994726eaf3db849070d29991f7a94e7fd84b7b8e5fc7ccc5
|
7
|
+
data.tar.gz: c32fecbcb9e4648e6afb75a1825374fe95329617ad7792fa27d44f7baa06b53bd02d30b55ea25a167e957153a8c68a0bf1a7f5681eb336340ff75286160b36d3
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -46,18 +46,44 @@ $ cp boards/example.yml boards/your_board_name.yml
|
|
46
46
|
edit `boards/your_board_name.yml`:
|
47
47
|
|
48
48
|
```yml
|
49
|
+
board_id: 531c1a3524127e**********
|
50
|
+
repositories:
|
51
|
+
- full_name: organization/project_one
|
52
|
+
milestone: Stable Version
|
53
|
+
- full_name: organization/project_two
|
54
|
+
milestone: Ver2
|
55
|
+
- full_name: organization/project_three
|
56
|
+
milestone: New Feature
|
57
|
+
lists:
|
58
|
+
- name: Backlog
|
59
|
+
default: true
|
60
|
+
- name: To Do
|
61
|
+
issue_label: to do
|
62
|
+
- name: Doing
|
63
|
+
issue_label: doing
|
64
|
+
- name: Done
|
65
|
+
issue_label: done
|
66
|
+
- name: Recent Closed
|
67
|
+
issue_closed_at: '>= Time.now.utc -60*60*24*7'
|
68
|
+
trello_application_key: 429452e37b7e********************
|
69
|
+
trello_application_token: dc71944d87340616f03a7647****************************************
|
70
|
+
github_access_token: e17e1c6caa******************************
|
71
|
+
```
|
72
|
+
|
73
|
+
```sh
|
74
|
+
$ env DEBUG=true env CONFIG_PATH=~/trellohub/boards/your_board_name.yml trellohub
|
49
75
|
```
|
50
76
|
|
51
77
|
Synchronizing
|
52
78
|
-------------
|
53
79
|
|
54
|
-
GitHub Issues
|
55
|
-
-------------
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
80
|
+
GitHub Issues | Trello Cards | Description
|
81
|
+
------------- | ------------ | -----------
|
82
|
+
Status(open, closed) changes | Closed(true false) changes | All created by a token user When trellohub creates the issue.
|
83
|
+
Milestone changes | Status changes | If setted milestones
|
84
|
+
Labels change | List changes | e.g. The "todo" label => The "To Do" list
|
85
|
+
Title changes | Title changes | Card title format is 'repo_name#issue_number title'
|
86
|
+
Asignee changes | Member changes | First member is issue assignee.
|
61
87
|
|
62
88
|
Contributing
|
63
89
|
------------
|
data/bin/trellohub
ADDED
data/lib/trellohub.rb
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
require 'octokit'
|
2
2
|
require 'trell'
|
3
|
+
require 'yaml'
|
4
|
+
|
3
5
|
require 'trellohub/version'
|
4
|
-
require 'trellohub/
|
6
|
+
require 'trellohub/repository'
|
5
7
|
require 'trellohub/board'
|
6
8
|
require 'trellohub/list'
|
7
|
-
require 'trellohub/lists'
|
8
9
|
require 'trellohub/card'
|
9
|
-
require 'trellohub/cards'
|
10
10
|
require 'trellohub/member'
|
11
|
+
require 'trellohub/form'
|
12
|
+
require 'trellohub/configurable'
|
13
|
+
require 'trellohub/mocking'
|
11
14
|
require 'trellohub/synchronal'
|
12
15
|
|
16
|
+
require 'trellohub/core_ext/string'
|
17
|
+
require 'trellohub/core_ext/array'
|
18
|
+
require 'trellohub/core_ext/hash'
|
19
|
+
|
13
20
|
module Trellohub
|
14
21
|
class << self
|
15
22
|
include Trellohub::Configurable
|
data/lib/trellohub/card.rb
CHANGED
@@ -1,90 +1,19 @@
|
|
1
1
|
require 'trellohub/board'
|
2
|
-
require 'trellohub/cards'
|
3
2
|
|
4
3
|
module Trellohub
|
5
|
-
|
4
|
+
module Card
|
6
5
|
class << self
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
attr_accessor(*self.all_attributes)
|
11
|
-
alias_method :repo, :repository
|
12
|
-
|
13
|
-
def repository_name
|
14
|
-
repo.split('/').last
|
15
|
-
end
|
16
|
-
|
17
|
-
def import(card)
|
18
|
-
card.attrs.keys.each do |attr|
|
19
|
-
instance_variable_set(:"@#{attr}", card.send(attr))
|
6
|
+
def all
|
7
|
+
@all || self.all!
|
20
8
|
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def import_from_issue(repository, issue)
|
24
|
-
@idBoard = Trellohub::Board.id
|
25
|
-
@repository = repository
|
26
|
-
@issue = issue.dup
|
27
|
-
|
28
|
-
build_key
|
29
|
-
build_name
|
30
|
-
build_desc
|
31
|
-
build_milestone
|
32
9
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def build_key
|
38
|
-
@key = "#{repository_name}##{@issue.number}"
|
39
|
-
end
|
40
|
-
|
41
|
-
def build_name
|
42
|
-
@name = "#{repository_name}##{@issue.number} #{@issue.title}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def build_desc
|
46
|
-
@desc = "#{Octokit.web_endpoint}#{repo}/issues/#{@issue.number}"
|
47
|
-
end
|
48
|
-
|
49
|
-
def build_milestone
|
50
|
-
return unless @issue.milestone
|
51
|
-
@milestone = @issue.milestone.title
|
52
|
-
end
|
53
|
-
|
54
|
-
def assign_members
|
55
|
-
return unless @issue.assignee
|
56
|
-
|
57
|
-
member = Trellohub::Member.find_by_github_user(@issue.assignee.login)
|
58
|
-
unless member.nil?
|
59
|
-
@idMembers = [member.id]
|
60
|
-
@members = [member.username]
|
10
|
+
def all!
|
11
|
+
@all = Trell.cards(Trellohub::Board.id, filter: 'all')
|
61
12
|
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def assign_list
|
65
|
-
labels = @issue.labels.map(&:name).uniq
|
66
|
-
list = Trellohub.list_by(labels: labels)
|
67
|
-
return unless list
|
68
|
-
@idList = list.id
|
69
|
-
@list_name = list.name
|
70
|
-
end
|
71
13
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
def save_to_github
|
76
|
-
end
|
77
|
-
|
78
|
-
def export
|
79
|
-
Hash[self.class.valid_attributes.map { |key|
|
80
|
-
[key, instance_variable_get(:"@#{key}")]
|
81
|
-
}]
|
82
|
-
end
|
83
|
-
|
84
|
-
def to_hash
|
85
|
-
Hash[self.class.all_attributes.map { |key|
|
86
|
-
[key, instance_variable_get(:"@#{key}")]
|
87
|
-
}]
|
14
|
+
def all_clear
|
15
|
+
self.all.each { |card| Trell.delete_card(card.id) }
|
16
|
+
end
|
88
17
|
end
|
89
18
|
end
|
90
19
|
end
|
@@ -1,39 +1,52 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'trellohub/core_ext/hash'
|
3
|
-
|
4
1
|
module Trellohub
|
5
2
|
module Configurable
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
3
|
+
class << self
|
4
|
+
def keys
|
5
|
+
%i(
|
6
|
+
config_file
|
7
|
+
board_id
|
8
|
+
repositories
|
9
|
+
lists
|
10
|
+
options
|
11
|
+
trello_application_key
|
12
|
+
trello_application_token
|
13
|
+
github_access_token
|
14
|
+
github_api_endpoint
|
15
|
+
github_web_endpoint
|
16
|
+
dry_run
|
17
|
+
debug
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def overrideable_keys
|
22
|
+
%i(
|
23
|
+
board_id
|
24
|
+
trello_application_key
|
25
|
+
trello_application_token
|
26
|
+
github_access_token
|
27
|
+
github_api_endpoint
|
28
|
+
github_web_endpoint
|
29
|
+
dry_run
|
30
|
+
debug
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_accessor(*self.keys)
|
21
36
|
|
22
37
|
def configure
|
23
38
|
yield self
|
24
39
|
end
|
25
40
|
|
26
|
-
def
|
41
|
+
def default!
|
27
42
|
@config_file = ENV['CONFIG_FILE']
|
28
|
-
@board_id = ENV['BOARD_ID']
|
29
43
|
@repositories = []
|
30
|
-
@milestones = []
|
31
44
|
@lists = []
|
32
|
-
@
|
33
|
-
@trello_application_token = ENV['TRELLO_APPLICATION_TOKEN']
|
34
|
-
@github_access_token = ENV['GITHUB_ACCESS_TOKEN']
|
45
|
+
@options = { default_assignee: true, default_member: true }
|
35
46
|
@github_api_endpoint = Octokit.api_endpoint
|
36
47
|
@github_web_endpoint = Octokit.web_endpoint
|
48
|
+
@dry_run = false
|
49
|
+
@debug = true
|
37
50
|
end
|
38
51
|
|
39
52
|
def load!(config_file = nil)
|
@@ -43,34 +56,44 @@ module Trellohub
|
|
43
56
|
symbolize_keys.
|
44
57
|
slice(*Trellohub::Configurable.keys).
|
45
58
|
each do |key, value|
|
46
|
-
|
47
|
-
|
59
|
+
case key
|
60
|
+
when :repositories
|
61
|
+
value = value.map { |v| Trellohub::Repository.new(v) }
|
62
|
+
when :lists
|
63
|
+
value = value.map { |v| Trellohub::List.new(v) }
|
48
64
|
end
|
49
65
|
instance_variable_set(:"@#{key}", value)
|
50
66
|
end
|
51
67
|
end
|
52
68
|
|
53
|
-
def
|
69
|
+
def override!
|
70
|
+
Trellohub::Configurable.overrideable_keys.each do |key|
|
71
|
+
env_name = key.to_s.upcase
|
72
|
+
instance_variable_set(:"@#{key}", ENV[env_name]) if ENV[env_name]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def init!
|
54
77
|
Trell.configure do |c|
|
55
78
|
c.application_key = @trello_application_key
|
56
79
|
c.application_token = @trello_application_token
|
57
80
|
end
|
58
|
-
end
|
59
81
|
|
60
|
-
def init_octokit
|
61
82
|
Octokit.configure do |c|
|
62
83
|
c.access_token = @github_access_token
|
63
84
|
c.api_endpoint = @github_api_endpoint
|
64
85
|
c.web_endpoint = @github_web_endpoint
|
65
86
|
c.auto_paginate = true
|
66
87
|
end
|
88
|
+
|
89
|
+
self.dry_run = true if @dry_run
|
67
90
|
end
|
68
91
|
|
69
92
|
def setup(config_file = nil)
|
70
|
-
|
93
|
+
default!
|
71
94
|
load!(config_file)
|
72
|
-
|
73
|
-
|
95
|
+
override!
|
96
|
+
init!
|
74
97
|
self
|
75
98
|
end
|
76
99
|
|
@@ -111,6 +134,23 @@ module Trellohub
|
|
111
134
|
@lists.map(&:issue_label).compact
|
112
135
|
end
|
113
136
|
|
137
|
+
def repository_by(full_name: nil, milestone: nil)
|
138
|
+
case
|
139
|
+
when full_name
|
140
|
+
@repositories.find { |repo| repo.full_name == full_name }
|
141
|
+
when milestone
|
142
|
+
@repositories.find { |repo| repo.milestone == milestone }
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def repository_full_names
|
147
|
+
@repositories.map(&:full_names).compact
|
148
|
+
end
|
149
|
+
|
150
|
+
def repository_milestones
|
151
|
+
@repositories.map(&:milestone).uniq
|
152
|
+
end
|
153
|
+
|
114
154
|
def github_api_endpoint
|
115
155
|
File.join(@github_api_endpoint, '')
|
116
156
|
end
|
@@ -119,10 +159,9 @@ module Trellohub
|
|
119
159
|
File.join(@github_web_endpoint, '')
|
120
160
|
end
|
121
161
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
end
|
162
|
+
def dry_run=(bool)
|
163
|
+
@dry_run = bool
|
164
|
+
Mocking.send(@dry_run ? :start : :stop)
|
126
165
|
end
|
127
166
|
end
|
128
167
|
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
class Hash
|
2
2
|
def slice(*keys)
|
3
|
-
keys.each_with_object(self.class.new) { |k, hash|
|
3
|
+
keys.each_with_object(self.class.new) { |k, hash|
|
4
|
+
hash[k] = self[k] if has_key?(k)
|
5
|
+
}
|
6
|
+
end
|
7
|
+
|
8
|
+
def extract(*keys)
|
9
|
+
self.each_with_object(self.class.new) { |(k, v), hash|
|
10
|
+
hash[k] = v unless keys.include?(k)
|
11
|
+
}
|
4
12
|
end
|
5
13
|
|
6
14
|
def symbolize_keys
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rainbow/ext/string'
|
2
|
+
|
3
|
+
class String
|
4
|
+
def width
|
5
|
+
self.no_coloring.each_char.map { |one_letter|
|
6
|
+
one_letter.ascii_only? ? 1 : 2
|
7
|
+
}.inject(:+) || 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def no_coloring
|
11
|
+
self.gsub(/\e\[\d?\d?;?\d\d?m/, '').gsub(/\e\[0m/, '')
|
12
|
+
end
|
13
|
+
|
14
|
+
def constantize
|
15
|
+
Object.const_get(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
def ljust_with_multibyte(length, padstr = ' ')
|
19
|
+
length > self.width ? "#{self}#{padstr * (length - self.width)}" : self
|
20
|
+
end
|
21
|
+
alias_method :ljust, :ljust_with_multibyte
|
22
|
+
end
|