uatu-marvel 0.0.1.1 → 0.0.2
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/README.md +1 -1
- data/lib/uatu.rb +0 -2
- data/lib/uatu/connection.rb +7 -12
- data/lib/uatu/resource.rb +14 -30
- data/lib/uatu/response.rb +1 -1
- data/lib/uatu/version.rb +1 -1
- data/uatu.gemspec +1 -2
- metadata +2 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 330a8356b2d7b0966db9894575503533baaaeeb2
|
|
4
|
+
data.tar.gz: b1d0e32f6c552458b8e2ee146d071ae28e43cba0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 497fed44e916e0f6527ac0786e1bdb6b5ba7c4c58c0510f3c31323f689f116da0dc7dc1e4336f260342dbe9624a8c60e019046fa8ecbeb0d507817eb71734b65
|
|
7
|
+
data.tar.gz: 37f432df0a3fe7ceba0d92fd44e5ab4d7487c7006c91b113a91aa0c30bda9a0b0e786c4bddcda7359aa29f8d58a884318db731e35ea7e53b5f29e246f0bc3e73
|
data/README.md
CHANGED
|
@@ -23,7 +23,7 @@ And then execute:
|
|
|
23
23
|
```ruby
|
|
24
24
|
require 'uatu'
|
|
25
25
|
|
|
26
|
-
# You can also have them in your env
|
|
26
|
+
# You can also have them in your env => ENV["MARVEL_PUBLIC_KEY"] - ENV["MARVEL_PRIVATE_KEY"]
|
|
27
27
|
Uatu.configure do |config|
|
|
28
28
|
config.public_key = 'your_api_key'
|
|
29
29
|
config.private_key = 'your_private_api_key'
|
data/lib/uatu.rb
CHANGED
data/lib/uatu/connection.rb
CHANGED
|
@@ -42,7 +42,7 @@ module Uatu
|
|
|
42
42
|
_options = options.reject{|key, value| key.to_s.match(/.*_id/)}
|
|
43
43
|
|
|
44
44
|
# We change the names, so 'format_type' becomes 'formatType'
|
|
45
|
-
_options.each{|key, value| valid_opts[
|
|
45
|
+
_options.each{|key, value| valid_opts[key.to_s.camelize(:lower).to_sym] = value }
|
|
46
46
|
|
|
47
47
|
# An array should become a string with comma separated values
|
|
48
48
|
valid_opts.each{|key, value| valid_opts[key] = value.join(',') if value.is_a?(Array) }
|
|
@@ -50,21 +50,17 @@ module Uatu
|
|
|
50
50
|
valid_opts
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
unrubified_key_array[1..-1].each(&:capitalize!)
|
|
57
|
-
unrubified_key_array.join.to_sym
|
|
58
|
-
end
|
|
59
|
-
|
|
53
|
+
# character => characters
|
|
54
|
+
# characters => characters
|
|
55
|
+
# character_comics => characters
|
|
60
56
|
def valid_method(method)
|
|
61
57
|
_method = method.split('_').first.pluralize
|
|
62
|
-
raise 'InvalidMethod' unless
|
|
58
|
+
raise Uatu::Error.new('InvalidMethod') unless Uatu::Base::RESOURCES.map(&:pluralize).include?(_method)
|
|
63
59
|
_method
|
|
64
60
|
end
|
|
65
61
|
|
|
66
62
|
def current_timestamp
|
|
67
|
-
DateTime.now.to_s
|
|
63
|
+
@ts ||= DateTime.now.to_s
|
|
68
64
|
end
|
|
69
65
|
|
|
70
66
|
def hash(timestamp, conn_options)
|
|
@@ -72,8 +68,7 @@ module Uatu
|
|
|
72
68
|
end
|
|
73
69
|
|
|
74
70
|
def mandatory_params(conn_options)
|
|
75
|
-
ts
|
|
76
|
-
{apikey: conn_options.public_key, ts: ts, hash: hash(ts, conn_options)}
|
|
71
|
+
{apikey: conn_options.public_key, ts: current_timestamp, hash: hash(current_timestamp, conn_options)}
|
|
77
72
|
end
|
|
78
73
|
|
|
79
74
|
end
|
data/lib/uatu/resource.rb
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
module Uatu
|
|
2
2
|
class Resource < OpenStruct
|
|
3
3
|
|
|
4
|
-
def initialize(
|
|
5
|
-
super(
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def improve_hash(original_hash)
|
|
9
|
-
output_hash = underscore_keys(original_hash)
|
|
10
|
-
output_hash = add_shortcuts(output_hash)
|
|
11
|
-
output_hash = mashify(output_hash)
|
|
12
|
-
output_hash
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# We change the hasehs to mashes (Hashie::Mash) so it's easier to manipulate
|
|
16
|
-
def mashify(hash)
|
|
17
|
-
_hash = {}
|
|
18
|
-
hash.each do |k,v|
|
|
19
|
-
_hash[k] = if v.is_a?(Hash)
|
|
20
|
-
Hashie::Mash.new(v)
|
|
21
|
-
else
|
|
22
|
-
v
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
_hash
|
|
4
|
+
def initialize(original_hash)
|
|
5
|
+
super(improve_values(underscore_keys(original_hash)))
|
|
26
6
|
end
|
|
27
7
|
|
|
28
8
|
# Underscore names of the Hash. I mean... this is Ruby, right?.
|
|
@@ -40,16 +20,20 @@ module Uatu
|
|
|
40
20
|
_hash
|
|
41
21
|
end
|
|
42
22
|
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
23
|
+
# We change the hashes to mashes (Hashie::Mash) so it's easier to manipulate
|
|
24
|
+
# The 'thumbnail' hash drives me crazy, we convert it to a single value.
|
|
25
|
+
def improve_values(hash)
|
|
26
|
+
_hash = {}
|
|
27
|
+
hash.each do |k,v|
|
|
28
|
+
_hash[k] = if k.to_s=='thumbnail'
|
|
29
|
+
[v['path'],v['extension']].join('.')
|
|
30
|
+
elsif v.is_a?(Hash)
|
|
31
|
+
Hashie::Mash.new(v)
|
|
32
|
+
else
|
|
33
|
+
v
|
|
50
34
|
end
|
|
51
35
|
end
|
|
52
|
-
|
|
36
|
+
_hash
|
|
53
37
|
end
|
|
54
38
|
|
|
55
39
|
end
|
data/lib/uatu/response.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Uatu
|
|
|
16
16
|
message = parsed_body['message'] || parsed_body['status']
|
|
17
17
|
|
|
18
18
|
unless code.to_i == 200
|
|
19
|
-
raise Uatu::Error::ClientError.new "#{code}
|
|
19
|
+
raise Uatu::Error::ClientError.new "- Error code: #{code}\n- Message: #{message}\n ", {body: body, headers: headers}
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
end
|
data/lib/uatu/version.rb
CHANGED
data/uatu.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.authors = ["Víctor Martín"]
|
|
10
10
|
spec.email = ["victor.martin84@gmail.com"]
|
|
11
11
|
spec.summary = %q{Marvel API Wrapper}
|
|
12
|
-
spec.description = %q{Marvel API Wrapper for Ruby.}
|
|
12
|
+
spec.description = %q{Lightweight Marvel API Wrapper for Ruby.}
|
|
13
13
|
spec.homepage = "https://github.com/eltercero/uatu"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
@@ -27,6 +27,5 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.add_development_dependency 'minitest', '~>5.2'
|
|
28
28
|
spec.add_development_dependency 'json', '~>1.8'
|
|
29
29
|
spec.add_development_dependency 'hashie', '~>2.0'
|
|
30
|
-
spec.add_development_dependency 'pry', '~>0.9'
|
|
31
30
|
spec.add_development_dependency 'activesupport', '~>3.2'
|
|
32
31
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uatu-marvel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Víctor Martín
|
|
@@ -94,20 +94,6 @@ dependencies:
|
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '2.0'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: pry
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - "~>"
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0.9'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - "~>"
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0.9'
|
|
111
97
|
- !ruby/object:Gem::Dependency
|
|
112
98
|
name: activesupport
|
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -122,7 +108,7 @@ dependencies:
|
|
|
122
108
|
- - "~>"
|
|
123
109
|
- !ruby/object:Gem::Version
|
|
124
110
|
version: '3.2'
|
|
125
|
-
description: Marvel API Wrapper for Ruby.
|
|
111
|
+
description: Lightweight Marvel API Wrapper for Ruby.
|
|
126
112
|
email:
|
|
127
113
|
- victor.martin84@gmail.com
|
|
128
114
|
executables: []
|