thumbtack 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,42 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Thumbtack
4
- # Internal: Wraps API calls related to users.
4
+ # Wraps API calls related to users
5
5
  class User
6
- # Internal: Creates a new User.
6
+ # Initialize a User
7
7
  #
8
- # client - a Thumbtack::Client to communicate with the Pinboard API.
8
+ # @param [Client] client
9
+ # client to communicate with the Pinboard API
10
+ #
11
+ # @api private
9
12
  def initialize(client)
10
13
  @client = client
11
14
  end
12
15
 
13
- # Public: Returns the user's secret RSS key for viewing private feeds.
16
+ # Fetch the secret RSS key for viewing private feeds
17
+ #
18
+ # @example
19
+ # rss_key = user.secret
20
+ #
21
+ # @return [String]
22
+ #
23
+ # @api public
24
+ #
25
+ # @see https://pinboard.in/api/#user_secret
14
26
  def secret
15
27
  @client.get('/user/secret').fetch('result')
16
28
  end
17
29
 
18
- # Public: Returns the user's API token for making calls without a password.
30
+ # Fetch the API token for making calls without a password
31
+ #
32
+ # @example
33
+ # api_token = user.api_token
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @api public
38
+ #
39
+ # @see https://pinboard.in/api/#user_api_token
19
40
  def api_token
20
41
  @client.get('/user/api_token').fetch('result')
21
42
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Thumbtack
4
4
  # Gem version
5
- VERSION = '0.0.2'.freeze
5
+ VERSION = '0.0.3'.freeze
6
6
  end
@@ -5,16 +5,10 @@ CodeClimate::TestReporter.start
5
5
  require 'thumbtack'
6
6
  require 'minitest/autorun'
7
7
 
8
- def auth_token
9
- File.open(File.expand_path('../auth_token.txt', __FILE__)).read.strip
10
- end
11
-
12
- def username
13
- auth_token.split(':').first
14
- end
15
-
16
- def token
17
- auth_token.split(':').last
8
+ def mock_client(url, params, response)
9
+ client = Minitest::Mock.new
10
+ client.expect(:get, response, [url, params].compact)
11
+ client
18
12
  end
19
13
 
20
14
  include Thumbtack
@@ -4,7 +4,7 @@ require 'test_helper'
4
4
 
5
5
  class ClientTest < Minitest::Test
6
6
  def setup
7
- @client = Client.new(username, token)
7
+ @client = Client.new(nil, nil)
8
8
  end
9
9
 
10
10
  def test_posts
@@ -5,12 +5,15 @@ require 'test_helper'
5
5
  module Integration
6
6
  class ClientTest < Minitest::Test
7
7
  def setup
8
- @client = Client.new(username, token)
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)
9
12
  end
10
13
 
11
14
  def test_requests_return_parsed_json
12
15
  response = @client.get('/user/api_token')
13
- assert_equal({ 'result' => token }, response)
16
+ assert_equal({ 'result' => @token }, response)
14
17
  end
15
18
 
16
19
  def test_request_query_parameters
@@ -16,7 +16,7 @@ class NoteSummaryTest < Minitest::Test
16
16
 
17
17
  assert_equal '8e5d6964bb810e0050b0', note.id
18
18
  assert_equal 'StarCraft beta coming this week!', note.title
19
- assert_equal '0c9c30f60cadabd31415', note.hash
19
+ assert_equal '0c9c30f60cadabd31415', note.digest
20
20
  assert_equal '2010-02-11 03:46:56', note.created_at
21
21
  assert_equal '2010-02-11 03:47:47', note.updated_at
22
22
  assert_equal 19, note.length
@@ -3,12 +3,6 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class NotesTest < Minitest::Test
6
- def mock_client(url, params, response)
7
- client = Minitest::Mock.new
8
- client.expect(:get, response, [url, params].compact)
9
- client
10
- end
11
-
12
6
  def test_list
13
7
  client = mock_client('/notes/list',
14
8
  nil,
@@ -41,7 +35,7 @@ class NotesTest < Minitest::Test
41
35
  assert_equal '8e5d6964bb810e0050b0', result[1].id
42
36
  end
43
37
 
44
- def test_list
38
+ def test_get
45
39
  client = mock_client('/notes/8e5d6964bb810e0050b0',
46
40
  nil,
47
41
  {
@@ -3,12 +3,6 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class PostsTest < Minitest::Test
6
- def mock_client(url, params, response)
7
- client = Minitest::Mock.new
8
- client.expect(:get, response, [url, params].compact)
9
- client
10
- end
11
-
12
6
  def test_update
13
7
  client = mock_client('/posts/update',
14
8
  nil,
@@ -130,16 +124,15 @@ class PostsTest < Minitest::Test
130
124
  def test_suggest
131
125
  client = mock_client('/posts/suggest',
132
126
  {url: 'http://blog.com'},
133
- {
134
- 'popular' => ['blog', 'blogs', 'people', 'writing'],
135
- 'recommended' => ['blog', 'writing', 'weblog']
136
- })
127
+ [
128
+ { 'popular' => ['blog', 'blogs', 'people'] },
129
+ { 'recommended' => ['blog', 'writing', 'weblog'] }
130
+ ])
137
131
  posts = Posts.new(client)
138
132
  response = posts.suggest('http://blog.com')
139
133
 
140
- assert_equal 2, response.size
141
- assert_equal 'blog', response[:popular].first
142
- assert_equal 'weblog', response[:recommended].last
134
+ assert_equal 'blog', response.popular.first
135
+ assert_equal 'weblog', response.recommended.last
143
136
  client.verify
144
137
  end
145
138
 
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ class NoteSummaryTest < Minitest::Test
6
+ def test_from_array
7
+ array = [
8
+ { 'popular' => ['ifttt'] },
9
+ { 'recommended' => ['ifttt', 'twitter'] }
10
+ ]
11
+ suggestion = Suggestion.from_array(array)
12
+
13
+ assert_equal ['ifttt'], suggestion.popular
14
+ assert_equal ['ifttt', 'twitter'], suggestion.recommended
15
+ end
16
+ end
@@ -3,12 +3,6 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class TagsTest < Minitest::Test
6
- def mock_client(url, params, response)
7
- client = Minitest::Mock.new
8
- client.expect(:get, response, [url, params].compact)
9
- client
10
- end
11
-
12
6
  def test_update
13
7
  client = mock_client('/tags/get',
14
8
  nil,
@@ -3,12 +3,6 @@
3
3
  require 'test_helper'
4
4
 
5
5
  class UserTest < Minitest::Test
6
- def mock_client(url, params, response)
7
- client = Minitest::Mock.new
8
- client.expect(:get, response, [url, params].compact)
9
- client
10
- end
11
-
12
6
  def test_secret
13
7
  client = mock_client('/user/secret',
14
8
  nil,
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thumbtack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-08-27 00:00:00.000000000 Z
11
+ date: 2014-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.2
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.7.2
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,20 +53,20 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 10.3.2
55
55
  - !ruby/object:Gem::Dependency
56
- name: rdoc
56
+ name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 4.1.1
61
+ version: 0.8.7.4
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 4.1.1
69
- description: Thumbtack is a simple wrapper for the Pinboard API
68
+ version: 0.8.7.4
69
+ description: Thumbtack is a simple client for the Pinboard API
70
70
  email:
71
71
  - nwjsmith@gmail.com
72
72
  executables: []
@@ -81,6 +81,7 @@ files:
81
81
  - lib/thumbtack/post.rb
82
82
  - lib/thumbtack/posts.rb
83
83
  - lib/thumbtack/specification.rb
84
+ - lib/thumbtack/suggestion.rb
84
85
  - lib/thumbtack/tags.rb
85
86
  - lib/thumbtack/types.rb
86
87
  - lib/thumbtack/types/boolean.rb
@@ -104,6 +105,7 @@ files:
104
105
  - test/thumbtack/post_test.rb
105
106
  - test/thumbtack/posts_test.rb
106
107
  - test/thumbtack/specification_test.rb
108
+ - test/thumbtack/suggestion_test.rb
107
109
  - test/thumbtack/tags_test.rb
108
110
  - test/thumbtack/types/boolean_test.rb
109
111
  - test/thumbtack/types/date_test.rb
@@ -128,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
130
  requirements:
129
131
  - - ">="
130
132
  - !ruby/object:Gem::Version
131
- version: '0'
133
+ version: 1.9.2
132
134
  required_rubygems_version: !ruby/object:Gem::Requirement
133
135
  requirements:
134
136
  - - ">="
@@ -150,6 +152,7 @@ test_files:
150
152
  - test/thumbtack/post_test.rb
151
153
  - test/thumbtack/posts_test.rb
152
154
  - test/thumbtack/specification_test.rb
155
+ - test/thumbtack/suggestion_test.rb
153
156
  - test/thumbtack/tags_test.rb
154
157
  - test/thumbtack/types/boolean_test.rb
155
158
  - test/thumbtack/types/date_test.rb
@@ -162,3 +165,4 @@ test_files:
162
165
  - test/thumbtack/types/title_test.rb
163
166
  - test/thumbtack/types/url_test.rb
164
167
  - test/thumbtack/user_test.rb
168
+ has_rdoc: