api-client 1.8.0 → 1.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.8.1
4
+
5
+ * Fixed a Bug when response was an Array.
6
+
3
7
  ## v1.8.0
4
8
 
5
9
  * Methods to return attributes of the class added.
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # ApiClient [![Build Status](https://secure.travis-ci.org/plribeiro3000/api-client.png?branch=master)](http://travis-ci.org/plribeiro3000/api-client)
1
+ # ApiClient - Client to call Api easily.
2
2
 
3
- Client to make Api calls easily. It supports ruby 1.8.7, 1.9.2, 1.9.3, jruby and ree out of the box.
3
+ [![Build Status](https://secure.travis-ci.org/zertico/api-client.png?branch=master)](http://travis-ci.org/zertico/api-client) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/zertico/api-client)
4
+
5
+ It supports ruby 1.8.7, 1.9.2, 1.9.3, jruby and ree out of the box.
4
6
 
5
7
  ## Installation
6
8
 
@@ -71,6 +73,10 @@ This code will create a setter and a getter for houses and cars and initialize t
71
73
  * Add support for parallel requests
72
74
  * Add more Response Handlers
73
75
 
76
+ ## Mantainers
77
+ [@plribeiro3000](https://github.com/plribeiro3000)
78
+
79
+
74
80
  ## Contributing
75
81
 
76
82
  1. Fork it
@@ -114,6 +114,7 @@ module ApiClient
114
114
  def self.method_missing(method, *args)
115
115
  @response = Parser.response(Dispatcher.send(method, *args))
116
116
  case true
117
+ when @response.instance_of?(Array) then return @response.map { |a| new(a.merge(:response => @response)) }
117
118
  when @response.key?(remote_object) then return new(@response[remote_object].merge(:response => @response))
118
119
  when @response.key?(remote_object.pluralize) then return @response[remote_object.pluralize].map { |a| new(a.merge(:response => @response)) }
119
120
  else return new(@response.merge(:response => @response))
@@ -1,5 +1,5 @@
1
1
  # High Level Namespace of the library ApiClient.
2
2
  module ApiClient
3
3
  # Version of the library.
4
- VERSION = "1.8.0"
4
+ VERSION = "1.8.1"
5
5
  end
@@ -102,16 +102,28 @@ describe ApiClient::Base do
102
102
  end
103
103
 
104
104
  describe "requests" do
105
- before :each do
106
- stub_request(:any, "http://api.example.com").to_return(:body => {"a" => "b"}.to_json)
107
- end
105
+ context "with an object as response" do
106
+ before :each do
107
+ stub_request(:any, "http://api.example.com").to_return(:body => {"a" => "b"}.to_json)
108
+ end
109
+
110
+ it "should return a new instance" do
111
+ User.get("http://api.example.com").should be_an_instance_of(User)
112
+ end
108
113
 
109
- it "should return a new instance" do
110
- User.get("http://api.example.com").should be_an_instance_of(User)
114
+ it "should set the response on the instance" do
115
+ User.get("http://api.example.com").response.should == {"a" => "b"}
116
+ end
111
117
  end
112
118
 
113
- it "should set the response on the instance" do
114
- User.get("http://api.example.com").response.should == {"a" => "b"}
119
+ context "with an array as response" do
120
+ before :each do
121
+ stub_request(:any, "http://api.example.com").to_return(:body => [{"a" => "b"}].to_json)
122
+ end
123
+
124
+ it "should return an array of instances" do
125
+ User.get("http://api.example.com").should be_an_instance_of(Array)
126
+ end
115
127
  end
116
128
  end
117
129
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
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-09-18 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -167,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
167
  version: '0'
168
168
  segments:
169
169
  - 0
170
- hash: -1461231548081400078
170
+ hash: 1498468142604583220
171
171
  required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  none: false
173
173
  requirements:
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  segments:
178
178
  - 0
179
- hash: -1461231548081400078
179
+ hash: 1498468142604583220
180
180
  requirements: []
181
181
  rubyforge_project:
182
182
  rubygems_version: 1.8.24