nestful 1.0.4 → 1.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.
data/README.markdown CHANGED
@@ -62,7 +62,7 @@ The `Endpoint` class provides a single object to work with restful services. The
62
62
  If you're building a binding for a REST API, then you should consider using the `Resource` class.
63
63
 
64
64
  class Charge < Nestful::Resource
65
- url 'https://api.stripe.com/v1/charges'
65
+ endpoint 'https://api.stripe.com/v1/charges'
66
66
  options :auth_type => :bearer, :password => 'sk_bar'
67
67
 
68
68
  def self.all
@@ -33,6 +33,11 @@ module Nestful
33
33
  end
34
34
 
35
35
  def self.uri(*parts)
36
+ # If an absolute URI already
37
+ if (uri = parts.first) && uri.is_a?(URI)
38
+ return uri if uri.host
39
+ end
40
+
36
41
  URI.parse(Helpers.to_path(url, *parts))
37
42
  end
38
43
 
@@ -119,7 +124,9 @@ module Nestful
119
124
  attributes.dup
120
125
  end
121
126
 
122
- alias_method :as_json, :to_hash
127
+ def as_json(*)
128
+ to_hash
129
+ end
123
130
 
124
131
  def to_json(*)
125
132
  as_json.to_json
@@ -1,3 +1,3 @@
1
1
  module Nestful
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -55,4 +55,14 @@ class TestResource < MiniTest::Unit::TestCase
55
55
  charge.get(:capture)
56
56
  assert_requested(:get, 'http://example.com/v1/tokens/1/capture?one=1')
57
57
  end
58
+
59
+ def test_absolute_uri
60
+ uri = Token.uri(URI.parse('http://example.com/v1/token'))
61
+ assert_equal uri.to_s, 'http://example.com/v1/token'
62
+ end
63
+
64
+ def test_to_json
65
+ charge = Charge.new(:amount => 1)
66
+ assert_equal charge.to_json, '{"amount":1}'
67
+ end
58
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nestful
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.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: 2013-06-01 00:00:00.000000000 Z
12
+ date: 2013-08-08 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -56,21 +56,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
56
  - - ! '>='
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
- segments:
60
- - 0
61
- hash: -3312569918476156670
62
59
  required_rubygems_version: !ruby/object:Gem::Requirement
63
60
  none: false
64
61
  requirements:
65
62
  - - ! '>='
66
63
  - !ruby/object:Gem::Version
67
64
  version: '0'
68
- segments:
69
- - 0
70
- hash: -3312569918476156670
71
65
  requirements: []
72
66
  rubyforge_project:
73
- rubygems_version: 1.8.24
67
+ rubygems_version: 1.8.25
74
68
  signing_key:
75
69
  specification_version: 3
76
70
  summary: Simple Ruby HTTP/REST client with a sane API