restfully 0.5.0 → 0.5.1
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/VERSION +1 -1
- data/lib/restfully.rb +1 -1
- data/lib/restfully/resource.rb +7 -8
- data/restfully.gemspec +2 -2
- data/spec/resource_spec.rb +14 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/lib/restfully.rb
CHANGED
data/lib/restfully/resource.rb
CHANGED
@@ -76,14 +76,13 @@ module Restfully
|
|
76
76
|
# you may pass it so that the GET request is not triggered.
|
77
77
|
def load(options = {})
|
78
78
|
options = options.symbolize_keys
|
79
|
-
force_reload = !!options.delete(:reload)
|
80
|
-
|
81
|
-
|
82
|
-
else
|
79
|
+
force_reload = !!options.delete(:reload)
|
80
|
+
stale! unless (request = executed_requests['GET']) && request['options'] == options && request['body']
|
81
|
+
if stale?
|
83
82
|
reset
|
84
|
-
if options[:body]
|
83
|
+
if !force_reload && options[:body]
|
85
84
|
body = options[:body]
|
86
|
-
headers =
|
85
|
+
headers = {}
|
87
86
|
else
|
88
87
|
response = session.get(uri, options)
|
89
88
|
body = response.body
|
@@ -98,8 +97,8 @@ module Restfully
|
|
98
97
|
populate_object(key, value)
|
99
98
|
end
|
100
99
|
@status = :loaded
|
101
|
-
self
|
102
100
|
end
|
101
|
+
self
|
103
102
|
end
|
104
103
|
|
105
104
|
# == Description
|
@@ -143,6 +142,7 @@ module Restfully
|
|
143
142
|
|
144
143
|
def reload
|
145
144
|
current_options = executed_requests['GET']['options'] rescue {}
|
145
|
+
stale!
|
146
146
|
self.load(current_options.merge(:reload => true))
|
147
147
|
end
|
148
148
|
|
@@ -232,7 +232,6 @@ module Restfully
|
|
232
232
|
session.logger.warn link.errors.join("\n")
|
233
233
|
end
|
234
234
|
end
|
235
|
-
|
236
235
|
|
237
236
|
end # class Resource
|
238
237
|
end # module Restfully
|
data/restfully.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{restfully}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Cyril Rohr"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-09}
|
13
13
|
s.default_executable = %q{restfully}
|
14
14
|
s.description = %q{Experimental code for auto-generation of wrappers on top of RESTful APIs that follow HATEOAS principles and provide OPTIONS methods and/or Allow headers.}
|
15
15
|
s.email = %q{cyril.rohr@gmail.com}
|
data/spec/resource_spec.rb
CHANGED
@@ -21,9 +21,15 @@ describe Resource do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
describe "reloading" do
|
25
|
+
it "should reload the resource" do
|
26
|
+
resource = Resource.new(@uri, mock('session'))
|
27
|
+
resource.should_receive(:load).with(:reload => true)
|
28
|
+
resource.reload
|
29
|
+
end
|
30
|
+
end
|
24
31
|
|
25
32
|
describe "loading" do
|
26
|
-
|
27
33
|
before do
|
28
34
|
@raw = {
|
29
35
|
'links' => [
|
@@ -69,6 +75,7 @@ describe Resource do
|
|
69
75
|
}
|
70
76
|
@response_200 = Restfully::HTTP::Response.new(200, {'Content-Type' => 'application/json;utf-8', 'Content-Length' => @raw.length}, @raw.to_json)
|
71
77
|
end
|
78
|
+
|
72
79
|
it "should not be loaded in its initial state" do
|
73
80
|
resource = Resource.new(@uri, mock('session'))
|
74
81
|
resource.executed_requests.should == {}
|
@@ -169,6 +176,12 @@ describe Resource do
|
|
169
176
|
resource.load
|
170
177
|
resource.links.keys.should =~ ['versions', 'clusters', 'environments', 'status', 'parent', 'version']
|
171
178
|
end
|
179
|
+
|
180
|
+
it "should reload the resource if user forces reload" do
|
181
|
+
resource = Resource.new(@uri, session = mock("session"))
|
182
|
+
session.should_receive(:get).and_return(response = mock("response", :headers => {}, :body => {}))
|
183
|
+
resource.load(:reload => true, :body => mock("body"))
|
184
|
+
end
|
172
185
|
end
|
173
186
|
|
174
187
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restfully
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Rohr
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-09 00:00:00 +01:00
|
13
13
|
default_executable: restfully
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|