tacokit 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +86 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +16 -25
  5. data/Guardfile +1 -1
  6. data/README.md +61 -17
  7. data/Rakefile +10 -5
  8. data/lib/tacokit/authorization.rb +14 -13
  9. data/lib/tacokit/client/actions.rb +68 -28
  10. data/lib/tacokit/client/boards.rb +92 -85
  11. data/lib/tacokit/client/cards.rb +285 -92
  12. data/lib/tacokit/client/checklists.rb +48 -28
  13. data/lib/tacokit/client/labels.rb +14 -16
  14. data/lib/tacokit/client/lists.rb +52 -28
  15. data/lib/tacokit/client/members.rb +56 -46
  16. data/lib/tacokit/client/notifications.rb +13 -27
  17. data/lib/tacokit/client/organizations.rb +0 -6
  18. data/lib/tacokit/client/searches.rb +0 -1
  19. data/lib/tacokit/client/tokens.rb +0 -6
  20. data/lib/tacokit/client/types.rb +0 -1
  21. data/lib/tacokit/client/webhooks.rb +3 -8
  22. data/lib/tacokit/client.rb +48 -75
  23. data/lib/tacokit/collection.rb +49 -0
  24. data/lib/tacokit/configuration.rb +4 -6
  25. data/lib/tacokit/error.rb +0 -2
  26. data/lib/tacokit/middleware/boom.rb +6 -7
  27. data/lib/tacokit/middleware.rb +2 -10
  28. data/lib/tacokit/resource.rb +84 -57
  29. data/lib/tacokit/response.rb +3 -3
  30. data/lib/tacokit/transform.rb +35 -13
  31. data/lib/tacokit/utils.rb +40 -8
  32. data/lib/tacokit/version.rb +1 -1
  33. data/lib/tacokit.rb +0 -2
  34. data/spec/cassettes/Tacokit_Client_Actions/_action_board/returns_action_board.json +1 -0
  35. data/spec/cassettes/Tacokit_Client_Actions/_action_card/returns_action_card.json +1 -0
  36. data/spec/cassettes/Tacokit_Client_Actions/_action_entities/returns_action_entities.json +1 -0
  37. data/spec/cassettes/Tacokit_Client_Actions/_action_list/returns_action_list.json +1 -0
  38. data/spec/cassettes/Tacokit_Client_Boards/_add_board_member/adds_invites_member_to_board.json +1 -1
  39. data/spec/cassettes/Tacokit_Client_Boards/_board_actions/returns_board_actions.json +1 -0
  40. data/spec/cassettes/Tacokit_Client_Boards/_board_cards/returns_board_cards.json +1 -0
  41. data/spec/cassettes/Tacokit_Client_Boards/_board_checklists/returns_board_checklists.json +1 -0
  42. data/spec/cassettes/Tacokit_Client_Boards/_board_labels/returns_board_labels.json +1 -0
  43. data/spec/cassettes/Tacokit_Client_Boards/_board_lists/returns_board_lists.json +1 -0
  44. data/spec/cassettes/Tacokit_Client_Boards/_board_members/returns_board_members.json +1 -0
  45. data/spec/cassettes/Tacokit_Client_Boards/_board_organization/returns_board_organization.json +1 -0
  46. data/spec/cassettes/Tacokit_Client_Boards/_board_preferences/returns_preferences_for_a_board.json +1 -0
  47. data/spec/cassettes/Tacokit_Client_Boards/_board_stars/returns_board_stars.json +1 -0
  48. data/spec/cassettes/Tacokit_Client_Boards/_member_board_stars/returns_board_stars.json +1 -0
  49. data/spec/cassettes/Tacokit_Client_Boards/_update_board_member/updates_member.json +1 -0
  50. data/spec/cassettes/Tacokit_Client_Cards/_add_comment/creates_a_comment.json +1 -0
  51. data/spec/cassettes/Tacokit_Client_Cards/_add_label/adds_label_to_card.json +1 -0
  52. data/spec/cassettes/Tacokit_Client_Cards/_add_member_to_card/adds_member_to_card.json +1 -0
  53. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/archives_card.json +1 -0
  54. data/spec/cassettes/Tacokit_Client_Cards/_archive_card/restore_card.json +1 -0
  55. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_an_attachment.json +1 -0
  56. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachment.json +1 -0
  57. data/spec/cassettes/Tacokit_Client_Cards/_attachments/returns_attachments.json +1 -0
  58. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_card_resource.json +1 -0
  59. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_id.json +1 -1
  60. data/spec/cassettes/Tacokit_Client_Cards/_card/returns_a_card_by_short_link.json +1 -1
  61. data/spec/cassettes/Tacokit_Client_Cards/_card_actions/returns_card_actions.json +1 -0
  62. data/spec/cassettes/Tacokit_Client_Cards/_card_board/returns_card_board.json +1 -0
  63. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_hash.json +1 -1
  64. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_a_value.json +1 -1
  65. data/spec/cassettes/Tacokit_Client_Cards/_card_field/returns_an_array.json +1 -1
  66. data/spec/cassettes/Tacokit_Client_Cards/_card_list/returns_a_list.json +1 -0
  67. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members.json +1 -0
  68. data/spec/cassettes/Tacokit_Client_Cards/_card_members/returns_members_voted.json +1 -0
  69. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_actions.json +1 -1
  70. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_board.json +1 -1
  71. data/spec/cassettes/Tacokit_Client_Cards/_card_resource/returns_card_check_item_states.json +1 -1
  72. data/spec/cassettes/Tacokit_Client_Cards/_card_stickers/returns_.json +1 -0
  73. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_check_item_states.json +1 -0
  74. data/spec/cassettes/Tacokit_Client_Cards/_checklists/returns_checklists.json +1 -0
  75. data/spec/cassettes/Tacokit_Client_Cards/_create_card/creates_a_card.json +1 -1
  76. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/attaches_external_url.json +1 -1
  77. data/spec/cassettes/Tacokit_Client_Cards/_create_card_attachment/uploads_local_file.json +1 -1
  78. data/spec/cassettes/Tacokit_Client_Cards/_delete_card/deletes_a_card.json +1 -1
  79. data/spec/cassettes/Tacokit_Client_Cards/_delete_card_resource/deletes_resource.json +1 -1
  80. data/spec/cassettes/Tacokit_Client_Cards/_delete_comment/deletes_comment.json +1 -0
  81. data/spec/cassettes/Tacokit_Client_Cards/_list/returns_list.json +1 -0
  82. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_a_new_position.json +1 -0
  83. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_another_board_list.json +1 -0
  84. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_board.json +1 -0
  85. data/spec/cassettes/Tacokit_Client_Cards/_move_card/moves_card_to_list.json +1 -0
  86. data/spec/cassettes/Tacokit_Client_Cards/_move_card/raises_error_if_missing_options.json +1 -0
  87. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_a_checklist_item.json +1 -0
  88. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/adds_new_checklist_by_name.json +1 -0
  89. data/spec/cassettes/Tacokit_Client_Cards/_start_checklist/copies_a_checklist_by_id.json +1 -0
  90. data/spec/cassettes/Tacokit_Client_Cards/_stickers/returns_stickers.json +1 -0
  91. data/spec/cassettes/Tacokit_Client_Cards/_update_card/updates_a_card.json +1 -1
  92. data/spec/cassettes/Tacokit_Client_Cards/_update_checklist_item/updates_checklist_item.json +1 -0
  93. data/spec/cassettes/Tacokit_Client_Cards/_update_comment/updates_a_comment.json +1 -0
  94. data/spec/cassettes/Tacokit_Client_Cards/_vote/adds_a_member_s_vote_to_card.json +1 -0
  95. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/adds_a_checklist_check_item.json +1 -0
  96. data/spec/cassettes/Tacokit_Client_Checklists/_check_items/retrieves_checklist_check_items.json +1 -0
  97. data/spec/cassettes/Tacokit_Client_Lists/_archive_list_cards/should_archive_cards_in_list.json +1 -0
  98. data/spec/cassettes/Tacokit_Client_Lists/_list_actions/returns_list_actions.json +1 -0
  99. data/spec/cassettes/Tacokit_Client_Lists/_list_board/returns_list_board.json +1 -0
  100. data/spec/cassettes/Tacokit_Client_Lists/_list_cards/returns_list_cards.json +1 -0
  101. data/spec/cassettes/Tacokit_Client_Lists/_move_list_cards/should_move_cards_in_list.json +1 -0
  102. data/spec/cassettes/Tacokit_Client_Members/_actions/returns_member_actions.json +1 -0
  103. data/spec/cassettes/Tacokit_Client_Members/_board_stars/returns_member_board_stars.json +1 -0
  104. data/spec/cassettes/Tacokit_Client_Members/_boards/returns_member_boards.json +1 -0
  105. data/spec/cassettes/Tacokit_Client_Members/_cards/returns_member_cards.json +1 -0
  106. data/spec/cassettes/Tacokit_Client_Members/_notifications/returns_member_notifications.json +1 -0
  107. data/spec/cassettes/Tacokit_Client_Members/_organizations/returns_member_organizations.json +1 -0
  108. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_organizations.json +1 -0
  109. data/spec/cassettes/Tacokit_Client_Members/_tokens/returns_member_tokens.json +1 -0
  110. data/spec/spec_helper.rb +39 -29
  111. data/spec/tacokit/authorization_spec.rb +11 -11
  112. data/spec/tacokit/client/actions_spec.rb +56 -19
  113. data/spec/tacokit/client/boards_spec.rb +81 -78
  114. data/spec/tacokit/client/cards_spec.rb +322 -68
  115. data/spec/tacokit/client/checklists_spec.rb +29 -27
  116. data/spec/tacokit/client/labels_spec.rb +8 -16
  117. data/spec/tacokit/client/lists_spec.rb +74 -27
  118. data/spec/tacokit/client/members_spec.rb +55 -41
  119. data/spec/tacokit/client/notifications_spec.rb +3 -31
  120. data/spec/tacokit/client/organizations_spec.rb +6 -27
  121. data/spec/tacokit/client/searches_spec.rb +1 -3
  122. data/spec/tacokit/client/tokens_spec.rb +2 -18
  123. data/spec/tacokit/client/types_spec.rb +2 -3
  124. data/spec/tacokit/client/webhooks_spec.rb +6 -14
  125. data/spec/tacokit/client_spec.rb +3 -3
  126. data/spec/tacokit/configuration_spec.rb +30 -31
  127. data/spec/tacokit/middleware/boom_spec.rb +6 -7
  128. data/spec/tacokit/resource_spec.rb +142 -17
  129. data/spec/tacokit/transform_spec.rb +37 -35
  130. data/spec/tacokit_spec.rb +3 -5
  131. data/tacokit.gemspec +6 -6
  132. metadata +132 -15
  133. data/config.ru +0 -7
  134. data/lib/tacokit/middleware/debug.rb +0 -22
  135. data/spec/cassettes/Tacokit_Client_Boards/_update_board_resource/updates_member.json +0 -1
  136. data/spec/cassettes/Tacokit_Client_Members/_member/raises_error_for_missing_token.json +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2578b367de9a2fa3604a9942c8605949fbe319a
4
- data.tar.gz: c78e9ff1f74434acd490dbe1aacc4eb9dac5c579
3
+ metadata.gz: 14ef84fc424d2cad14b4ea5ff37a270d9e3b5399
4
+ data.tar.gz: 130dd7e3aa458418bfb83f945026edb91f272286
5
5
  SHA512:
6
- metadata.gz: 510e5322ab2146b830db7124c8f644a5e7d2b35fc3a9c2ee2f2f8750690ae23103142d537040118d3329632cc8ff78147b63036a1ab99beafe2ddd06f2eb9c72
7
- data.tar.gz: 2487e3e8af3c5f79a54555ce7c8021bc7417f20398bed4a787ab08f1e8f819ac780a0aaacf41ca17f9723c56864381e4533f0510821153ee88a925db41d4067b
6
+ metadata.gz: 6fcc934c4029cabdcbb49827c3598b66daa1774b6e10346f8f5cb3be8371baf56c5fe685757f5e81e71003674eee75551452c05eefd790dc39a8731105460243
7
+ data.tar.gz: 2b974070b2c21ef16b3cd0535a9142da22e657a0e459aa08b753fe8881d14ad37c29719919725ed57273822fd2a570a15779cabd89e87511bb02fd502068962e
data/.rubocop.yml ADDED
@@ -0,0 +1,86 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "Guardfile"
4
+ - "spec/cassettes/**/*"
5
+ - "vendor/**/*"
6
+
7
+ Lint/UnusedBlockArgument:
8
+ Enabled: false
9
+ #
10
+ Lint/UnusedMethodArgument:
11
+ Enabled: false
12
+
13
+ Metrics/LineLength:
14
+ Max: 150 # TODO: we should decrease this to 120
15
+
16
+ Metrics/ClassLength:
17
+ Max: 300
18
+
19
+ Metrics/MethodLength:
20
+ Max: 25
21
+
22
+ Metrics/ParameterLists:
23
+ Max: 8
24
+
25
+ Metrics/AbcSize:
26
+ Enabled: false
27
+
28
+ Metrics/CyclomaticComplexity:
29
+ Enabled: false
30
+
31
+ Metrics/PerceivedComplexity:
32
+ Enabled: false
33
+
34
+ Style/AlignParameters:
35
+ EnforcedStyle: with_fixed_indentation
36
+
37
+ Style/StringLiterals:
38
+ EnforcedStyle: double_quotes
39
+
40
+ Style/StringLiteralsInInterpolation:
41
+ EnforcedStyle: double_quotes
42
+
43
+ Style/AndOr:
44
+ Enabled: false
45
+
46
+ Style/Not:
47
+ Enabled: false
48
+
49
+ Style/DoubleNegation:
50
+ Enabled: false
51
+
52
+ Documentation:
53
+ Enabled: false # TODO: Enable again once we have more docs
54
+
55
+ Style/CaseIndentation:
56
+ IndentWhenRelativeTo: case
57
+ SupportedStyles:
58
+ - case
59
+ - end
60
+ IndentOneStep: false
61
+
62
+ Style/PercentLiteralDelimiters:
63
+ PreferredDelimiters:
64
+ "%w": "[]"
65
+ "%W": "[]"
66
+
67
+ Style/AccessModifierIndentation:
68
+ EnforcedStyle: indent
69
+
70
+ Style/RegexpLiteral:
71
+ Enabled: false
72
+
73
+ Style/SignalException:
74
+ Enabled: false
75
+
76
+ Style/IndentationWidth:
77
+ Enabled: false
78
+
79
+ Lint/EndAlignment:
80
+ AlignWith: variable
81
+
82
+ Lint/DefEndAlignment:
83
+ Enabled: false
84
+
85
+ Lint/HandleExceptions:
86
+ Enabled: false
data/.travis.yml CHANGED
@@ -6,8 +6,14 @@ rvm:
6
6
  - 2.1
7
7
  - ruby-head
8
8
 
9
+ sudo: false
10
+ cache: bundler
11
+
9
12
  bundler_args: --without development --retry=3 --jobs=3
10
13
 
14
+ script:
15
+ - bundle exec rake
16
+
11
17
  env:
12
18
  # global:
13
19
  # - TRELLO_APP_KEY='tacokit-app-key'
data/Gemfile CHANGED
@@ -1,28 +1,19 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- group :development do
6
- gem 'awesome_print', :require => 'ap'
7
- gem 'guard-rspec'
8
- gem 'pry'
9
- gem 'pry-byebug', :platforms => :ruby_21
10
-
11
- gem 'oauth'
12
- gem 'sinatra'
13
- end
14
-
15
- group :test do
16
- # gem 'coveralls', :require => false
17
- # gem 'json', '~> 1.7', :platforms => [:ruby_18, :jruby]
18
- # gem 'mime-types', '< 2.0.0'
19
- # gem 'netrc', '~> 0.7.7'
20
- gem 'dotenv'
21
- gem 'launchy'
22
- gem 'rb-fsevent'
23
- gem 'rspec'
24
- gem 'simplecov', :require => false
25
- gem 'vcr'
26
- gem 'webmock'
27
- gem 'rake'
28
- end
5
+ gem "awesome_print", require: "ap"
6
+ gem "coveralls", require: false
7
+ gem "dotenv"
8
+ gem "guard-rspec"
9
+ gem "launchy"
10
+ gem "oauth"
11
+ gem "pry"
12
+ gem "pry-byebug", platforms: :ruby_21
13
+ gem "rake"
14
+ gem "rb-fsevent"
15
+ gem "rspec"
16
+ gem "rubocop"
17
+ gem "sinatra"
18
+ gem "vcr"
19
+ gem "webmock"
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard :rspec, cmd: "bundle exec rspec" do
1
+ guard :rspec, cmd: "bundle exec rspec --format progress" do
2
2
  require "ostruct"
3
3
 
4
4
  rspec = OpenStruct.new
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Tacokit
2
2
 
3
- [![Build Status](https://travis-ci.org/rossta/tacokit.rb.svg?branch=master)](https://travis-ci.org/rossta/tacokit.rb) [![Code Climate](https://codeclimate.com/github/rossta/tacokit.rb/badges/gpa.svg)](https://codeclimate.com/github/rossta/tacokit.rb) [![Dependency Status](https://gemnasium.com/rossta/tacokit.rb.svg)](https://gemnasium.com/rossta/tacokit.rb)
3
+ [![Build Status](https://travis-ci.org/rossta/tacokit.rb.svg?branch=master)](https://travis-ci.org/rossta/tacokit.rb) [![Code Climate](https://codeclimate.com/github/rossta/tacokit.rb/badges/gpa.svg)](https://codeclimate.com/github/rossta/tacokit.rb) [![Dependency Status](https://gemnasium.com/rossta/tacokit.rb.svg)](https://gemnasium.com/rossta/tacokit.rb) [![Coverage Status](https://coveralls.io/repos/rossta/tacokit.rb/badge.svg)](https://coveralls.io/r/rossta/tacokit.rb)
4
4
 
5
5
  Ruby toolkit for the Trello API... a work-in-progress. Design and philosophy
6
6
  inspired by [ocktokit.rb](https://github.com/ocktokit/ocktokit.rb)
@@ -12,10 +12,10 @@ This is Taco.
12
12
 
13
13
  ## Quick Start
14
14
 
15
- Add this line to your application's Gemfile:
15
+ Add this line to your application"s Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'tacokit'
18
+ gem "tacokit"
19
19
  ```
20
20
 
21
21
  ... or install it yourself as:
@@ -26,11 +26,11 @@ Configure the client with public-read application credentials:
26
26
 
27
27
  ```ruby
28
28
  # View an app key and secret on Trello
29
- Tacokit.open_app_key
29
+ Tacokit.get_app_key
30
30
 
31
31
  # Configure the client
32
32
  Tacokit.configure do |c|
33
- c.app_key = '4ppk3y'
33
+ c.app_key = "4ppk3y"
34
34
  end
35
35
  ```
36
36
 
@@ -41,13 +41,13 @@ client instance methods.
41
41
  Tacokit.member
42
42
 
43
43
  # Fetch another member
44
- Tacokit.member 'tacokit'
44
+ Tacokit.member "tacokit"
45
45
 
46
46
  # Configure a separate client
47
- client = Tacokit::Client.new app_key: '4ppk3y'
47
+ client = Tacokit::Client.new app_key: "4ppk3y"
48
48
 
49
49
  # Fetch a member
50
- client.member 'tacokit'
50
+ client.member "tacokit"
51
51
  ```
52
52
  ## Authentication
53
53
 
@@ -59,7 +59,7 @@ Tacokit provides a simple way to retrieve your application key:
59
59
 
60
60
  ```ruby
61
61
  # Install the `launchy` gem to load the Trello page automatically
62
- Tacokit.open_app_key
62
+ Tacokit.get_app_key
63
63
  ```
64
64
  Your application key are available by logging into Trello and visiting the [app key](https://trello.com/app-key) page. This page also provides your application secret that can be used to generate OAuth token access (see below).
65
65
 
@@ -69,13 +69,13 @@ Tacokit provides a simple way to generate a new app token:
69
69
 
70
70
  ```ruby
71
71
  # Full permissions for 30 days
72
- Tacokit.authorize scope: %w[ read write account ], expiration: '30days'
72
+ Tacokit.authorize scope: %w[ read write account ], expiration: "30days"
73
73
 
74
74
  # Authorize a custom application and a different app key
75
- Tacokit.authorize name: 'My Trello App', key: '4ppk3y2'
75
+ Tacokit.authorize name: "My Trello App", key: "4ppk3y2"
76
76
 
77
77
  # Read only permissions for custom app forever
78
- Tacokit.authorize scope: 'read', expiration: 'never', name: 'My Trello App'
78
+ Tacokit.authorize scope: "read", expiration: "never", name: "My Trello App"
79
79
  ```
80
80
 
81
81
  Your Tacokit client can now be configured to make requests:
@@ -83,8 +83,8 @@ Your Tacokit client can now be configured to make requests:
83
83
  ```ruby
84
84
  # Configure the client
85
85
  Tacokit.configure do |c|
86
- c.app_key = '4ppk3y'
87
- c.app_token = '4ppt0k3n'
86
+ c.app_key = "4ppk3y"
87
+ c.app_token = "4ppt0k3n"
88
88
  end
89
89
  ```
90
90
 
@@ -97,7 +97,7 @@ flow. Tacokit clients can therefore be configured separately to make requests on
97
97
  behalf of different members:
98
98
 
99
99
  ```ruby
100
- client = Tacokit::Client.new app_key: '4ppk3y', oauth_token: '04utht0k3n'
100
+ client = Tacokit::Client.new app_key: "4ppk3y", oauth_token: "04utht0k3n"
101
101
  ```
102
102
 
103
103
  To experiment with OAuth tokens for development, visit the [Tacokit
@@ -123,12 +123,56 @@ TRELLO_APP_TOKEN=4ppt0k3n
123
123
 
124
124
  ## Usage
125
125
 
126
- Coming soon.
126
+ Working with boards
127
+
128
+ ```ruby
129
+ client.boards
130
+
131
+ client.boards("rossta")
132
+
133
+ board_id = "swezQ9XS" # short link to "Test Board" for Tacokit
134
+
135
+ board = client.board(board_id)
136
+
137
+ board.name = "Ice Box"
138
+
139
+ client.update_board(board.id, name: "TODO")
140
+ ```
141
+
142
+ Working with cards
143
+
144
+ ```ruby
145
+ client.cards
146
+
147
+ client.cards("rossta")
148
+
149
+ client.board_cards(board_id)
150
+
151
+ card_id = "SpbauOpX" # short link to card on "Test Board"
152
+
153
+ card.name = "Shopping List"
154
+
155
+ client.update_card(card.id, name: "Wish List")
156
+
157
+ client.move_card(card.id, list_id: list_id)
158
+ ```
159
+
160
+ Working with lists
161
+
162
+ ```ruby
163
+ client.lists(board_id)
164
+
165
+ list = client.list(list_id)
166
+
167
+ list.name = "Work in Progress"
168
+
169
+ client.update_list(list.id, name: "Done")
170
+ ```
127
171
 
128
172
  ## Contributing
129
173
 
130
174
  1. Fork it ( https://github.com/[my-github-username]/tacokit/fork )
131
175
  2. Create your feature branch (`git checkout -b my-new-feature`)
132
- 3. Commit your changes (`git commit -am 'Add some feature'`)
176
+ 3. Commit your changes (`git commit -am "Add some feature"`)
133
177
  4. Push to the branch (`git push origin my-new-feature`)
134
178
  5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,8 +1,13 @@
1
- require 'bundler'
1
+ require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require 'rspec/core/rake_task'
5
- RSpec::Core::RakeTask.new(:spec)
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.rspec_opts = "--color --format progress"
7
+ end
6
8
 
7
- task :test => :spec
8
- task :default => :spec
9
+ require "rubocop/rake_task"
10
+ RuboCop::RakeTask.new
11
+
12
+ task test: [:spec, :rubocop]
13
+ task default: [:spec, :rubocop]
@@ -1,33 +1,35 @@
1
1
  module Tacokit
2
2
  module Authorization
3
-
4
- def open_app_key
3
+ def get_app_key # rubocop:disable Style/AccessorMethodName
5
4
  open_url web_url("appKey/generate")
6
5
  end
7
6
 
8
- # Params
9
- # callback_method: "postMessage" or "fragment"
10
- # return_url: URL the token should be returned to
11
- # scope: Comma-separated list of one or more of "read", "write", "account"
12
- # expiration: "1hour", "1day", "30days", "never"
13
- # name: Name of the application
14
- # key: Application key
7
+ # Get a token for making authorized requests to the Trello API
15
8
  #
9
+ # @param [String, #read] contents the contents to reverse
10
+ # @param options [Hash] Repository information to update
11
+ # @option options [String] :name Name of the application
12
+ # @option options [String] :key Application key
13
+ # @option options [String] :callback_method "postMessage" or "fragment"
14
+ # @option options [String] :return_url URL the token should be returned to
15
+ # @option options [String] :scope Comma-separated list of one or more of "read", "write", "account"
16
+ # @option options [String] :expiration "1hour", "1day", "30days", "never"
17
+ # @see https://trello.com/docs/gettingstarted/authorize.html
16
18
  def authorize(params = {})
17
19
  open_url authorize_url(params)
18
20
  end
19
21
 
20
22
  def authorize_url(params = {})
21
23
  params[:key] ||= app_key
22
- params[:name] ||= 'Tacokit'
23
- params[:response_type] ||= 'token'
24
+ params[:name] ||= "Tacokit"
25
+ params[:response_type] ||= "token"
24
26
  web_url "authorize", params
25
27
  end
26
28
 
27
29
  private
28
30
 
29
31
  def open_url(url)
30
- require 'launchy'
32
+ require "launchy"
31
33
  Launchy.open(url)
32
34
  rescue LoadError
33
35
  warn "Visit #{url}"
@@ -41,6 +43,5 @@ module Tacokit
41
43
  def web_connection
42
44
  Faraday::Connection.new(web_endpoint)
43
45
  end
44
-
45
46
  end
46
47
  end
@@ -1,51 +1,91 @@
1
1
  module Tacokit
2
2
  class Client
3
3
  module Actions
4
-
5
- # GET /1/actions/[idAction]
4
+ # Retrieve an action
5
+ #
6
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction
6
7
  def action(action_id, options = nil)
7
8
  get action_path(action_id), options
8
9
  end
9
10
 
10
- # GET /1/actions/[idAction]/[field]
11
- def action_field(action_id, field)
12
- get action_path(action_id, camp(field))
13
- end
14
-
15
- # GET /1/actions/[idAction]/[resource]
16
- # board
17
- # board/[field]
18
- # card
19
- # card/[field]
20
- # entities
21
- # list
22
- # list/[field]
23
- # member
24
- # member/[field]
25
- # memberCreator
26
- # memberCreator/[field]
27
- # organization
28
- # organization/[field]
29
- def action_resource(action_id, resource, *paths)
30
- paths, options = extract_options(camp(resource), *paths)
31
- get action_path(action_id, *paths), options
11
+ # Retrieve an action's board
12
+ #
13
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction-field
14
+ def action_board(action_id, fields = "all")
15
+ action_resource action_id, "board", fields: fields
16
+ end
17
+
18
+ # Retrieve an actions" card
19
+ #
20
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction-card
21
+ def action_card(action_id, fields = "all")
22
+ action_resource action_id, "card", fields: fields
23
+ end
24
+
25
+ # Retrive an action's entities
26
+ #
27
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction-entities
28
+ def action_entities(action_id)
29
+ action_resource action_id, "entities"
30
+ end
31
+
32
+ # Retrieve an action's list
33
+ #
34
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction-list
35
+ def action_list(action_id, fields = "all")
36
+ action_resource action_id, "list", fields: fields
37
+ end
38
+
39
+ # Retrieve an actions" member
40
+ #
41
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction-member
42
+ def action_member(action_id, fields = "all")
43
+ action_resource action_id, "member", fields: fields
44
+ end
45
+
46
+ # Retrieve an action's creator
47
+ #
48
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction-membercreator
49
+ def action_member_creator(action_id, fields = "all")
50
+ action_resource action_id, "memberCreator", fields: fields
32
51
  end
33
52
 
34
- # PUT /1/actions/[idAction]
53
+ # Retrieve an action's org
54
+ #
55
+ # @see https://trello.com/docs/api/action/index.html#get-1-actions-idaction-organization
56
+ def action_organization(action_id, fields = "all")
57
+ action_resource action_id, "organization", fields: fields
58
+ end
59
+
60
+ # Update an action
61
+ #
62
+ # @see https://trello.com/docs/api/action/index.html#put-1-actions-idaction
35
63
  def update_action(action_id, options = {})
36
64
  put action_path(action_id), options
37
65
  end
38
66
 
39
- # PUT /1/actions/[idAction]/text
67
+ # Set new text for an action
68
+ #
69
+ # @see https://trello.com/docs/api/action/index.html#put-1-actions-idaction-text
40
70
  def update_action_text(action_id, text)
41
- put action_path(action_id, 'text'), value: text
71
+ put action_path(action_id, "text"), value: text
42
72
  end
73
+ alias_method :edit_action_text, :update_action_text
43
74
 
44
- # DELETE /1/actions/[idAction]
75
+ # Delete an action
76
+ #
77
+ # @see https://trello.com/docs/api/action/index.html#delete-1-actions-idaction
45
78
  def delete_action(action_id)
46
79
  delete action_path(action_id)
47
80
  end
48
81
 
82
+ private
83
+
84
+ def action_resource(action_id, resource, *paths)
85
+ paths, options = extract_options(camp(resource), *paths)
86
+ get action_path(action_id, *paths), options
87
+ end
88
+
49
89
  def action_path(*paths)
50
90
  path_join("actions", *paths)
51
91
  end