eve_api 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95daf8a03a495f751f104ef772fb6987e7927be1
4
- data.tar.gz: 80ea6c473276238a445b913b7967514f2eb32c44
3
+ metadata.gz: 5e50a6e8f3bac768008e54914ccf49a6ba998f0c
4
+ data.tar.gz: 604b3c52128f5056ca72cbd7306b3499554e51b5
5
5
  SHA512:
6
- metadata.gz: 9d051191993244cac24ab8e9f33e849cd35b0cc26774c7bdac43962a995b6dcdf01ef9504d9d2399923158524c595df1ce3a0d4512c48a4f938159c43eefe4ba
7
- data.tar.gz: d3c33741fae6aade10a1b4a849eac0e15633dc19f6cba4ab177f97ec6801151a9deda37e06e43514366b4c1ff363a2af846183e8abb519b94ac9c1ba221ef3b1
6
+ metadata.gz: 5a69d4be8974626baea1a1528a3adfc4b0bcd9d458ef4a426595ecd492bb1b925b0747156293667d342acd8e11ad658550162e66c4438cb8bd138983b3bce114
7
+ data.tar.gz: 64713be12accb6b695de60be1dfb753deb895b4e6ebd03cf14d0ed93fc0f104c6903ea6db2c92a319add950c4819083e820629b602a3d81b8e0d7d70c0f3e1c9
data/lib/eve_api.rb CHANGED
@@ -2,9 +2,11 @@ require 'eve_api/version'
2
2
  require 'addressable/uri'
3
3
  require 'faraday'
4
4
  require 'nokogiri'
5
+ require 'json'
5
6
 
6
7
  module EveApi
7
8
 
9
+ autoload :Crest, 'eve_api/crest.rb'
8
10
  autoload :Api, 'eve_api/api.rb'
9
11
  autoload :ScopedApi, 'eve_api/scoped_api.rb'
10
12
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EveApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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: 2013-08-31 00:00:00.000000000 Z
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