trellish 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create ruby-1.9.3-p194-falcon@trellish
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trellish.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Wes Gibbs
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,53 @@
1
+ # Trellish
2
+
3
+ Trellish is used to finish a Trello card. It does everything necessary to move a development card from the In Progress list to the QA list.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'trellish'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install trellish
18
+
19
+ ## Usage
20
+
21
+ Create a trellish.yml file in your current directory or home directory. Set it up like this:
22
+
23
+ # Sign in to Trello and go here https://trello.com/1/appKey/generate.
24
+ # Copy "Key" from that page to tello_api_key.
25
+ trello_api_key: numbers_and_letters_and_stuff
26
+ # Copy "Secret (for OAuth signing)" from that page to tello_oauth_secret.
27
+ trello_oauth_secret: numbers_and_letters_and_stuff
28
+ # Visit http://trello.com/1/connect?key=TRELLO_API_KEY_FROM_ABOVE&name=Trellish&response_type=token&scope=read,write&expiration=never and copy the token to trello_oauth_token.
29
+ trello_oauth_token: numbers_and_letters_and_stuff
30
+
31
+ git checkout the topic branch for the card you are finishing. Then do this:
32
+
33
+ trellish https://trello.com/c/a3Wbcde4
34
+
35
+ or alternately:
36
+
37
+ trellish a3Wbcde4
38
+
39
+ This will:
40
+
41
+ - add a link to the branch on github as a comment on the card
42
+ - add a checklist named "Checklist" if one doesn't exist
43
+ - add an item to that checklist called "Merge to master"
44
+ - remove you from the card
45
+ - move the card to the QA list
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/trellish ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'trellish'
4
+ require 'trellish/card'
5
+ require 'yaml'
6
+
7
+ if ARGV[0].nil?
8
+ Trellish.logger.error "Please provide a Trello card id or URL."
9
+ exit
10
+ end
11
+
12
+ config_file = if File.exists?('trellish.yml')
13
+ YAML.load(File.read('trellish.yml'))
14
+ elsif File.exists?(File.expand_path('~/trellish.yml'))
15
+ YAML.load(File.read(File.expand_path('~/trellish.yml')))
16
+ end
17
+
18
+ unless config_file
19
+ Trellish.logger.error "Could not locate trellish.yml file in current directory or home directory."
20
+ exit
21
+ end
22
+
23
+ Trellish.configure(
24
+ trello_api_key: config_file['trello_api_key'],
25
+ trello_oauth_secret: config_file['trello_oauth_secret'],
26
+ trello_oauth_token: config_file['trello_oauth_token'])
27
+
28
+ card = Trellish::Card.new(ARGV[0])
29
+ card.finish
data/lib/trellish.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'logger'
2
+ require 'trellish/auth'
3
+ require 'trellish/card'
4
+ require 'trellish/git'
5
+ require 'trellish/version'
6
+ require 'trello'
7
+
8
+ module Trellish
9
+
10
+ @config = {
11
+ trello_api_key: 'TRELLO_API_KEY',
12
+ trello_oauth_secret: 'TRELLO_OAUTH_SECRET',
13
+ trello_oauth_token: 'TRELLO_OAUTH_TOKEN'
14
+ }
15
+
16
+ @valid_config_keys = @config.keys
17
+
18
+ def self.configure(params = {})
19
+ params.each { |k, v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym }
20
+ end
21
+
22
+ def self.config
23
+ @config
24
+ end
25
+
26
+ def self.logger
27
+ @logger ||= Logger.new(STDOUT)
28
+ end
29
+
30
+ def self.logger=(logger)
31
+ @logger = logger
32
+ end
33
+
34
+ end
@@ -0,0 +1,28 @@
1
+ require 'trello'
2
+
3
+ module Trellish
4
+
5
+ class Auth
6
+ include Trello
7
+ include Trello::Authorization
8
+
9
+ Trello::Authorization.const_set :AuthPolicy, OAuthPolicy
10
+
11
+ def self.authorize
12
+ OAuthPolicy.consumer_credential = OAuthCredential.new(
13
+ Trellish.config[:trello_api_key],
14
+ Trellish.config[:trello_oauth_secret])
15
+ OAuthPolicy.token = OAuthCredential.new(Trellish.config[:trello_oauth_token], nil)
16
+
17
+ # Test that the user is authorized
18
+ begin
19
+ member_id = Trello::Token.find(OAuthPolicy.token.key).member_id
20
+ Member.find(member_id)
21
+ rescue
22
+ Trellish.logger.error "Unable to authorize access to Trello API."
23
+ exit
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,56 @@
1
+ require 'trellish/git'
2
+
3
+ module Trellish
4
+ class Card
5
+ include Trello
6
+ include Trellish::Git
7
+
8
+ def initialize(card_id_or_url)
9
+ @member = Trellish::Auth.authorize
10
+ @card = Trello::Card.find(parse_card_id(card_id_or_url))
11
+ end
12
+
13
+ def add_branch_link
14
+ @card.add_comment(github_branch_url)
15
+ end
16
+
17
+ def add_merge_to_master_item
18
+ checklist = @card.checklists.first
19
+ if checklist.nil?
20
+ new_checklist = Checklist.create(name: 'Checklist', board_id: @card.board_id)
21
+ @card.add_checklist(new_checklist)
22
+ checklist = @card.refresh!.checklists.first
23
+ end
24
+ checklist.add_item('Merge to master')
25
+ end
26
+
27
+ def finish
28
+ add_branch_link
29
+ add_merge_to_master_item
30
+ remove_me
31
+ move_to_qa
32
+ end
33
+
34
+ def move_to_qa
35
+ qa_list = @card.board.lists.find { |list| list.name == 'QA' }
36
+ if qa_list
37
+ @card.move_to_list(qa_list)
38
+ else
39
+ Trellish.logger.warn "Unable to move card to 'QA' list. No list named 'QA' found."
40
+ end
41
+ end
42
+
43
+ def remove_me
44
+ if @card.members.include? @member
45
+ @card.remove_member(@member) rescue nil
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def parse_card_id(card_id_or_url)
52
+ card_id_or_url.match(/[A-Za-z0-9]*$/)[0]
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,29 @@
1
+ module Trellish
2
+ module Git
3
+
4
+ def current_git_branch
5
+ @current_git_branch ||= `cat .git/head`.split('/').last
6
+ end
7
+
8
+ def github_branch_url
9
+ @github_branch_url ||= "https://github.com/#{git_repository_owner}/#{git_repository_name}/tree/#{current_git_branch}"
10
+ end
11
+
12
+ def remote_url
13
+ @remote_url ||= `git config remote.origin.url`
14
+ end
15
+
16
+ def matches
17
+ @matches ||= matches = remote_url.match(%r|^git@github.com:([^/]*)\/([^\.]*)\.git$|)
18
+ end
19
+
20
+ def git_repository_owner
21
+ @git_repository_owner ||= matches[1]
22
+ end
23
+
24
+ def git_repository_name
25
+ @git_repository_name ||= matches[2]
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Trellish
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,7 @@
1
+ # Sign in to Trello and go here https://trello.com/1/appKey/generate.
2
+ # Copy "Key" from that page to tello_api_key.
3
+ trello_api_key: numbers_and_letters_and_stuff
4
+ # Copy "Secret (for OAuth signing)" from that page to tello_oauth_secret.
5
+ trello_oauth_secret: numbers_and_letters_and_stuff
6
+ # Visit http://trello.com/1/connect?key=TRELLO_API_KEY_FROM_ABOVE&name=Trellish&response_type=token&scope=read,write&expiration=never and copy the token to trello_oauth_token.
7
+ trello_oauth_token: numbers_and_letters_and_stuff
data/trellish.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/trellish/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Wes Gibbs"]
6
+ gem.email = ["wesgibbs@gmail.com"]
7
+ gem.description = %q{Annotate Trello cards with git branch, add 'Merge to master' checkbox, remove yourself and move the card to the QA list}
8
+ gem.summary = %q{Finish a Trello card}
9
+ gem.homepage = "http://rubygems.org/gems/trellish"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "trellish"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Trellish::VERSION
17
+
18
+ gem.add_dependency 'ruby-trello-wgibbs'
19
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trellish
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Wes Gibbs
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ruby-trello-wgibbs
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Annotate Trello cards with git branch, add 'Merge to master' checkbox,
31
+ remove yourself and move the card to the QA list
32
+ email:
33
+ - wesgibbs@gmail.com
34
+ executables:
35
+ - trellish
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gitignore
40
+ - .rvmrc
41
+ - Gemfile
42
+ - LICENSE
43
+ - README.md
44
+ - Rakefile
45
+ - bin/trellish
46
+ - lib/trellish.rb
47
+ - lib/trellish/auth.rb
48
+ - lib/trellish/card.rb
49
+ - lib/trellish/git.rb
50
+ - lib/trellish/version.rb
51
+ - trellish.example.yml
52
+ - trellish.gemspec
53
+ homepage: http://rubygems.org/gems/trellish
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.24
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Finish a Trello card
77
+ test_files: []