prpr-trello 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10941a34eb95fb3bff554519e40cb93e30b8f2f0
4
+ data.tar.gz: f87dd0ff9695e38c54786ceb38ac08950ad5483c
5
+ SHA512:
6
+ metadata.gz: 30f6ada54268314690c3a24eadd11fc5ec0a1d6542ed3d6c6ca6e3e3b0b393bd99c763c49772e3fef69672ba4dbb00171855841568c4d2933c8e92deb448659f
7
+ data.tar.gz: dc56e813ec9436c078ba6bd569274c9d5bc129cc4f6522722b2dd0230dd11582bbfbb4708589649b11a0b4513640bff9d74416461d6796ee387110a711c0c248
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in prpr-trello.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 mzp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,76 @@
1
+ # Prpr::Trello
2
+
3
+ [Prpr](https://github.com/mzp/prpr) plugin to move trello card when pull request status is changed.
4
+
5
+ ## Install
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ # Gemfile
11
+ gem 'prpr-trello'
12
+ ```
13
+
14
+ ## Usage
15
+ This plugin move trello card like following:
16
+
17
+ * When pull request is labeled as WIP, move card to WIP list.
18
+ * When pull request is labeled as REVIEW, move card to REVIEW list and append github link to description.
19
+ * When pull requset is merged, move card to DONE list.
20
+
21
+ ## Env
22
+
23
+ Trello token:
24
+
25
+ * TRELLO_DEVELOPER_PUBLIC_KEY: Trello Developer API key. You can obtain from https://trello.com/1/appKey/generate
26
+ * TRELLO_MEMBER_TOKEN: Trello member token. You can obtain from https://trello.com/1/connect?key=<your developer public key>&name=prpr&response_type=token&scope=read,write
27
+
28
+ Github config:
29
+
30
+ * TRELLO_WIP_LABEL: Github's WIP label. (Default: `WIP`)
31
+ * TRELLO_REVIEW_LABEL: Github's review label. (Default: `REVIEW`)
32
+
33
+ Trello config:
34
+
35
+ * TRELLO_WIP_LIST: Trello's WIP list id.
36
+ * TRELLO_REVIEW_LIST: Trello's review list id.
37
+ * TRELLO_DONE_LIST: Trello's done list id.
38
+
39
+ ### Tips: how to obtain trello list id
40
+ If your board URL is `https://trello.com/b/deadbeaf/todo`, open `https://trello.com/1/boards/deadbeaf` and obtain following response.
41
+
42
+ ```json
43
+ [{
44
+ "id": "4eea4ffc91e31d174600004a",
45
+ "name": "To Do Soon",
46
+ "cards": [{
47
+ "id": "4eea503791e31d1746000080",
48
+ "name": "Finish my awesome application"
49
+ }]
50
+ }, {
51
+ "id": "4eea4ffc91e31d174600004b",
52
+ "name": "Doing",
53
+ "cards": [{
54
+ "id": "4eea503d91e31d174600008f",
55
+ "name": "Learn about the Trello API"
56
+ }, {
57
+ "id": "4eea522c91e31d174600027e",
58
+ "name": "Figure out how to read a user's board list"
59
+ }]
60
+ }, {
61
+ "id": "4eea4ffc91e31d174600004c",
62
+ "name": "Done",
63
+ "cards": [{
64
+ "id": "4eea501f91e31d1746000062",
65
+ "name": "Get a key to use in my API requests"
66
+ }, {
67
+ "id": "4eea502b91e31d1746000071",
68
+ "name": "Find out where the Trello API documentation is"
69
+ }]
70
+ }]
71
+ ```
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
76
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "prpr/trello"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,45 @@
1
+ require 'trello'
2
+
3
+ module Prpr
4
+ module Action
5
+ module Trello
6
+ class Base < Prpr::Action::Base
7
+ private
8
+
9
+ def client
10
+ @client ||= ::Trello::Client.new(
11
+ developer_public_key: env[:trello_developer_public_key],
12
+ member_token: env[:trello_member_token])
13
+ end
14
+
15
+ def card
16
+ @card ||=
17
+ if card_id
18
+ client.find(:cards, card_id)
19
+ end
20
+ end
21
+
22
+ def card_desc
23
+ @card_desc ||= card.desc.to_s
24
+ end
25
+
26
+ def card_id
27
+ @card_id ||=
28
+ if head.chomp =~ %r!trello.com/c/([^/]+)!
29
+ $1
30
+ end
31
+ end
32
+
33
+ def head
34
+ event.pull_request.body.lines.first.chomp
35
+ end
36
+
37
+ def github_url
38
+ event.pull_request.html_url
39
+ end
40
+
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,21 @@
1
+ module Prpr
2
+ module Action
3
+ module Trello
4
+ class Close < Base
5
+ def call
6
+ return unless card
7
+
8
+ card.move_to_list done_list
9
+ card.pos = 0
10
+ card.save
11
+ end
12
+
13
+ private
14
+
15
+ def done_list
16
+ env[:trello_done_list]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,57 @@
1
+ module Prpr
2
+ module Action
3
+ module Trello
4
+ class Labeled < Base
5
+ def call
6
+ return unless card
7
+
8
+ case
9
+ when wip?
10
+ card.move_to_list wip_list
11
+
12
+ when review_label?
13
+ unless card_desc.include?(github_url)
14
+ card.desc = github_url + "\n"+ card_desc
15
+ card.update!
16
+ end
17
+ card.move_to_list review_list
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def github_url
24
+ event.pull_request.html_url
25
+ end
26
+
27
+ def label
28
+ event.label.name
29
+ end
30
+
31
+ def review_label?
32
+ label == review_label
33
+ end
34
+
35
+ def wip?
36
+ label == wip_label
37
+ end
38
+
39
+ def review_label
40
+ env[:trello_review_label] || 'REVIEW'
41
+ end
42
+
43
+ def wip_label
44
+ env[:trello_wip_label] || 'WIP'
45
+ end
46
+
47
+ def review_list
48
+ env[:trello_review_list]
49
+ end
50
+
51
+ def wip_list
52
+ env[:trello_wip_list]
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,13 @@
1
+ module Prpr
2
+ module Handler
3
+ class Trello < Base
4
+ handle Event::PullRequest, action: 'labeled' do
5
+ Prpr::Action::Trello::Labeled.new(event).call
6
+ end
7
+
8
+ handle Event::PullRequest, action: /closed/ do
9
+ Prpr::Action::Trello::Close.new(event).call
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ require "prpr/trello/version"
2
+ require "prpr/action/trello/base"
3
+ require "prpr/action/trello/labeled"
4
+ require "prpr/action/trello/close"
5
+ require "prpr/handler/trello"
@@ -0,0 +1,5 @@
1
+ module Prpr
2
+ module Trello
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prpr/trello/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "prpr-trello"
8
+ spec.version = Prpr::Trello::VERSION
9
+ spec.authors = ["mzp"]
10
+ spec.email = ["mzpppp@gmail.com"]
11
+
12
+ spec.summary = "Prpr plugin to connect github to trell"
13
+ spec.description = "When PR status changed, move trello card"
14
+ spec.homepage = "https://github.com/mzp/prpr"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "prpr"
23
+ spec.add_dependency "ruby-trello"
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prpr-trello
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mzp
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: prpr
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-trello
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: When PR status changed, move trello card
70
+ email:
71
+ - mzpppp@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - lib/prpr/action/trello/base.rb
84
+ - lib/prpr/action/trello/close.rb
85
+ - lib/prpr/action/trello/labeled.rb
86
+ - lib/prpr/handler/trello.rb
87
+ - lib/prpr/trello.rb
88
+ - lib/prpr/trello/version.rb
89
+ - prpr-trello.gemspec
90
+ homepage: https://github.com/mzp/prpr
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.5.1
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Prpr plugin to connect github to trell
114
+ test_files: []