ki_trello 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -51,18 +51,23 @@ end
51
51
 
52
52
  desc 'List boards'
53
53
  command :boards do |c|
54
+ c.desc "Print all details about each board"
55
+ c.switch [:d, :details]
54
56
  c.action do |global_options, options, args|
55
57
  command = KiTrello::Command.new
56
- command.list_boards
58
+ command.list_boards(options)
57
59
  end
58
60
  end
59
61
 
60
- desc 'Get card by ID (or short URL)'
62
+ desc 'Get card by short ID (e.g. card number), short URL, short URL ID'
61
63
  command :card do |c|
64
+ c.desc "Board ID"
65
+ c.flag [:b, :board]
62
66
  c.action do |global_options, options, args|
63
67
  card_id = args.first
68
+ help_now! "Card ID required" unless card_id
64
69
  command = KiTrello::Command.new
65
- command.get_card(card_id)
70
+ command.get_card(card_id, options[:board])
66
71
  end
67
72
  end
68
73
 
@@ -8,6 +8,7 @@ autoload :Kiseru, 'ki_trello/kiseru'
8
8
 
9
9
  module KiTrello
10
10
 
11
+ autoload :Board, "ki_trello/board"
11
12
  autoload :Command, "ki_trello/command"
12
13
  autoload :Interactive, "ki_trello/interactive"
13
14
  autoload :Session, "ki_trello/session"
@@ -0,0 +1,19 @@
1
+ module KiTrello
2
+
3
+ class Board
4
+
5
+ def initialize(board_data)
6
+ @board_data = board_data
7
+ end
8
+
9
+ def simplified
10
+ @board_data.select{ |k,v| ["id","name","url"].include? k }
11
+ end
12
+
13
+ def full
14
+ @board_data
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -11,12 +11,12 @@ module KiTrello
11
11
  @pretty = true
12
12
  end
13
13
 
14
- def list_boards
15
- output.puts(boards)
14
+ def list_boards(options={})
15
+ output.puts(boards(options))
16
16
  end
17
17
 
18
- def get_card(card_id)
19
- output.puts(card(card_id))
18
+ def get_card(card_id, board_id=nil)
19
+ output.puts(card(card_id, board_id))
20
20
  end
21
21
 
22
22
  def create_card(json, opts = {})
@@ -31,9 +31,14 @@ module KiTrello
31
31
  output.puts(lists(board_id))
32
32
  end
33
33
 
34
- def card(card_id)
34
+ def card(card_id, board_id)
35
35
  session = Session.new(@config)
36
- card_data = session.card(extract_id(card_id))
36
+ simple_card_id = extract_id(card_id)
37
+ card_data = if board_id
38
+ session.card_on_board(board_id, simple_card_id)
39
+ else
40
+ session.card(simple_card_id)
41
+ end
37
42
  MultiJson.dump(card_data, :pretty => @pretty)
38
43
  end
39
44
 
@@ -41,12 +46,16 @@ module KiTrello
41
46
  session = Session.new(@config)
42
47
  list_data = session.lists(board_id)
43
48
  MultiJson.dump(list_data, :pretty => @pretty)
44
-
45
49
  end
46
50
 
47
- def boards
51
+ def boards(options)
48
52
  session = Session.new(@config)
49
- board_data = session.boards
53
+ boards = session.boards.map {|b| Board.new(b) }
54
+ board_data = if options[:details]
55
+ boards.map(&:full)
56
+ else
57
+ boards.map(&:simplified)
58
+ end
50
59
  MultiJson.dump(board_data, :pretty => @pretty)
51
60
  end
52
61
 
@@ -31,6 +31,16 @@ module KiTrello
31
31
  end
32
32
  end
33
33
 
34
+ def card_on_board(board_id, card_id)
35
+ response = connection.get("/1/boards/#{board_id}/cards/#{card_id}", auth_params.merge(:checklists => 'all'))
36
+ case response.status
37
+ when 200
38
+ response.body.merge('ki_type' => 'trello_card')
39
+ else
40
+ raise SessionError, "Unhandled status code #{response.status}: #{response.body}"
41
+ end
42
+ end
43
+
34
44
  def card(card_id)
35
45
  response = connection.get("/1/cards/#{card_id}", auth_params.merge(:checklists => 'all'))
36
46
 
@@ -1,3 +1,3 @@
1
1
  module KiTrello
2
- VERSION = "0.0.6"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,30 @@
1
+ describe Board do
2
+
3
+ it "contains all data" do
4
+ data = {
5
+ "id" => "1234",
6
+ "name" => "my board",
7
+ "desc" =>"",
8
+ "closed" => false
9
+ }
10
+ board = Board.new(data)
11
+ board.full.should == data
12
+ end
13
+
14
+ it "simplifies data" do
15
+ data = {
16
+ "id" => "1234",
17
+ "name" => "my board",
18
+ "desc" =>"",
19
+ "url" => "http://trello.com/board-my-board/1234",
20
+ "closed" => false
21
+ }
22
+ board = Board.new(data)
23
+ board.simplified.should == {
24
+ "id" => "1234",
25
+ "name" => "my board",
26
+ "url" => "http://trello.com/board-my-board/1234"
27
+ }
28
+ end
29
+
30
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Interactive do
4
+ include Helpers
5
+
6
+ describe "select_item" do
7
+
8
+ it "returns nil if there are no items" do
9
+ id = Interactive.new.select_item({})
10
+ id.should be_nil
11
+ end
12
+
13
+ it "returns only id if there is only one item" do
14
+ id = Interactive.new.select_item([{:name => 'foo', :id => 99}])
15
+ id.should == 99
16
+ end
17
+
18
+ it "returns id of chosen item" do
19
+ index = 1
20
+ with_io(index) do |input, output, _|
21
+ lists = [{:name => 'foo', :id => 77},
22
+ {:name => 'bar', :id => 88}]
23
+ id = Interactive.new(input, output).select_item(lists)
24
+ id.should == 77
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ki_trello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-01 00:00:00.000000000Z
12
+ date: 2013-05-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
16
- requirement: &70119331014300 !ruby/object:Gem::Requirement
16
+ requirement: &70283273216280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70119331014300
24
+ version_requirements: *70283273216280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &70119331013080 !ruby/object:Gem::Requirement
27
+ requirement: &70283273215800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70119331013080
35
+ version_requirements: *70283273215800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: faraday_middleware
38
- requirement: &70119331011520 !ruby/object:Gem::Requirement
38
+ requirement: &70283273215340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.8.8
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70119331011520
46
+ version_requirements: *70283273215340
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: gli
49
- requirement: &70119331010180 !ruby/object:Gem::Requirement
49
+ requirement: &70283273214880 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.2.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70119331010180
57
+ version_requirements: *70283273214880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: multi_json
60
- requirement: &70119331008860 !ruby/object:Gem::Requirement
60
+ requirement: &70283273214420 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.3.6
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70119331008860
68
+ version_requirements: *70283273214420
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json_pure
71
- requirement: &70119331008240 !ruby/object:Gem::Requirement
71
+ requirement: &70283273213960 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.7.4
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70119331008240
79
+ version_requirements: *70283273213960
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: map
82
- requirement: &70119331007660 !ruby/object:Gem::Requirement
82
+ requirement: &70283273213500 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 6.2.0
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70119331007660
90
+ version_requirements: *70283273213500
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: debugger
93
- requirement: &70119331006640 !ruby/object:Gem::Requirement
93
+ requirement: &70283273233520 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.2.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70119331006640
101
+ version_requirements: *70283273233520
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rake
104
- requirement: &70119331005600 !ruby/object:Gem::Requirement
104
+ requirement: &70283273233060 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.9.2
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70119331005600
112
+ version_requirements: *70283273233060
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec
115
- requirement: &70119331004880 !ruby/object:Gem::Requirement
115
+ requirement: &70283273232600 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 2.11.0
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70119331004880
123
+ version_requirements: *70283273232600
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: simplecov
126
- requirement: &70119331004140 !ruby/object:Gem::Requirement
126
+ requirement: &70283273232140 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 0.6.4
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70119331004140
134
+ version_requirements: *70283273232140
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: test-construct
137
- requirement: &70119331003120 !ruby/object:Gem::Requirement
137
+ requirement: &70283273231680 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ~>
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: 1.2.0
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70119331003120
145
+ version_requirements: *70283273231680
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: vcr
148
- requirement: &70119331002140 !ruby/object:Gem::Requirement
148
+ requirement: &70283273231220 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ~>
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: 2.2.4
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *70119331002140
156
+ version_requirements: *70283273231220
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: webmock
159
- requirement: &70119330994600 !ruby/object:Gem::Requirement
159
+ requirement: &70283273230760 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ~>
@@ -164,7 +164,7 @@ dependencies:
164
164
  version: 1.8.9
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *70119330994600
167
+ version_requirements: *70283273230760
168
168
  description: A Kiseru client for Trello
169
169
  email:
170
170
  - ben@freeagent.com
@@ -182,6 +182,7 @@ files:
182
182
  - bin/ki_trello
183
183
  - ki_trello.gemspec
184
184
  - lib/ki_trello.rb
185
+ - lib/ki_trello/board.rb
185
186
  - lib/ki_trello/command.rb
186
187
  - lib/ki_trello/interactive.rb
187
188
  - lib/ki_trello/kiseru.rb
@@ -189,6 +190,8 @@ files:
189
190
  - lib/ki_trello/version.rb
190
191
  - spec/integration/command_spec.rb
191
192
  - spec/spec_helper.rb
193
+ - spec/unit/board_spec.rb
194
+ - spec/unit/interactive_spec.rb
192
195
  homepage: ''
193
196
  licenses: []
194
197
  post_install_message:
@@ -216,3 +219,5 @@ summary: A Kiseru client for Trello
216
219
  test_files:
217
220
  - spec/integration/command_spec.rb
218
221
  - spec/spec_helper.rb
222
+ - spec/unit/board_spec.rb
223
+ - spec/unit/interactive_spec.rb