trello_branch 0.0.0

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.
Files changed (3) hide show
  1. data/bin/tb +18 -0
  2. data/lib/trello_branch.rb +38 -0
  3. metadata +82 -0
data/bin/tb ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'trello_branch'
4
+ require 'configuration'
5
+
6
+ Configuration.path = '~'
7
+ config = Configuration.for 'tb'
8
+
9
+ Trello::Authorization::BasicAuthPolicy.developer_public_key = config.developer_public_key
10
+ Trello::Authorization::BasicAuthPolicy.member_token = config.member_token
11
+
12
+ module Trello::Authorization
13
+ remove_const :AuthPolicy
14
+ AuthPolicy = BasicAuthPolicy
15
+ end
16
+
17
+ tb = TrelloBranch.new(config.board_id)
18
+ tb.checkout_card(ARGV[0].to_i)
@@ -0,0 +1,38 @@
1
+ require 'trello'
2
+ require 'git'
3
+
4
+ class TrelloBranch
5
+
6
+ attr_reader :board, :logger
7
+
8
+ def initialize(board_id)
9
+ @board = Trello::Board.find(board_id)
10
+ @logger = Logger.new(STDOUT)
11
+ end
12
+
13
+ def checkout_card(short_id)
14
+ logger.info "TrelloBranch: Looking up card ##{short_id}"
15
+ c = card(short_id)
16
+ branch_name = branch_name_for_card(c)
17
+
18
+ logger.info "TrelloBranch: Checking out branch: #{branch_name}"
19
+ checkout_branch(branch_name)
20
+ end
21
+
22
+ private
23
+
24
+ def card(short_id)
25
+ board.cards.detect{|c| c.short_id == short_id}
26
+ end
27
+
28
+ def branch_name_for_card(c)
29
+ short_desc = c.name.downcase.gsub(/\W+/, '-')[0..40]
30
+ "tr_#{c.id}_#{short_desc}"
31
+ end
32
+
33
+ def checkout_branch(branch_name)
34
+ g = Git.open('.', log: logger)
35
+ g.branch(branch_name).checkout
36
+ end
37
+
38
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trello_branch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Gillooly
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ruby-trello
16
+ requirement: &70355076261200 !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: *70355076261200
25
+ - !ruby/object:Gem::Dependency
26
+ name: git
27
+ requirement: &70355076260040 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70355076260040
36
+ - !ruby/object:Gem::Dependency
37
+ name: configuration
38
+ requirement: &70355076258900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70355076258900
47
+ description: Easily create branches from Trello cards
48
+ email: matt@mattgillooly.com
49
+ executables:
50
+ - tb
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/trello_branch.rb
55
+ - !binary |-
56
+ YmluL3Ri
57
+ homepage: http://github.com/mattgillooly/trello_branch
58
+ licenses: []
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.11
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: TrelloBranch!
81
+ test_files: []
82
+ has_rdoc: