pinboard_rb 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  module Pinboard
2
2
  class InvalidCredentialsError < StandardError; end
3
3
  class TooManyRequestsError < StandardError; end
4
+ class UnableToRenderURIError < StandardError; end
4
5
  end
@@ -4,13 +4,17 @@ module Pinboard
4
4
  class Request
5
5
  include HTTParty
6
6
 
7
+ CALLS_WHITELIST = %w(posts update add delete get dates recent all suggest tags rename user secret params)
8
+
7
9
  def initialize(username, password)
8
10
  self.class.basic_auth username, password
11
+ @calls = []
9
12
  end
10
13
 
11
14
  def req
12
- @params ||= { }
13
- @params.merge({ :format => 'json' })
15
+ raise UnableToRenderURIError if @calls.empty?
16
+
17
+ parse_params
14
18
 
15
19
  path = @calls.join('/')
16
20
  @calls = []
@@ -30,9 +34,7 @@ module Pinboard
30
34
 
31
35
  private
32
36
  def method_missing(name, *args, &block)
33
- @calls ||= []
34
-
35
- return self if name == :clear || name == :req
37
+ return self if CALLS_WHITELIST.include?(name.to_s) == false
36
38
 
37
39
  if name != :params
38
40
  @calls.push(name)
@@ -43,6 +45,11 @@ module Pinboard
43
45
  self
44
46
  end
45
47
 
48
+ def parse_params
49
+ @params ||= { }
50
+ @params.merge({ :format => 'json' })
51
+ end
52
+
46
53
  def process_response_code(response_code)
47
54
  case response_code
48
55
  when '401'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinboard_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-25 00:00:00.000000000 Z
12
+ date: 2012-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec