thumbtack 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/thumbtack.rb +2 -1
  3. data/lib/thumbtack/adapters/basic_adapter.rb +83 -0
  4. data/lib/thumbtack/client.rb +26 -19
  5. data/lib/thumbtack/hash_to_digest.rb +12 -7
  6. data/lib/thumbtack/note.rb +1 -1
  7. data/lib/thumbtack/note_summary.rb +1 -1
  8. data/lib/thumbtack/post.rb +1 -1
  9. data/lib/thumbtack/posts.rb +13 -5
  10. data/lib/thumbtack/suggestion.rb +18 -4
  11. data/lib/thumbtack/symbolize_keys.rb +22 -0
  12. data/lib/thumbtack/types/boolean.rb +1 -1
  13. data/lib/thumbtack/types/date.rb +1 -1
  14. data/lib/thumbtack/types/date_time.rb +1 -1
  15. data/lib/thumbtack/types/identity.rb +1 -1
  16. data/lib/thumbtack/types/integer.rb +1 -1
  17. data/lib/thumbtack/types/length_validation.rb +10 -8
  18. data/lib/thumbtack/types/md5.rb +16 -3
  19. data/lib/thumbtack/types/range_validation.rb +5 -3
  20. data/lib/thumbtack/types/tags.rb +16 -3
  21. data/lib/thumbtack/types/text.rb +1 -1
  22. data/lib/thumbtack/types/title.rb +1 -1
  23. data/lib/thumbtack/types/url.rb +1 -1
  24. data/lib/thumbtack/version.rb +1 -1
  25. data/test/test_helper.rb +2 -2
  26. data/test/thumbtack/client_test.rb +29 -1
  27. data/test/thumbtack/integration/basic_adapter_test.rb +24 -0
  28. data/test/thumbtack/note_summary_test.rb +1 -1
  29. data/test/thumbtack/notes_test.rb +34 -34
  30. data/test/thumbtack/post_test.rb +1 -1
  31. data/test/thumbtack/posts_test.rb +113 -95
  32. data/test/thumbtack/specification_test.rb +2 -1
  33. data/test/thumbtack/suggestion_test.rb +4 -4
  34. data/test/thumbtack/tags_test.rb +30 -24
  35. data/test/thumbtack/types/date_test.rb +2 -2
  36. data/test/thumbtack/types/date_time_test.rb +4 -3
  37. data/test/thumbtack/types/identity_test.rb +1 -1
  38. data/test/thumbtack/types/md5_test.rb +3 -3
  39. data/test/thumbtack/types/tags_test.rb +2 -2
  40. data/test/thumbtack/types/text_test.rb +2 -2
  41. data/test/thumbtack/user_test.rb +10 -6
  42. metadata +26 -11
  43. data/lib/thumbtack/types.rb +0 -9
  44. data/test/thumbtack/integration/client_test.rb +0 -29
@@ -8,7 +8,8 @@ class SpecificationTest < Minitest::Test
8
8
  type_handler.expect(:validate, type_handler, ['value'])
9
9
  type_handler.expect(:to_parameter, 'parameterized', ['value'])
10
10
 
11
- assert_equal({ key: 'parameterized' },
11
+ assert_equal(
12
+ { key: 'parameterized' },
12
13
  Specification.new(key: type_handler).parameters(key: 'value'))
13
14
  type_handler.verify
14
15
  end
@@ -5,12 +5,12 @@ require 'test_helper'
5
5
  class NoteSummaryTest < Minitest::Test
6
6
  def test_from_array
7
7
  array = [
8
- { 'popular' => ['ifttt'] },
9
- { 'recommended' => ['ifttt', 'twitter'] }
8
+ { 'popular' => %w(ifttt) },
9
+ { 'recommended' => %w(ifttt twitter) }
10
10
  ]
11
11
  suggestion = Suggestion.from_array(array)
12
12
 
13
- assert_equal ['ifttt'], suggestion.popular
14
- assert_equal ['ifttt', 'twitter'], suggestion.recommended
13
+ assert_equal %w(ifttt), suggestion.popular
14
+ assert_equal %w(ifttt twitter), suggestion.recommended
15
15
  end
16
16
  end
@@ -4,34 +4,38 @@ require 'test_helper'
4
4
 
5
5
  class TagsTest < Minitest::Test
6
6
  def test_update
7
- client = mock_client_get('/tags/get',
8
- nil,
9
- {
10
- 'activedesktop' => '1',
11
- 'business' => '1',
12
- 'radio' => '3',
13
- 'xml' => '5',
14
- 'xp' => '1',
15
- 'xpi' => '1',
16
- })
7
+ client = mock_client_get(
8
+ '/tags/get',
9
+ nil,
10
+ 'activedesktop' => '1',
11
+ 'business' => '1',
12
+ 'radio' => '3',
13
+ 'xml' => '5',
14
+ 'xp' => '1',
15
+ 'xpi' => '1'
16
+ )
17
17
  tags = Tags.new(client)
18
18
 
19
- assert_equal({
20
- 'activedesktop' => 1,
21
- 'business' => 1,
22
- 'radio' => 3,
23
- 'xml' => 5,
24
- 'xp' => 1,
25
- 'xpi' => 1,
26
- }, tags.get)
19
+ assert_equal(
20
+ {
21
+ 'activedesktop' => 1,
22
+ 'business' => 1,
23
+ 'radio' => 3,
24
+ 'xml' => 5,
25
+ 'xp' => 1,
26
+ 'xpi' => 1
27
+ },
28
+ tags.get
29
+ )
27
30
 
28
31
  client.verify
29
32
  end
30
33
 
31
34
  def test_delete
32
- client = mock_client_action('/tags/delete',
33
- { tag: 'argentina' },
34
- { 'result_code' => 'done' })
35
+ client = mock_client_action(
36
+ '/tags/delete',
37
+ tag: 'argentina'
38
+ )
35
39
  tags = Tags.new(client)
36
40
 
37
41
  assert_equal tags, tags.delete('argentina')
@@ -39,9 +43,11 @@ class TagsTest < Minitest::Test
39
43
  end
40
44
 
41
45
  def test_rename
42
- client = mock_client_action('/tags/rename',
43
- { old: 'argentina', new: 'evita' },
44
- { 'result_code' => 'done' })
46
+ client = mock_client_action(
47
+ '/tags/rename',
48
+ old: 'argentina',
49
+ new: 'evita'
50
+ )
45
51
  tags = Tags.new(client)
46
52
 
47
53
  assert_equal tags, tags.rename('argentina', 'evita')
@@ -17,11 +17,11 @@ class DateTest < Minitest::Test
17
17
 
18
18
  def test_to_parameter
19
19
  assert_equal '2010-12-11',
20
- Types::Date.to_parameter(::Date.new(2010, 12, 11))
20
+ Types::Date.to_parameter(::Date.new(2010, 12, 11))
21
21
  end
22
22
 
23
23
  def test_from_parameter
24
24
  assert_equal ::Date.new(2010, 12, 11),
25
- Types::Date.from_parameter('2010-12-11')
25
+ Types::Date.from_parameter('2010-12-11')
26
26
  end
27
27
  end
@@ -17,16 +17,17 @@ class DateTimeTest < Minitest::Test
17
17
 
18
18
  def test_to_parameter
19
19
  assert_equal '2010-12-11T19:48:02Z',
20
- Types::DateTime.to_parameter(::DateTime.new(2010, 12, 11, 19, 48, 2))
20
+ Types::DateTime.to_parameter(
21
+ ::DateTime.new(2010, 12, 11, 19, 48, 2))
21
22
  end
22
23
 
23
24
  def test_from_parameter
24
25
  assert_equal ::DateTime.new(2010, 12, 11, 19, 48, 2),
25
- Types::DateTime.from_parameter('2010-12-11T19:48:02Z')
26
+ Types::DateTime.from_parameter('2010-12-11T19:48:02Z')
26
27
  end
27
28
 
28
29
  def test_from_note_parameter
29
30
  assert_equal ::DateTime.new(2010, 12, 11, 19, 48, 2),
30
- Types::DateTime.from_note_parameter('2010-12-11 19:48:02')
31
+ Types::DateTime.from_note_parameter('2010-12-11 19:48:02')
31
32
  end
32
33
  end
@@ -13,6 +13,6 @@ class IdentityTest < Minitest::Test
13
13
 
14
14
  def test_from_parameter
15
15
  assert_equal 'any parameter',
16
- Types::Identity.from_parameter('any parameter')
16
+ Types::Identity.from_parameter('any parameter')
17
17
  end
18
18
  end
@@ -5,7 +5,7 @@ require 'test_helper'
5
5
  class MD5Test < Minitest::Test
6
6
  def test_validate
7
7
  assert_equal Types::MD5,
8
- Types::MD5.validate('437b930db84b8079c2dd804a71936b5f')
8
+ Types::MD5.validate('437b930db84b8079c2dd804a71936b5f')
9
9
 
10
10
  assert_raises(ValidationError) do
11
11
  Types::MD5.validate('0' * 33)
@@ -18,11 +18,11 @@ class MD5Test < Minitest::Test
18
18
 
19
19
  def test_to_parameter
20
20
  assert_equal '437b930db84b8079c2dd804a71936b5f',
21
- Types::MD5.to_parameter('437b930db84b8079c2dd804a71936b5f')
21
+ Types::MD5.to_parameter('437b930db84b8079c2dd804a71936b5f')
22
22
  end
23
23
 
24
24
  def test_from_parameter
25
25
  assert_equal '437b930db84b8079c2dd804a71936b5f',
26
- Types::MD5.from_parameter('437b930db84b8079c2dd804a71936b5f')
26
+ Types::MD5.from_parameter('437b930db84b8079c2dd804a71936b5f')
27
27
  end
28
28
  end
@@ -19,11 +19,11 @@ class TagsTest < Minitest::Test
19
19
 
20
20
  def test_to_parameter
21
21
  assert_equal 'one', Types::Tags.to_parameter('one')
22
- assert_equal 'one two', Types::Tags.to_parameter(['one', 'two'])
22
+ assert_equal 'one two', Types::Tags.to_parameter(%w(one two))
23
23
  assert_equal 'padding', Types::Tags.to_parameter([' padding '])
24
24
  end
25
25
 
26
26
  def test_from_parameter
27
- assert_equal ['one', 'two'], Types::Tags.from_parameter('one two')
27
+ assert_equal %w(one two), Types::Tags.from_parameter('one two')
28
28
  end
29
29
  end
@@ -5,10 +5,10 @@ require 'test_helper'
5
5
  class TextTest < Minitest::Test
6
6
  def test_validate
7
7
  assert_equal Types::Text, Types::Text.validate('')
8
- assert_equal Types::Text, Types::Text.validate('x' * 65536)
8
+ assert_equal Types::Text, Types::Text.validate('x' * 65_536)
9
9
 
10
10
  assert_raises(ValidationError) do
11
- Types::Text.validate('x' * 65537)
11
+ Types::Text.validate('x' * 65_537)
12
12
  end
13
13
  end
14
14
 
@@ -4,18 +4,22 @@ require 'test_helper'
4
4
 
5
5
  class UserTest < Minitest::Test
6
6
  def test_secret
7
- client = mock_client_get('/user/secret',
8
- nil,
9
- { 'result' => '6493a84f72d86e7de130' })
7
+ client = mock_client_get(
8
+ '/user/secret',
9
+ nil,
10
+ 'result' => '6493a84f72d86e7de130'
11
+ )
10
12
  user = User.new(client)
11
13
 
12
14
  assert_equal '6493a84f72d86e7de130', user.secret
13
15
  end
14
16
 
15
17
  def test_api_token
16
- client = mock_client_get('/user/api_token',
17
- nil,
18
- { 'result' => 'XOG86E7JIYMI' })
18
+ client = mock_client_get(
19
+ '/user/api_token',
20
+ nil,
21
+ 'result' => 'XOG86E7JIYMI'
22
+ )
19
23
  user = User.new(client)
20
24
 
21
25
  assert_equal 'XOG86E7JIYMI', user.api_token
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thumbtack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-02 00:00:00.000000000 Z
11
+ date: 2015-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,34 +24,48 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: codeclimate-test-reporter
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.7
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.7
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: minitest
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 5.3.5
47
+ version: 5.7.0
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 5.3.5
54
+ version: 5.7.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 10.3.2
61
+ version: 10.4.2
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 10.3.2
68
+ version: 10.4.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: yard
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +88,7 @@ extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
90
  - lib/thumbtack.rb
91
+ - lib/thumbtack/adapters/basic_adapter.rb
77
92
  - lib/thumbtack/client.rb
78
93
  - lib/thumbtack/hash_to_digest.rb
79
94
  - lib/thumbtack/note.rb
@@ -83,8 +98,8 @@ files:
83
98
  - lib/thumbtack/posts.rb
84
99
  - lib/thumbtack/specification.rb
85
100
  - lib/thumbtack/suggestion.rb
101
+ - lib/thumbtack/symbolize_keys.rb
86
102
  - lib/thumbtack/tags.rb
87
- - lib/thumbtack/types.rb
88
103
  - lib/thumbtack/types/boolean.rb
89
104
  - lib/thumbtack/types/date.rb
90
105
  - lib/thumbtack/types/date_time.rb
@@ -101,7 +116,7 @@ files:
101
116
  - lib/thumbtack/version.rb
102
117
  - test/test_helper.rb
103
118
  - test/thumbtack/client_test.rb
104
- - test/thumbtack/integration/client_test.rb
119
+ - test/thumbtack/integration/basic_adapter_test.rb
105
120
  - test/thumbtack/note_summary_test.rb
106
121
  - test/thumbtack/note_test.rb
107
122
  - test/thumbtack/notes_test.rb
@@ -133,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
148
  requirements:
134
149
  - - ">="
135
150
  - !ruby/object:Gem::Version
136
- version: 1.9.2
151
+ version: 1.9.3
137
152
  required_rubygems_version: !ruby/object:Gem::Requirement
138
153
  requirements:
139
154
  - - ">="
@@ -141,14 +156,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
156
  version: '0'
142
157
  requirements: []
143
158
  rubyforge_project:
144
- rubygems_version: 2.3.0
159
+ rubygems_version: 2.4.5
145
160
  signing_key:
146
161
  specification_version: 4
147
162
  summary: The best Pinboard API client
148
163
  test_files:
149
164
  - test/test_helper.rb
150
165
  - test/thumbtack/client_test.rb
151
- - test/thumbtack/integration/client_test.rb
166
+ - test/thumbtack/integration/basic_adapter_test.rb
152
167
  - test/thumbtack/note_summary_test.rb
153
168
  - test/thumbtack/note_test.rb
154
169
  - test/thumbtack/notes_test.rb
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Thumbtack
4
- # Handlers for each of the data types in the Pinboard API
5
- #
6
- # @see https://pinboard.in/api/#data
7
- module Types
8
- end
9
- end
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'test_helper'
4
-
5
- module Integration
6
- class ClientTest < Minitest::Test
7
- def setup
8
- path = File.expand_path('../../../auth_token.txt', __FILE__)
9
- auth_token = File.open(path).read.strip
10
- @username, @token = auth_token.split(':')
11
- @client = Client.new(@username, @token)
12
- end
13
-
14
- def test_requests_return_parsed_json
15
- response = @client.get('/user/api_token')
16
- assert_equal({ 'result' => @token }, response)
17
- end
18
-
19
- def test_request_query_parameters
20
- response = @client.get('/posts/recent', tag: 'thumbtack-test-query-params')
21
- assert_equal([] , response['posts'])
22
- end
23
-
24
- def test_action_command_method
25
- response = @client.action('/tags/delete', tag: 'thumbtack-test-command')
26
- assert_equal(@client, response)
27
- end
28
- end
29
- end