github_to_trello 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/github_to_trello.gemspec +23 -0
- data/lib/github_to_trello/github_gateway.rb +11 -0
- data/lib/github_to_trello/trello_gateway.rb +61 -0
- data/lib/github_to_trello/version.rb +3 -0
- data/lib/github_to_trello.rb +36 -0
- data/spec/github_gateway_spec.rb +14 -0
- data/spec/trello_gateway_spec.rb +53 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 680f9c64a0e18754aefe2c430104341cefb6f09c
|
4
|
+
data.tar.gz: 75a8ff3fe437125dda094c061d45fa416ebd3ede
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 263b6997ab83caaacb0f0730e22818c498fc7053e2d5b596e5251edf0ee085516fef8c0c4a9cd1da298fa1961304d7904fb7daaa2973067ed39a3a2f7be5e48b
|
7
|
+
data.tar.gz: 00b1aad91a0d1f5c25b9faae2c35d7071282df4a31c104f7f342bb8c63d357b71270016bcd715230389c94bf4ba3f1c0c9b54d77bcc7693b6643692562448518
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 chrissie
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# USAGE
|
2
|
+
|
3
|
+
After completing the [setup](#setup), run `ruby github_to_trello.rb`
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
Use the github API to grab all open issues for specified repo.
|
7
|
+
Creates a list with the repo name of the specified trello board.
|
8
|
+
For each issue, create/update a trello card on that list.
|
9
|
+
|
10
|
+
Running the script:
|
11
|
+
- Creates a list for each specified repo (if a list for that repo is not already present)
|
12
|
+
- Adds or updates cards for all open issues or PRs in that repo
|
13
|
+
- Adds or updates color labels to cards based on date last updated
|
14
|
+
|
15
|
+
## Setup
|
16
|
+
Running this script requires:
|
17
|
+
|
18
|
+
1. A trello account with access to the board you are populating with github issues.
|
19
|
+
|
20
|
+
2. A .env file with with the following variables
|
21
|
+
defined:
|
22
|
+
- `BOARD_ID` - The ID of the trello board to add the cards to
|
23
|
+
- `REPOS` - The name(s) of the github repos to pull issues from
|
24
|
+
(comma separated: `REPOS=your_name/your_repo,your_name/your_other_repo`)
|
25
|
+
- `PUBLIC_KEY` - Log into trello and visit https://trello.com/app-key
|
26
|
+
- `TOKEN` - Go to
|
27
|
+
https://trello.com/1/connect?key=...&name=MyApp&response_type=token&scope=read,write
|
28
|
+
(substituting the public key for ... a unique name for MyApp)
|
29
|
+
|
30
|
+
Sites used for reference
|
31
|
+
http://www.sitepoint.com/customizing-trello-ruby/
|
32
|
+
https://github.com/jeremytregunna/ruby-trello/blob/master/lib/trello/card.rb
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'github_to_trello/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "github_to_trello"
|
8
|
+
spec.version = GithubToTrello::VERSION
|
9
|
+
spec.authors = ["chrissie"]
|
10
|
+
spec.email = ["chrissie.deist@gmail.com"]
|
11
|
+
spec.description = %q{A gem for converting github issues into trello cards}
|
12
|
+
spec.summary = %q{Pulls github issues from specified repos and automatically creates/populates trello lists with the repo names on a specified board.}
|
13
|
+
spec.homepage = "http://rubygems.org/gems/github_to_trello"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "trello"
|
2
|
+
|
3
|
+
SECONDS_PER_DAY = 60 * 60 * 24
|
4
|
+
DAYS_TIL_OLD = 14
|
5
|
+
DAYS_TIL_REALLY_OLD = 28
|
6
|
+
|
7
|
+
class TrelloGateway
|
8
|
+
def initialize(public_key, token, board_id, repo)
|
9
|
+
Trello.configure do |c|
|
10
|
+
c.developer_public_key = public_key
|
11
|
+
c.member_token = token
|
12
|
+
end
|
13
|
+
|
14
|
+
@board = _board(board_id)
|
15
|
+
@repo = repo
|
16
|
+
@list = _list
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_or_update_card(issue)
|
20
|
+
existing_card = _existing_card?(issue)
|
21
|
+
card = existing_card.class == (Trello::Card) ? existing_card : _create_card(issue)
|
22
|
+
_update(issue, card)
|
23
|
+
end
|
24
|
+
|
25
|
+
def _update(issue, card)
|
26
|
+
if issue.updated_at < (Time.now - DAYS_TIL_REALLY_OLD * SECONDS_PER_DAY)
|
27
|
+
card.card_labels = [:red]
|
28
|
+
elsif issue.updated_at < (Time.now - DAYS_TIL_OLD * SECONDS_PER_DAY)
|
29
|
+
card.card_labels = [:yellow]
|
30
|
+
else
|
31
|
+
card.card_labels = []
|
32
|
+
end
|
33
|
+
card.save
|
34
|
+
card
|
35
|
+
end
|
36
|
+
|
37
|
+
def _existing_card?(issue)
|
38
|
+
@list.cards.detect do |card|
|
39
|
+
card.name == issue.title
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def _create_card(issue)
|
44
|
+
Trello::Card.create(
|
45
|
+
:name => issue.title,
|
46
|
+
:list_id => @list.id,
|
47
|
+
:desc => issue.body + "\n" + issue.html_url + "\n" + issue.updated_at.to_s
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def _board(id)
|
52
|
+
Trello::Board.find(id)
|
53
|
+
end
|
54
|
+
|
55
|
+
def _list
|
56
|
+
list = @board.lists.detect do |list|
|
57
|
+
list.name =~ /#{@repo}/
|
58
|
+
end
|
59
|
+
list = list || Trello::List.create(:name => @repo, :board_id => @board.id)
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative './github_to_trello/github_gateway'
|
2
|
+
require_relative './github_to_trello/trello_gateway'
|
3
|
+
require 'octokit'
|
4
|
+
require 'trello'
|
5
|
+
require 'dotenv'
|
6
|
+
|
7
|
+
Dotenv.load
|
8
|
+
|
9
|
+
class GithubToTrello
|
10
|
+
def initialize(public_key, token, board_id, repo_name)
|
11
|
+
@github_gateway = GithubGateway.new(repo_name)
|
12
|
+
@trello_gateway = TrelloGateway.new(public_key,
|
13
|
+
token,
|
14
|
+
board_id,
|
15
|
+
repo_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def update
|
19
|
+
@github_gateway.issues.each do |issue|
|
20
|
+
@trello_gateway.create_or_update_card(issue)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if __FILE__ == $PROGRAM_NAME
|
26
|
+
public_key = ENV["PUBLIC_KEY"]
|
27
|
+
token = ENV["TOKEN"]
|
28
|
+
board_id = ENV["BOARD_ID"]
|
29
|
+
repos = ENV["REPOS"].split(",")
|
30
|
+
|
31
|
+
repos.each do |repo|
|
32
|
+
puts "Updating repo: #{repo}"
|
33
|
+
GithubToTrello.new(public_key, token, board_id, repo).update
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'github_gateway'
|
3
|
+
|
4
|
+
describe GithubGateway do
|
5
|
+
before(:all) do
|
6
|
+
@gateway = GithubGateway.new("chrissiedeist/django_blog")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can access the title and body of the issue" do
|
10
|
+
issue = @gateway.issues.first
|
11
|
+
expect(issue.title).to eq("Test")
|
12
|
+
expect(issue.body).to eq("This is a test.")
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'rspec'
|
3
|
+
require 'trello_gateway'
|
4
|
+
|
5
|
+
describe TrelloGateway do
|
6
|
+
before(:each) do
|
7
|
+
public_key = "56acdaa7404ebcc8bbaffab18428d4d2"
|
8
|
+
token = "748c2116942c251bf6ed8000c13196293443ddcb407422ccacd92d0001b831da"
|
9
|
+
board_id = "5jGWvKui"
|
10
|
+
repo = "django_blog"
|
11
|
+
|
12
|
+
@gateway = TrelloGateway.new(public_key, token, board_id, repo)
|
13
|
+
@issue = double(:issue,
|
14
|
+
:title => "Test",
|
15
|
+
:id => "91374795",
|
16
|
+
:updated_at => "2015-06-26T22:08:36Z",
|
17
|
+
:body => "This is a test",
|
18
|
+
:html_url => "https://github.com/chrissiedeist/django_blog/issues/1",
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "create_or_update_card" do
|
23
|
+
it "creates a new card on the appropriate list if it does not exist" do
|
24
|
+
card = @gateway.create_or_update_card(@issue)
|
25
|
+
expect(card.class).to be(Trello::Card)
|
26
|
+
expect(card.name).to eq("Test")
|
27
|
+
expect(card.list.name).to eq("chrissiedeist/django_blog")
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it "does not add a duplicate card if card exits" do
|
32
|
+
card = @gateway.create_or_update_card(@issue)
|
33
|
+
card = @gateway.create_or_update_card(@issue)
|
34
|
+
|
35
|
+
expect(card.list.cards.length).to eq(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "adds a red label if card is more than 28 days old" do
|
39
|
+
card = @gateway.create_or_update_card(@issue)
|
40
|
+
expect(card.card_labels).to eq([])
|
41
|
+
|
42
|
+
updated_issue = double(:issue,
|
43
|
+
:title => "Test",
|
44
|
+
:id => "91374795",
|
45
|
+
:updated_at => "2015-01-27T22:08:36Z",
|
46
|
+
:body => "This is a test",
|
47
|
+
:html_url => "https://github.com/chrissiedeist/django_blog/issues/1",
|
48
|
+
)
|
49
|
+
card = @gateway.create_or_update_card(updated_issue)
|
50
|
+
expect(card.card_labels).to eq([:red])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_to_trello
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chrissie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A gem for converting github issues into trello cards
|
42
|
+
email:
|
43
|
+
- chrissie.deist@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- github_to_trello.gemspec
|
54
|
+
- lib/github_to_trello.rb
|
55
|
+
- lib/github_to_trello/github_gateway.rb
|
56
|
+
- lib/github_to_trello/trello_gateway.rb
|
57
|
+
- lib/github_to_trello/version.rb
|
58
|
+
- spec/github_gateway_spec.rb
|
59
|
+
- spec/trello_gateway_spec.rb
|
60
|
+
homepage: http://rubygems.org/gems/github_to_trello
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.1.11
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Pulls github issues from specified repos and automatically creates/populates
|
84
|
+
trello lists with the repo names on a specified board.
|
85
|
+
test_files:
|
86
|
+
- spec/github_gateway_spec.rb
|
87
|
+
- spec/trello_gateway_spec.rb
|
88
|
+
has_rdoc:
|