thumbtack 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfceebca8bd2653fbb6a32085aa3449e3a872c1d
4
- data.tar.gz: f3be0d3c15e9f9ca487bba144f9192fe300941b2
3
+ metadata.gz: 865dedec8bc24d93f1134a1a4b0515decd1ab4cb
4
+ data.tar.gz: 55d72d32a1a29eeee1578fb3736ba20f643f721d
5
5
  SHA512:
6
- metadata.gz: 57742f4274a670de859c45b9e4373176205d01ba219a1d8b0eccc3443ef61a8f171881c37917a8bb7a174fc531171c89163df9e7b65172f52c5bc2eef703c6e8
7
- data.tar.gz: 392b5f79e1ecd490bf8fa7c336f48c150ba47b19c7f8c010c6be8eea4c8327d3239c3279fd5d4b95ce1fec6b1f3552a56e80581992740895c35e7a1e7d7dba8f
6
+ metadata.gz: 5eb64b30a1a0f11dc500e9e48017467f807026e6526278c046602424a65fdc1bbd419f634a46323b86994181d6d80de59fe91f67312f9717695bb1c12ce0288d
7
+ data.tar.gz: 4d9462b77cfe56905794db3e876c93bd20a487a4ed5d510de210f37c714a5efeea55c60bd12eb5fe6b1f75ca787075262965ca8afc4d6dd2c95d9dfcb27cfb63
@@ -47,7 +47,7 @@ module Thumbtack
47
47
  #
48
48
  # @api public
49
49
  def created_at
50
- Types::DateTime.from_note_parameter(@created_at)
50
+ Types::DateTime.deserialize_from_note(@created_at)
51
51
  end
52
52
 
53
53
  # The time at which the note was last updated
@@ -59,7 +59,7 @@ module Thumbtack
59
59
  #
60
60
  # @api public
61
61
  def updated_at
62
- Types::DateTime.from_note_parameter(@updated_at)
62
+ Types::DateTime.deserialize_from_note(@updated_at)
63
63
  end
64
64
 
65
65
  # 20 character hexadecimal SHA1 hash of the note text
@@ -47,7 +47,7 @@ module Thumbtack
47
47
  #
48
48
  # @api public
49
49
  def created_at
50
- Types::DateTime.from_note_parameter(@created_at)
50
+ Types::DateTime.deserialize_from_note(@created_at)
51
51
  end
52
52
 
53
53
  # The time at which the note was last updated
@@ -59,7 +59,7 @@ module Thumbtack
59
59
  #
60
60
  # @api public
61
61
  def updated_at
62
- Types::DateTime.from_note_parameter(@updated_at)
62
+ Types::DateTime.deserialize_from_note(@updated_at)
63
63
  end
64
64
 
65
65
  # 20 character hexadecimal SHA1 hash of the note text
@@ -79,7 +79,7 @@ module Thumbtack
79
79
  #
80
80
  # @api public
81
81
  def time
82
- Types::DateTime.from_parameter(@time)
82
+ Types::DateTime.deserialize(@time)
83
83
  end
84
84
 
85
85
  # If true, this post is public
@@ -91,7 +91,7 @@ module Thumbtack
91
91
  #
92
92
  # @api public
93
93
  def shared
94
- Types::Boolean.from_parameter(@shared)
94
+ Types::Boolean.deserialize(@shared)
95
95
  end
96
96
 
97
97
  # If true, this post is marked unread
@@ -103,7 +103,7 @@ module Thumbtack
103
103
  #
104
104
  # @api public
105
105
  def toread
106
- Types::Boolean.from_parameter(@toread)
106
+ Types::Boolean.deserialize(@toread)
107
107
  end
108
108
 
109
109
  # The tags for this post, space-seperated
@@ -115,7 +115,7 @@ module Thumbtack
115
115
  #
116
116
  # @api public
117
117
  def tags
118
- Types::Tags.from_parameter(@tags)
118
+ Types::Tags.deserialize(@tags)
119
119
  end
120
120
 
121
121
  # Creates a new Post from a Hash
@@ -25,7 +25,7 @@ module Thumbtack
25
25
  # @see https://pinboard.in/api/#posts_update
26
26
  def update
27
27
  response = @client.get('/posts/update')
28
- Types::DateTime.from_parameter response.fetch('update_time')
28
+ Types::DateTime.deserialize response.fetch('update_time')
29
29
  end
30
30
 
31
31
  # Add a bookmark
@@ -249,7 +249,7 @@ module Thumbtack
249
249
  # @api private
250
250
  def dates_with_counts_from(response)
251
251
  entries = response.fetch('dates', EMPTY_HASH).map do |date, count|
252
- [Types::Date.from_parameter(date), count.to_i]
252
+ [Types::Date.deserialize(date), count.to_i]
253
253
  end
254
254
  Hash[entries]
255
255
  end
@@ -26,7 +26,7 @@ module Thumbtack
26
26
  arguments.map do |name, value|
27
27
  type_handler = @type_handlers.fetch(name)
28
28
  type_handler.validate(value)
29
- [name, type_handler.to_parameter(value)]
29
+ [name, type_handler.serialize(value)]
30
30
  end
31
31
  ]
32
32
  end
@@ -32,7 +32,7 @@ module Thumbtack
32
32
  #
33
33
  # @return [String]
34
34
  # 'yes' if value is true, 'no' otherwise
35
- def self.to_parameter(value)
35
+ def self.serialize(value)
36
36
  case value
37
37
  when TrueClass
38
38
  'yes'
@@ -47,7 +47,7 @@ module Thumbtack
47
47
  # Either 'yes' or 'no'
48
48
  #
49
49
  # @return [Boolean]
50
- def self.from_parameter(parameter)
50
+ def self.deserialize(parameter)
51
51
  case parameter
52
52
  when 'yes'
53
53
  true
@@ -33,7 +33,7 @@ module Thumbtack
33
33
  #
34
34
  # @return [String]
35
35
  # the date with format yyyy-mm-dd
36
- def self.to_parameter(value)
36
+ def self.serialize(value)
37
37
  value.xmlschema
38
38
  end
39
39
 
@@ -43,7 +43,7 @@ module Thumbtack
43
43
  # the date with format yyyy-mm-dd
44
44
  #
45
45
  # @return [Date]
46
- def self.from_parameter(parameter)
46
+ def self.deserialize(parameter)
47
47
  ::Date.xmlschema(parameter)
48
48
  end
49
49
  end
@@ -11,8 +11,10 @@ module Thumbtack
11
11
  EARLIEST = ::DateTime.new(1, 1, 1)
12
12
  # The latest allowable time
13
13
  LATEST = ::DateTime.new(2100, 1, 1)
14
- # Pinboard's date format
14
+ # Pinboard's date time format
15
15
  FORMAT = '%Y-%m-%dT%H:%M:%SZ'.freeze
16
+ # Pinboard's date time format for notes
17
+ NOTE_FORMAT = '%Y-%m-%d %H:%M:%S'.freeze
16
18
 
17
19
  # Validate a time
18
20
  #
@@ -35,7 +37,7 @@ module Thumbtack
35
37
  #
36
38
  # @return [String]
37
39
  # the time formatted yyyy-mm-ddTHH:MM:SSZ.
38
- def self.to_parameter(value)
40
+ def self.serialize(value)
39
41
  value.strftime(FORMAT)
40
42
  end
41
43
 
@@ -45,7 +47,7 @@ module Thumbtack
45
47
  # the time formatted yyyy-mm-ddTHH:MM:SSZ
46
48
  #
47
49
  # @return [DateTime]
48
- def self.from_parameter(parameter)
50
+ def self.deserialize(parameter)
49
51
  ::DateTime.strptime(parameter)
50
52
  end
51
53
 
@@ -55,8 +57,8 @@ module Thumbtack
55
57
  # the time formatted yyyy-mm-dd HH:MM:SS
56
58
  #
57
59
  # @return [DateTime]
58
- def self.from_note_parameter(parameter)
59
- ::DateTime.strptime(parameter, '%Y-%m-%d %H:%M:%S')
60
+ def self.deserialize_from_note(parameter)
61
+ ::DateTime.strptime(parameter, NOTE_FORMAT)
60
62
  end
61
63
  end
62
64
  end
@@ -19,7 +19,7 @@ module Thumbtack
19
19
  # the value to return
20
20
  #
21
21
  # @return [value]
22
- def self.to_parameter(value)
22
+ def self.serialize(value)
23
23
  value
24
24
  end
25
25
 
@@ -29,7 +29,7 @@ module Thumbtack
29
29
  # the parameter to return
30
30
  #
31
31
  # @return [parameter]
32
- def self.from_parameter(parameter)
32
+ def self.deserialize(parameter)
33
33
  parameter
34
34
  end
35
35
  end
@@ -40,7 +40,7 @@ module Thumbtack
40
40
  #
41
41
  # @return [String]
42
42
  # space-separated list of tags
43
- def self.to_parameter(value)
43
+ def self.serialize(value)
44
44
  Array(value).map(&:strip).join(SEPARATOR)
45
45
  end
46
46
 
@@ -50,7 +50,7 @@ module Thumbtack
50
50
  # space-separated list of tags
51
51
  #
52
52
  # @return [Array<String>]
53
- def self.from_parameter(parameter)
53
+ def self.deserialize(parameter)
54
54
  parameter.split(SEPARATOR)
55
55
  end
56
56
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Thumbtack
4
4
  # Gem version
5
- VERSION = '1.1.0'.freeze
5
+ VERSION = '1.1.1'.freeze
6
6
  end
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  def mock_client_action(url, params)
15
15
  client = Minitest::Mock.new
16
- client.expect(:action, { 'result' => 'done' }, [url, params].compact)
16
+ client.expect(:action, { 'result' => 'done' }, [url, params])
17
17
  client
18
18
  end
19
19
 
@@ -6,7 +6,7 @@ class SpecificationTest < Minitest::Test
6
6
  def test_parameters
7
7
  type_handler = Minitest::Mock.new
8
8
  type_handler.expect(:validate, type_handler, ['value'])
9
- type_handler.expect(:to_parameter, 'parameterized', ['value'])
9
+ type_handler.expect(:serialize, 'parameterized', ['value'])
10
10
 
11
11
  assert_equal(
12
12
  { key: 'parameterized' },
@@ -16,13 +16,13 @@ class BooleanTest < Minitest::Test
16
16
  end
17
17
  end
18
18
 
19
- def test_to_parameter
20
- assert_equal 'yes', Types::Boolean.to_parameter(true)
21
- assert_equal 'no', Types::Boolean.to_parameter(false)
19
+ def test_serialize
20
+ assert_equal 'yes', Types::Boolean.serialize(true)
21
+ assert_equal 'no', Types::Boolean.serialize(false)
22
22
  end
23
23
 
24
- def test_from_parameter
25
- assert_equal true, Types::Boolean.from_parameter('yes')
26
- assert_equal false, Types::Boolean.from_parameter('no')
24
+ def test_deserialize
25
+ assert_equal true, Types::Boolean.deserialize('yes')
26
+ assert_equal false, Types::Boolean.deserialize('no')
27
27
  end
28
28
  end
@@ -15,13 +15,13 @@ class DateTest < Minitest::Test
15
15
  end
16
16
  end
17
17
 
18
- def test_to_parameter
18
+ def test_serialize
19
19
  assert_equal '2010-12-11',
20
- Types::Date.to_parameter(::Date.new(2010, 12, 11))
20
+ Types::Date.serialize(::Date.new(2010, 12, 11))
21
21
  end
22
22
 
23
- def test_from_parameter
23
+ def test_deserialize
24
24
  assert_equal ::Date.new(2010, 12, 11),
25
- Types::Date.from_parameter('2010-12-11')
25
+ Types::Date.deserialize('2010-12-11')
26
26
  end
27
27
  end
@@ -15,19 +15,19 @@ class DateTimeTest < Minitest::Test
15
15
  end
16
16
  end
17
17
 
18
- def test_to_parameter
18
+ def test_serialize
19
19
  assert_equal '2010-12-11T19:48:02Z',
20
- Types::DateTime.to_parameter(
20
+ Types::DateTime.serialize(
21
21
  ::DateTime.new(2010, 12, 11, 19, 48, 2))
22
22
  end
23
23
 
24
- def test_from_parameter
24
+ def test_deserialize
25
25
  assert_equal ::DateTime.new(2010, 12, 11, 19, 48, 2),
26
- Types::DateTime.from_parameter('2010-12-11T19:48:02Z')
26
+ Types::DateTime.deserialize('2010-12-11T19:48:02Z')
27
27
  end
28
28
 
29
- def test_from_note_parameter
29
+ def test_deserialize_from_note
30
30
  assert_equal ::DateTime.new(2010, 12, 11, 19, 48, 2),
31
- Types::DateTime.from_note_parameter('2010-12-11 19:48:02')
31
+ Types::DateTime.deserialize_from_note('2010-12-11 19:48:02')
32
32
  end
33
33
  end
@@ -7,12 +7,12 @@ class IdentityTest < Minitest::Test
7
7
  assert_equal Types::Identity, Types::Identity.validate('any value')
8
8
  end
9
9
 
10
- def test_to_parameter
11
- assert_equal 'any value', Types::Identity.to_parameter('any value')
10
+ def test_serialize
11
+ assert_equal 'any value', Types::Identity.serialize('any value')
12
12
  end
13
13
 
14
- def test_from_parameter
14
+ def test_deserialize
15
15
  assert_equal 'any parameter',
16
- Types::Identity.from_parameter('any parameter')
16
+ Types::Identity.deserialize('any parameter')
17
17
  end
18
18
  end
@@ -16,11 +16,11 @@ class IntegerTest < Minitest::Test
16
16
  end
17
17
  end
18
18
 
19
- def test_to_parameter
20
- assert_equal 42, Types::Integer.to_parameter(42)
19
+ def test_serialize
20
+ assert_equal 42, Types::Integer.serialize(42)
21
21
  end
22
22
 
23
- def test_from_parameter
24
- assert_equal 42, Types::Integer.from_parameter(42)
23
+ def test_deserialize
24
+ assert_equal 42, Types::Integer.deserialize(42)
25
25
  end
26
26
  end
@@ -16,13 +16,13 @@ class MD5Test < Minitest::Test
16
16
  end
17
17
  end
18
18
 
19
- def test_to_parameter
19
+ def test_serialize
20
20
  assert_equal '437b930db84b8079c2dd804a71936b5f',
21
- Types::MD5.to_parameter('437b930db84b8079c2dd804a71936b5f')
21
+ Types::MD5.serialize('437b930db84b8079c2dd804a71936b5f')
22
22
  end
23
23
 
24
- def test_from_parameter
24
+ def test_deserialize
25
25
  assert_equal '437b930db84b8079c2dd804a71936b5f',
26
- Types::MD5.from_parameter('437b930db84b8079c2dd804a71936b5f')
26
+ Types::MD5.deserialize('437b930db84b8079c2dd804a71936b5f')
27
27
  end
28
28
  end
@@ -17,13 +17,13 @@ class TagsTest < Minitest::Test
17
17
  end
18
18
  end
19
19
 
20
- def test_to_parameter
21
- assert_equal 'one', Types::Tags.to_parameter('one')
22
- assert_equal 'one two', Types::Tags.to_parameter(%w(one two))
23
- assert_equal 'padding', Types::Tags.to_parameter([' padding '])
20
+ def test_serialize
21
+ assert_equal 'one', Types::Tags.serialize('one')
22
+ assert_equal 'one two', Types::Tags.serialize(%w(one two))
23
+ assert_equal 'padding', Types::Tags.serialize([' padding '])
24
24
  end
25
25
 
26
- def test_from_parameter
27
- assert_equal %w(one two), Types::Tags.from_parameter('one two')
26
+ def test_deserialize
27
+ assert_equal %w(one two), Types::Tags.deserialize('one two')
28
28
  end
29
29
  end
@@ -12,11 +12,11 @@ class TextTest < Minitest::Test
12
12
  end
13
13
  end
14
14
 
15
- def test_to_parameter
16
- assert_equal 'text', Types::Text.to_parameter('text')
15
+ def test_serialize
16
+ assert_equal 'text', Types::Text.serialize('text')
17
17
  end
18
18
 
19
- def test_from_parameter
20
- assert_equal 'text', Types::Text.from_parameter('text')
19
+ def test_deserialize
20
+ assert_equal 'text', Types::Text.deserialize('text')
21
21
  end
22
22
  end
@@ -12,11 +12,11 @@ class TitleTest < Minitest::Test
12
12
  end
13
13
  end
14
14
 
15
- def test_to_parameter
16
- assert_equal 'title', Types::Title.to_parameter('title')
15
+ def test_serialize
16
+ assert_equal 'title', Types::Title.serialize('title')
17
17
  end
18
18
 
19
- def test_from_parameter
20
- assert_equal 'title', Types::Title.from_parameter('title')
19
+ def test_deserialize
20
+ assert_equal 'title', Types::Title.deserialize('title')
21
21
  end
22
22
  end
@@ -11,13 +11,13 @@ class URLTest < Minitest::Test
11
11
  end
12
12
  end
13
13
 
14
- def test_to_parameter
14
+ def test_serialize
15
15
  value = 'http://pinboard.in'
16
- assert_equal value, Types::URL.to_parameter(value)
16
+ assert_equal value, Types::URL.serialize(value)
17
17
  end
18
18
 
19
- def test_from_parameter
19
+ def test_deserialize
20
20
  value = 'http://pinboard.in'
21
- assert_equal value, Types::URL.from_parameter(value)
21
+ assert_equal value, Types::URL.deserialize(value)
22
22
  end
23
23
  end
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.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2015-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.7
33
+ version: 0.4.8
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.7
40
+ version: 0.4.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 5.7.0
47
+ version: 5.8.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 5.7.0
54
+ version: 5.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.4.5
159
+ rubygems_version: 2.4.8
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: The best Pinboard API client