eve_api 0.0.2 → 0.0.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/lib/eve_api.rb +2 -0
- data/lib/eve_api/crest.rb +52 -0
- data/lib/eve_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e50a6e8f3bac768008e54914ccf49a6ba998f0c
|
4
|
+
data.tar.gz: 604b3c52128f5056ca72cbd7306b3499554e51b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a69d4be8974626baea1a1528a3adfc4b0bcd9d458ef4a426595ecd492bb1b925b0747156293667d342acd8e11ad658550162e66c4438cb8bd138983b3bce114
|
7
|
+
data.tar.gz: 64713be12accb6b695de60be1dfb753deb895b4e6ebd03cf14d0ed93fc0f104c6903ea6db2c92a319add950c4819083e820629b602a3d81b8e0d7d70c0f3e1c9
|
data/lib/eve_api.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
module EveApi
|
2
|
+
class Crest
|
3
|
+
BASE_URI = "https://public-crest.eveonline.com"
|
4
|
+
|
5
|
+
attr_accessor :cache_only, :path
|
6
|
+
|
7
|
+
def initialize(path, cache_only = false)
|
8
|
+
self.path = path
|
9
|
+
self.cache_only = cache_only
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(opt = {})
|
13
|
+
splat = render(opt)
|
14
|
+
|
15
|
+
conn = Faraday.new(:url => BASE_URI) do |faraday|
|
16
|
+
faraday.request :url_encoded
|
17
|
+
faraday.adapter Faraday.default_adapter
|
18
|
+
end
|
19
|
+
|
20
|
+
response = conn.get("/#{splat.join('/')}/")
|
21
|
+
|
22
|
+
case response.status
|
23
|
+
when 200
|
24
|
+
return JSON.parse(response.body)
|
25
|
+
when 404
|
26
|
+
raise EAAL::Exception::APINotFoundError.new("The requested API (#{splat}) could not be found.")
|
27
|
+
else
|
28
|
+
raise EAAL::Exception::HTTPError.new("An HTTP Error occured, body: " + response.body)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def render(opt)
|
35
|
+
result = self.path.map do |m|
|
36
|
+
if m.is_a?(Symbol)
|
37
|
+
if !opt.has_key?(m)
|
38
|
+
raise "could not find :#{m} in argument"
|
39
|
+
end
|
40
|
+
|
41
|
+
res = opt[m].to_s
|
42
|
+
else
|
43
|
+
res = m if m.is_a?(String)
|
44
|
+
end
|
45
|
+
|
46
|
+
res
|
47
|
+
end
|
48
|
+
|
49
|
+
return result
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/eve_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eve_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Femaref
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/eve_api/api.rb
|
70
70
|
- lib/eve_api/caches/default.rb
|
71
71
|
- lib/eve_api/caches/file.rb
|
72
|
+
- lib/eve_api/crest.rb
|
72
73
|
- lib/eve_api/data.rb
|
73
74
|
- lib/eve_api/parsers/cache.rb
|
74
75
|
- lib/eve_api/parsers/default.rb
|