github-trello 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,8 +21,23 @@ Go to https://trello.com/1/appKey/generate to get your key, then go to _https://
21
21
 
22
22
  You can get the board id from the URL, for example https://trello.com/board/trello-development/4d5ea62fd76aa1136000000c the board id is _4d5ea62fd76aa1136000000ca_.
23
23
 
24
- There are 3 actions you can configure to decide what happens to a card. Currently due to a bug in Trello's API, you cannot move a card to another list through the API, so only __archive__ will work. The code is already in, just waiting on Trello to fix the bug.
24
+ There are 3 actions you can configure to decide what happens to a card, __on_start__ for case/card, __on_close__ for close/fix. __on_deploy__ requires an additional hookin to your deployment that you can read below.
25
25
 
26
- To do
26
+ Deployment
27
27
  -
28
- Once Trello fixes the list API bug, I'll be implementing an on deploy action for people who want to be able to move cards from list A to B, such as moving from a "Pending Deployment" to "Live" or just archiving the cards.
28
+
29
+ If you are moving your cards to a new list (such as "Live") after deployment, then you must use the __move_to__ option in __on_close__. Unlike __on_start__ or __on_close__, you must also specify the repo name for __move_to__.
30
+
31
+ You indicate a deploy happened through sending a POST request to __http://foobar.com:4000/deployed/[repo name]__. An example of a Capistrano deployment script:
32
+
33
+ require "net/https"
34
+ Capistrano::Configuration.instance(:must_exist).load do
35
+ after "deploy:update" do
36
+ uri = URI("https://foobar.com:4000/deployed/foo-bar")
37
+
38
+ http = Net::HTTP.new(uri.host, uri.port)
39
+ http.use_ssl = uri.scheme == "https"
40
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
41
+ http.request_post(uri.path, "")
42
+ end
43
+ end
@@ -14,8 +14,24 @@ Vegas::Runner.new(GithubTrello::Server, "trello-web", {
14
14
  puts "[WARNING] No configuration found at #{path}."
15
15
  puts "We've generated an example one for you, but you need to configure it still."
16
16
 
17
+ config = <<YAML
18
+ oauth_token: [token]
19
+ api_key: [key]
20
+ on_start:
21
+ move_to: [list id]
22
+ archive: true
23
+ on_close:
24
+ move_to: [list id]
25
+ archive: true
26
+ # See README for deployment usage
27
+ on_deploy:
28
+ move_to:
29
+ [repo name]: [list id]
30
+ archive: true
31
+ YAML
32
+
17
33
  File.open(path, "w+") do |f|
18
- f.write("# NOTE: Due to a Trello API bug, currently only archive is supported and not move_to.\n\nboard_ids:\n [repo name]: [board id]\noauth_token: [token]\napi_key: [key]\non_start:\n move_to: [list id]\non_close:\n move_to: [list id]\n archive: false\non_deploy:\n move_to: [list id]\n archive: true")
34
+ f.write(config)
19
35
  end
20
36
 
21
37
  exit
@@ -20,6 +20,10 @@ module GithubTrello
20
20
  http_request(:post, "/1/cards/#{card_id}/actions/comments", :body => "text=#{CGI::escape(comment)}")
21
21
  end
22
22
 
23
+ def get_cards(list_id)
24
+ http_request(:get, "/1/lists/#{list_id}/cards", :params => {:fields => "idList"})
25
+ end
26
+
23
27
  private
24
28
  def http_request(method, request_path, args={})
25
29
  request_path << "?"
@@ -55,10 +55,9 @@ module GithubTrello
55
55
  # Modify it if needed
56
56
  to_update = {}
57
57
 
58
- # Disabled for now due to a Trello bug
59
- #unless results["idList"] == update_config["move_to"]
60
- # to_update[:idList] = update_config["move_to"]
61
- #end
58
+ unless results["idList"] == update_config["move_to"]
59
+ to_update[:idList] = update_config["move_to"]
60
+ end
62
61
 
63
62
  if !results["closed"] and update_config["archive"]
64
63
  to_update[:closed] = true
@@ -72,8 +71,35 @@ module GithubTrello
72
71
  ""
73
72
  end
74
73
 
74
+ post "/deployed/:repo" do
75
+ config, http = self.class.config, self.class.http
76
+ if !config["on_deploy"]
77
+ raise "Deploy triggered without a on_deploy config specified"
78
+ elsif !config["on_close"] or !config["on_close"]["move_to"]
79
+ raise "Deploy triggered and either on_close config missed or move_to is not set"
80
+ end
81
+
82
+ update_config = config["on_deploy"]
83
+
84
+ to_update = {}
85
+ if update_config["move_to"] and update_config["move_to"][params[:repo]]
86
+ to_update[:idList] = update_config["move_to"][params[:repo]]
87
+ end
88
+
89
+ if update_config["archive"]
90
+ to_update[:closed] = true
91
+ end
92
+
93
+ cards = JSON.parse(http.get_cards(config["on_close"]["move_to"]))
94
+ cards.each do |card|
95
+ http.update_card(card["id"], to_update)
96
+ end
97
+
98
+ ""
99
+ end
100
+
75
101
  get "/" do
76
- "Nothing to see here"
102
+ ""
77
103
  end
78
104
 
79
105
  def self.config=(config)
@@ -1,3 +1,3 @@
1
1
  module GithubTrello
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vegas
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70278794486600 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: 0.1.8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 0.1.8
24
+ version_requirements: *70278794486600
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: sinatra
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70278794485740 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ~>
@@ -37,12 +32,7 @@ dependencies:
37
32
  version: 1.3.2
38
33
  type: :runtime
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.3.2
35
+ version_requirements: *70278794485740
46
36
  description: Enables managing Trello cards through Github posthooks and Git commits
47
37
  email:
48
38
  - zach.anker@gmail.com
@@ -58,8 +48,7 @@ files:
58
48
  - MIT-LICENSE
59
49
  - README.md
60
50
  - Rakefile
61
- - !binary |-
62
- YmluL3RyZWxsby13ZWI=
51
+ - bin/trello-web
63
52
  homepage: http://github.com/zanker/github-trello
64
53
  licenses: []
65
54
  post_install_message:
@@ -80,8 +69,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
69
  version: 1.3.6
81
70
  requirements: []
82
71
  rubyforge_project: github-trello
83
- rubygems_version: 1.8.21
72
+ rubygems_version: 1.8.10
84
73
  signing_key:
85
74
  specification_version: 3
86
75
  summary: Github -> Trello integration
87
76
  test_files: []
77
+ has_rdoc: