marvelite 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +16 -0
- data/lib/marvelite/api/client.rb +1 -8
- data/lib/marvelite/api/response.rb +18 -0
- data/lib/marvelite/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faa7a107bdb9bf78772cbfeeb23682c7a31571bd
|
4
|
+
data.tar.gz: 2c183a0ee440da0e4f9a5ea0a97a2aa386c2a94d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce9f5eae4795d770a9106443fa38bcf24a26a3a46f8ed2075ddfe1325cab8fdc6c3689fd87bc94723b846ca8e59a6e265a4a80c44f51e6693a77aecb78aa972d
|
7
|
+
data.tar.gz: e740a5008b0b3867a2c5987c5ca153f4ff065fe749854d3179a97a4938064f13025b097054ba3b7b3d0d78133e7bcb40c729f24220cb02c5864a4baa19596584
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### 0.1.2
|
4
|
+
* Adds `#raw_response` to store the original response from the API inside
|
5
|
+
a `Marvelite::API::Response` instance. Author: [Jon Allured](https://github.com/jonallured)
|
6
|
+
|
3
7
|
### 0.1.1
|
4
8
|
* Gzipped responses are enabled by default.
|
5
9
|
* All API requests include `{ 'Accept-Encoding' = 'gzip' }` which translates
|
data/README.md
CHANGED
@@ -128,6 +128,22 @@ response.data
|
|
128
128
|
response.data[:results]
|
129
129
|
```
|
130
130
|
|
131
|
+
You can always access the raw response returned by the API by calling the
|
132
|
+
`#raw_response` attribute of the response. Example:
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
hero = client.character(1009610)
|
136
|
+
hero.raw_response
|
137
|
+
#=> { "code"=>200, "status"=>"Ok", "copyright"=>"© 2014 MARVEL", ... }
|
138
|
+
```
|
139
|
+
Difference between `response` and `raw_reponse`, is that `raw_response` does
|
140
|
+
not include `Hashie` helpers, and thus you need to navigate it as a plain old
|
141
|
+
Hash.
|
142
|
+
```ruby
|
143
|
+
hero.raw_response['data'][0]['name']
|
144
|
+
#=> "Spider-Man"
|
145
|
+
```
|
146
|
+
|
131
147
|
## Etags and Gzip support
|
132
148
|
|
133
149
|
Support for Etags is built into every endpoint:
|
data/lib/marvelite/api/client.rb
CHANGED
@@ -40,14 +40,7 @@ module Marvelite
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def build_response_object(response)
|
43
|
-
|
44
|
-
when 200
|
45
|
-
Response.new(response)
|
46
|
-
when 304
|
47
|
-
NotModifiedResponse.new(response)
|
48
|
-
else
|
49
|
-
ErrorResponse.new(response)
|
50
|
-
end
|
43
|
+
Response.make(response)
|
51
44
|
end
|
52
45
|
|
53
46
|
def find_by_name_or_title(endpoint, column, value)
|
@@ -5,6 +5,24 @@ module Marvelite
|
|
5
5
|
include Hashie::Extensions::KeyConversion
|
6
6
|
include Hashie::Extensions::MethodAccess
|
7
7
|
include Hashie::Extensions::IndifferentAccess
|
8
|
+
|
9
|
+
attr_reader :raw_response
|
10
|
+
|
11
|
+
def self.make(response)
|
12
|
+
case response.code
|
13
|
+
when 200
|
14
|
+
Response.new(response)
|
15
|
+
when 304
|
16
|
+
NotModifiedResponse.new(response)
|
17
|
+
else
|
18
|
+
ErrorResponse.new(response)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(raw)
|
23
|
+
@raw_response = raw
|
24
|
+
super(raw)
|
25
|
+
end
|
8
26
|
end
|
9
27
|
|
10
28
|
class ErrorResponse < Response; end
|
data/lib/marvelite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marvelite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antonio Antillon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|