marvel_api 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/VERSION +1 -1
- data/lib/marvel/client.rb +37 -32
- data/lib/marvel/connection.rb +2 -2
- data/marvel_api.gemspec +8 -5
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9d7479fcdd1929f6bfcb85144acf86da8e50be4
|
4
|
+
data.tar.gz: 822114459097dfb00cfea66892df24aac463c6a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f2ec4602b49b535665b5fb094e15c6a420c6aa34d5042e547308295fafccaa32451c485fd3bf6d552882a0483df3cb4a3f7e6100344328657949af8f7edcd48
|
7
|
+
data.tar.gz: 42404bc7490247d9afc2b9ef7ed54edce56efb7f4537158964681b42380e0a67ead434a61b0498fdb1fa91c35978c542475ff89b90592bd80048233aee746912
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/marvel/client.rb
CHANGED
@@ -12,8 +12,6 @@ module Marvel
|
|
12
12
|
include Marvel::Connection
|
13
13
|
include Marvel::Configuration
|
14
14
|
|
15
|
-
# BASE_URL = 'https://gateway.marvel.com/v1/public/'
|
16
|
-
|
17
15
|
def initialize
|
18
16
|
reset
|
19
17
|
end
|
@@ -25,9 +23,17 @@ module Marvel
|
|
25
23
|
# where hash is the MD5 hash of the concatenation of
|
26
24
|
# ts, your private API key, and your public API key
|
27
25
|
|
26
|
+
# So basic request form for all methods looks like
|
27
|
+
# Faraday.get("#{BASE_URL}#{path}#{id}#{stub}#{auth}").body
|
28
|
+
# e.g., get_comics_by_character_id
|
29
|
+
# Faraday.get("#{BASE_URL}characters/#{id}/comics#{auth}").body
|
30
|
+
|
28
31
|
# TODO; MODULARIZE THIS!!!
|
29
32
|
# TODO; Refactor — tons of duplication
|
30
33
|
|
34
|
+
# All methods return a Hashie::Mash object
|
35
|
+
# representation of the original JSON response
|
36
|
+
|
31
37
|
# Characters:
|
32
38
|
|
33
39
|
# fetches lists of characters
|
@@ -38,26 +44,25 @@ module Marvel
|
|
38
44
|
# fetches a single character by id
|
39
45
|
def get_character(id)
|
40
46
|
# v1/public/characters/{characterId}
|
41
|
-
|
42
|
-
# get("characters/#{id}#{auth}")
|
47
|
+
get("characters/#{id}#{auth}")
|
43
48
|
end
|
44
49
|
|
45
50
|
# fetches lists of comics filtered by a character id
|
46
51
|
def get_comics_by_character_id(id)
|
47
52
|
# v1/public/characters/{characterId}/comics
|
48
|
-
|
53
|
+
get("characters/#{id}/comics#{auth}")
|
49
54
|
end
|
50
55
|
|
51
56
|
# fetches lists of events filtered by a character id
|
52
57
|
def get_events_by_character_id(id)
|
53
58
|
# v1/public/characters/{characterId}/events
|
54
|
-
|
59
|
+
get("characters/#{id}/events#{auth}")
|
55
60
|
end
|
56
61
|
|
57
62
|
# fetches lists of stories filtered by a character id
|
58
63
|
def get_stories_by_character_id(id)
|
59
64
|
# v1/public/characters/{characterId}/stories
|
60
|
-
|
65
|
+
get("characters/#{id}/stories#{auth}")
|
61
66
|
end
|
62
67
|
|
63
68
|
# Comics:
|
@@ -70,31 +75,31 @@ module Marvel
|
|
70
75
|
# fetches a single comic by id
|
71
76
|
def get_comic(id)
|
72
77
|
# v1/public/comics/{comicId}
|
73
|
-
|
78
|
+
get("comics/#{id}#{auth}")
|
74
79
|
end
|
75
80
|
|
76
81
|
# fetches lists of characters filtered by a comic id
|
77
82
|
def get_characters_by_comic_id(id)
|
78
83
|
# v1/public/comics/{comicId}/characters
|
79
|
-
|
84
|
+
get("comics/#{id}/characters#{auth}")
|
80
85
|
end
|
81
86
|
|
82
87
|
# fetches lists of creators filtered by a comic id
|
83
88
|
def get_creators_by_comic_id(id)
|
84
89
|
# v1/public/comics/{comicId}/creators
|
85
|
-
|
90
|
+
get("comics/#{id}/creators#{auth}")
|
86
91
|
end
|
87
92
|
|
88
93
|
# fetches lists of events filtered by a comic id
|
89
94
|
def get_events_by_comic_id(id)
|
90
95
|
# v1/public/comics/{comicId}/events
|
91
|
-
|
96
|
+
get("comics/#{id}/events#{auth}")
|
92
97
|
end
|
93
98
|
|
94
99
|
# fetches lists of stories filtered by a comic id
|
95
100
|
def get_stories_by_comic_id(id)
|
96
101
|
# v1/public/comics/{comicId}/stories
|
97
|
-
|
102
|
+
get("comics/#{id}/stories#{auth}")
|
98
103
|
end
|
99
104
|
|
100
105
|
# Creators:
|
@@ -107,25 +112,25 @@ module Marvel
|
|
107
112
|
# fetches a single creator by id
|
108
113
|
def get_creator(id)
|
109
114
|
# v1/public/creators/{creatorId}
|
110
|
-
|
115
|
+
get("creators/#{id}#{auth}")
|
111
116
|
end
|
112
117
|
|
113
118
|
# fetches lists of comics filtered by a creator id
|
114
119
|
def get_comics_by_creator_id(id)
|
115
120
|
# v1/public/creators/{creatorId}/comics
|
116
|
-
|
121
|
+
get("creators/#{id}/comics#{auth}")
|
117
122
|
end
|
118
123
|
|
119
124
|
# fetches lists of events filtered by a creator id
|
120
125
|
def get_events_by_creator_id(id)
|
121
126
|
# v1/public/creators/{creatorId}/events
|
122
|
-
|
127
|
+
get("creators/#{id}/events#{auth}")
|
123
128
|
end
|
124
129
|
|
125
130
|
# fetches lists of stories filtered by a creator id
|
126
131
|
def get_stories_by_creator_id(id)
|
127
132
|
# v1/public/creators/{creatorId}/stories
|
128
|
-
|
133
|
+
get("creators/#{id}/stories#{auth}")
|
129
134
|
end
|
130
135
|
|
131
136
|
# Events:
|
@@ -138,31 +143,31 @@ module Marvel
|
|
138
143
|
# fetches a single event by id
|
139
144
|
def get_event(id)
|
140
145
|
# v1/public/events/{eventId}
|
141
|
-
|
146
|
+
get("events/#{id}#{auth}")
|
142
147
|
end
|
143
148
|
|
144
149
|
# fetches lists of characters filtered by an event id
|
145
150
|
def get_characters_by_event_id(id)
|
146
151
|
# v1/public/events/{eventId}/characters
|
147
|
-
|
152
|
+
get("events/#{id}/characters#{auth}")
|
148
153
|
end
|
149
154
|
|
150
155
|
# fetches lists of comics filtered by an event id
|
151
156
|
def get_comics_by_event_id(id)
|
152
157
|
# v1/public/events/{eventId}/comics
|
153
|
-
|
158
|
+
get("events/#{id}/comics#{auth}")
|
154
159
|
end
|
155
160
|
|
156
161
|
# fetches lists of creators filtered by an event id
|
157
162
|
def get_creators_by_event_id(id)
|
158
163
|
# v1/public/events/{eventId}/creators
|
159
|
-
|
164
|
+
get("events/#{id}/creators#{auth}")
|
160
165
|
end
|
161
166
|
|
162
167
|
# fetches lists of stories filtered by an event id
|
163
168
|
def get_stories_by_event_id(id)
|
164
169
|
# v1/public/events/{eventId}/stories
|
165
|
-
|
170
|
+
get("events/#{id}/stories#{auth}")
|
166
171
|
end
|
167
172
|
|
168
173
|
|
@@ -176,37 +181,37 @@ module Marvel
|
|
176
181
|
# fetches a single comic series by id
|
177
182
|
def get_series_by_id(id)
|
178
183
|
# v1/public/series/{seriesId}
|
179
|
-
|
184
|
+
get("series/#{id}#{auth}")
|
180
185
|
end
|
181
186
|
|
182
187
|
# fetches lists of characters filtered by a series id
|
183
188
|
def get_characters_by_series_id(id)
|
184
189
|
# v1/public/series/{seriesId}/characters
|
185
|
-
|
190
|
+
get("series/#{id}/characters#{auth}")
|
186
191
|
end
|
187
192
|
|
188
193
|
# fetches lists of comics filtered by a series id
|
189
194
|
def get_comics_by_series_id(id)
|
190
195
|
# v1/public/series/{seriesId}/comics
|
191
|
-
|
196
|
+
get("series/#{id}/comics#{auth}")
|
192
197
|
end
|
193
198
|
|
194
199
|
# fetches lists of creators filtered by a series id
|
195
200
|
def get_creators_by_series_id(id)
|
196
201
|
# v1/public/series/{seriesId}/creators
|
197
|
-
|
202
|
+
get("series/#{id}/creators#{auth}")
|
198
203
|
end
|
199
204
|
|
200
205
|
# fetches lists of events filtered by a series id
|
201
206
|
def get_events_by_series_id(id)
|
202
207
|
# v1/public/series/{seriesId}/events
|
203
|
-
|
208
|
+
get("series/#{id}/events#{auth}")
|
204
209
|
end
|
205
210
|
|
206
211
|
# fetches lists of stories filtered by a series id
|
207
212
|
def get_stories_by_series_id(id)
|
208
213
|
# v1/public/series/{seriesId}/stories
|
209
|
-
|
214
|
+
get("series/#{id}/stories#{auth}")
|
210
215
|
end
|
211
216
|
|
212
217
|
# Stories:
|
@@ -219,31 +224,31 @@ module Marvel
|
|
219
224
|
# fetches a single comic story by id
|
220
225
|
def get_story(id)
|
221
226
|
# v1/public/stories/{storyId}
|
222
|
-
|
227
|
+
get("stories/#{id}#{auth}")
|
223
228
|
end
|
224
229
|
|
225
230
|
# fetches lists of characters filtered by a story id
|
226
231
|
def get_characters_by_story_id(id)
|
227
232
|
# v1/public/stories/{storyId}/characters
|
228
|
-
|
233
|
+
get("stories/#{id}/characters#{auth}")
|
229
234
|
end
|
230
235
|
|
231
236
|
# fetches lists of comics filtered by a story id
|
232
237
|
def get_comics_by_story_id(id)
|
233
238
|
# v1/public/stories/{storyId}/comics
|
234
|
-
|
239
|
+
get("stories/#{id}/comics#{auth}")
|
235
240
|
end
|
236
241
|
|
237
242
|
# fetches lists of creators filtered by a story id
|
238
243
|
def get_creators_by_story_id(id)
|
239
244
|
# v1/public/stories/{storyId}/creators
|
240
|
-
|
245
|
+
get("stories/#{id}/creators#{auth}")
|
241
246
|
end
|
242
247
|
|
243
248
|
# fetches lists of events filtered by a story id
|
244
249
|
def get_events_by_story_id(id)
|
245
250
|
# v1/public/stories/{storyId}/events
|
246
|
-
|
251
|
+
get("stories/#{id}/events#{auth}")
|
247
252
|
end
|
248
253
|
|
249
254
|
private
|
data/lib/marvel/connection.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday_middleware'
|
2
2
|
|
3
3
|
module Marvel
|
4
4
|
module Connection
|
@@ -13,7 +13,7 @@ module Marvel
|
|
13
13
|
Faraday.new(options) do |connection|
|
14
14
|
connection.use Faraday::Request::UrlEncoded
|
15
15
|
connection.use Faraday::Response::RaiseError
|
16
|
-
connection.use Faraday::Response::
|
16
|
+
connection.use Faraday::Response::Mashify
|
17
17
|
connection.use Faraday::Response::ParseJson
|
18
18
|
connection.adapter(Faraday.default_adapter)
|
19
19
|
end
|
data/marvel_api.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: marvel_api 0.1.
|
5
|
+
# stub: marvel_api 0.1.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "marvel_api"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Rahul Hor\u{e9}"]
|
@@ -44,7 +44,8 @@ Gem::Specification.new do |s|
|
|
44
44
|
s.specification_version = 4
|
45
45
|
|
46
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_runtime_dependency(%q<faraday>, ["
|
47
|
+
s.add_runtime_dependency(%q<faraday>, ["~> 0.8.9"])
|
48
|
+
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
48
49
|
s.add_development_dependency(%q<pry>, [">= 0"])
|
49
50
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
50
51
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
@@ -53,7 +54,8 @@ Gem::Specification.new do |s|
|
|
53
54
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
54
55
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
55
56
|
else
|
56
|
-
s.add_dependency(%q<faraday>, ["
|
57
|
+
s.add_dependency(%q<faraday>, ["~> 0.8.9"])
|
58
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
57
59
|
s.add_dependency(%q<pry>, [">= 0"])
|
58
60
|
s.add_dependency(%q<rspec>, [">= 0"])
|
59
61
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
@@ -63,7 +65,8 @@ Gem::Specification.new do |s|
|
|
63
65
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
64
66
|
end
|
65
67
|
else
|
66
|
-
s.add_dependency(%q<faraday>, ["
|
68
|
+
s.add_dependency(%q<faraday>, ["~> 0.8.9"])
|
69
|
+
s.add_dependency(%q<hashie>, [">= 0"])
|
67
70
|
s.add_dependency(%q<pry>, [">= 0"])
|
68
71
|
s.add_dependency(%q<rspec>, [">= 0"])
|
69
72
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marvel_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahul Horé
|
@@ -12,6 +12,20 @@ date: 2014-02-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.9
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.9
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - '>='
|