restfully 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/Rakefile +3 -0
- data/VERSION +1 -1
- data/lib/restfully.rb +1 -1
- data/lib/restfully/parsing.rb +1 -0
- data/restfully.gemspec +10 -1
- data/spec/session_spec.rb +6 -1
- data/spec/spec_helper.rb +3 -0
- metadata +31 -1
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.5.5
|
2
|
+
* raise an error if Content-Type of the response is nil or empty
|
3
|
+
* start to use webmock for better tests
|
4
|
+
|
5
|
+
0.5.4
|
6
|
+
* refactored Restfully::Parsing module. Allow to define its own parsers for specific content types
|
7
|
+
* automatically load root resource when calling session.root
|
8
|
+
|
1
9
|
0.5.3
|
2
10
|
* can handle text/* content, useful when using low-level methods on a session object (session.{get,post,delete,put})
|
3
11
|
* can now find a collection item using collection[:symbol] even if item uid is an integer: collection[:'12345']
|
data/Rakefile
CHANGED
@@ -12,6 +12,9 @@ begin
|
|
12
12
|
gem.authors = ["Cyril Rohr"]
|
13
13
|
gem.add_dependency "rest-client", '>= 1.3'
|
14
14
|
gem.add_dependency "backports"
|
15
|
+
gem.add_development_dependency "webmock"
|
16
|
+
gem.add_development_dependency "rspec"
|
17
|
+
gem.add_development_dependency "json"
|
15
18
|
gem.rubyforge_project = 'restfully'
|
16
19
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
20
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.5
|
data/lib/restfully.rb
CHANGED
data/lib/restfully/parsing.rb
CHANGED
@@ -54,6 +54,7 @@ module Restfully
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def select_parser_for(content_type)
|
57
|
+
raise ParserNotFound.new("The Content-Type HTTP header of the resource is empty. Cannot find a parser.") if content_type.nil? || content_type.empty?
|
57
58
|
content_type.split(",").each do |type|
|
58
59
|
parser = PARSERS.find{|parser| parser[:supported_types].find{|supported_type| type =~ (supported_type.kind_of?(String) ? Regexp.new(supported_type) : supported_type) }}
|
59
60
|
return parser unless parser.nil?
|
data/restfully.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
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.5"
|
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"]
|
@@ -93,13 +93,22 @@ Gem::Specification.new do |s|
|
|
93
93
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
94
94
|
s.add_runtime_dependency(%q<rest-client>, [">= 1.3"])
|
95
95
|
s.add_runtime_dependency(%q<backports>, [">= 0"])
|
96
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
97
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
98
|
+
s.add_development_dependency(%q<json>, [">= 0"])
|
96
99
|
else
|
97
100
|
s.add_dependency(%q<rest-client>, [">= 1.3"])
|
98
101
|
s.add_dependency(%q<backports>, [">= 0"])
|
102
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
103
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
104
|
+
s.add_dependency(%q<json>, [">= 0"])
|
99
105
|
end
|
100
106
|
else
|
101
107
|
s.add_dependency(%q<rest-client>, [">= 1.3"])
|
102
108
|
s.add_dependency(%q<backports>, [">= 0"])
|
109
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
110
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
111
|
+
s.add_dependency(%q<json>, [">= 0"])
|
103
112
|
end
|
104
113
|
end
|
105
114
|
|
data/spec/session_spec.rb
CHANGED
@@ -57,6 +57,11 @@ describe Session do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should initialize the root resource" do
|
60
|
+
stub_request(:get, "https://api.grid5000.fr/grid5000").to_return(
|
61
|
+
:status => 200,
|
62
|
+
:body => {"property1" => "value1"}.to_json,
|
63
|
+
:headers => {'Content-Type' => 'text/plain', 'Content-Length' => 4}
|
64
|
+
)
|
60
65
|
session = Session.new(:base_uri => 'https://api.grid5000.fr/grid5000', :user => 'crohr', :password => 'password')
|
61
66
|
session.root.should be_a Restfully::Resource
|
62
67
|
session.root.uri.to_s.should == 'https://api.grid5000.fr/grid5000'
|
@@ -65,7 +70,7 @@ describe Session do
|
|
65
70
|
|
66
71
|
it "should yield the loaded root resource and the session object" do
|
67
72
|
Restfully::Resource.stub!(:new).and_return(root_resource = mock(Restfully::Resource))
|
68
|
-
root_resource.should_receive(:load).and_return(root_resource)
|
73
|
+
root_resource.should_receive(:load).at_least(1).and_return(root_resource)
|
69
74
|
Session.new(:base_uri => 'https://api.grid5000.fr', :user => 'crohr', :password => 'password') do |root, session|
|
70
75
|
session.root.should == root
|
71
76
|
root.should == root_resource
|
data/spec/spec_helper.rb
CHANGED
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Rohr
|
@@ -32,6 +32,36 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: "0"
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: webmock
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
35
65
|
description: Experimental code for auto-generation of wrappers on top of RESTful APIs that follow HATEOAS principles and provide OPTIONS methods and/or Allow headers.
|
36
66
|
email: cyril.rohr@gmail.com
|
37
67
|
executables:
|