eoat 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/.yardopts +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +361 -0
- data/Rakefile +9 -0
- data/eoat.gemspec +37 -0
- data/lib/eoat.rb +80 -0
- data/lib/eoat/cache/file_cache.rb +109 -0
- data/lib/eoat/cache/memcached_cache.rb +54 -0
- data/lib/eoat/cache/none_cache.rb +36 -0
- data/lib/eoat/cache/redis_cache.rb +61 -0
- data/lib/eoat/eve_api.rb +49 -0
- data/lib/eoat/exception.rb +63 -0
- data/lib/eoat/request.rb +82 -0
- data/lib/eoat/result/eve_type.rb +163 -0
- data/lib/eoat/version.rb +4 -0
- data/lib/eoat/zk_api.rb +33 -0
- data/spec/eoat/eve_api_spec.rb +80 -0
- data/spec/eoat/eve_result_spec.rb +127 -0
- data/spec/eoat/file_cache_spec.rb +29 -0
- data/spec/eoat/memcached_cache_spec.rb +14 -0
- data/spec/eoat/redis_cache_spec.rb +14 -0
- data/spec/eoat/zk_api_spec.rb +55 -0
- data/spec/eoat_spec.rb +39 -0
- data/spec/fixtures/eve/account/APIKeyInfo.xml.aspx +13 -0
- data/spec/fixtures/eve/corp/KillLog.xml.aspx +6 -0
- data/spec/fixtures/eve/eve/CertificateTree.xml.aspx +3846 -0
- data/spec/fixtures/eve/eve/CharacterInfo.xml.aspx +24 -0
- data/spec/fixtures/eve/eve/CharacterName.xml.aspx +11 -0
- data/spec/fixtures/eve/eve/ErrorList.xml.aspx +91 -0
- data/spec/fixtures/eve/eve/FacWarStats.xml.aspx +31 -0
- data/spec/fixtures/eve/eve/FacWarTopStats.xml.aspx +733 -0
- data/spec/fixtures/eve/server/ServerStatus.xml.aspx +9 -0
- data/spec/fixtures/zkillboard/api-kills-allianceID-99002003-limit-5-xml +1 -0
- data/spec/fixtures/zkillboard/api-kills-solo-xml +1 -0
- data/spec/spec_helper.rb +86 -0
- metadata +259 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb299a1e63f9fbfeb1d14973543051a7d29a9d78
|
4
|
+
data.tar.gz: 49356a6cdf04d1a1869978fa7ab6a2c1113d0efd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 08f5cc071c753a44048c7ddb7fae84b618fd9356c3c895b7b1e9edc6360bcd887e6cdff6e3ddcde878c778eb7aefd6173648d561385c55c4dc697374bdad5b95
|
7
|
+
data.tar.gz: f165d361a4e3dc3bf37cbc8fa331ece1a34334cbde8fcf7c92e5e3cd493560ab1d07d03c36f4f96f45a1e142e1eef19ec91f864d4f67a095607500e93316ea1f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ivan Kotov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,361 @@
|
|
1
|
+
# EOAT
|
2
|
+
|
3
|
+
**EVE Online API Toolbox** a single tool to access the API of a variety resources for the EVE Online.
|
4
|
+
|
5
|
+
### Support of:
|
6
|
+
|
7
|
+
* [EVE API](https://wiki.eveonline.com/en/wiki/EVE_API_Functions)
|
8
|
+
* [ZKilloard API](https://zkillboard.com/information/api/)
|
9
|
+
|
10
|
+
## Requirements
|
11
|
+
|
12
|
+
* Ruby 2.0.0
|
13
|
+
* httparty
|
14
|
+
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
gem 'eoat'
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install eoat
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
### Fast links
|
33
|
+
|
34
|
+
* [EVE API](#eve-api)
|
35
|
+
* [Requests without authorization](#requests-without-authorization)
|
36
|
+
* [Authorized requests](#authorized-requests)
|
37
|
+
* [ZKillboard API](#zkillboard-api)
|
38
|
+
* [Examples](#examples)
|
39
|
+
* [Response errors](#response-errors)
|
40
|
+
* [Caching](#caching)
|
41
|
+
* [File](#file)
|
42
|
+
* [Memcached](#memcached)
|
43
|
+
* [Redis](#redis)
|
44
|
+
* [Additional options](#additional-options)
|
45
|
+
* [Data checking](#data-checking)
|
46
|
+
* [Additional request parameters](#additional-request-parameters)
|
47
|
+
|
48
|
+
### EVE API
|
49
|
+
|
50
|
+
Use `EOAT::EveApi` class to retrieve data from the EVE API.
|
51
|
+
|
52
|
+
#### Requests without authorization
|
53
|
+
|
54
|
+
Example, get [skill tree](https://api.eveonline.com/eve/SkillTree.xml.aspx)
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require 'eoat'
|
58
|
+
skill_tree = EOAT::EveApi.new.SkillTree
|
59
|
+
skill_tree.result # EOAT::Result::EveType::Result class instance
|
60
|
+
=> ["skillGroups"]
|
61
|
+
skill_tree.skillGroups # EOAT::Result::EveType::RowSet class instance
|
62
|
+
skill_tree.skillGroups.columns
|
63
|
+
=> ["groupName", "groupID"]
|
64
|
+
skill_tree.skillGroups.key
|
65
|
+
=> "groupID"
|
66
|
+
skill_tree.skillGroups.entries # Array class instance
|
67
|
+
group = skill_tree.skillGroups.get 1241 # EOAT::Result::EveType::Row class instance or
|
68
|
+
group = skill_tree.skillGroups.entries.first
|
69
|
+
group.groupID
|
70
|
+
=> "1241"
|
71
|
+
group.groupName
|
72
|
+
=> "Planet Management"
|
73
|
+
group.skills # EOAT::Result::EveType::RowSet class instance
|
74
|
+
group.skills.key
|
75
|
+
=> "typeID"
|
76
|
+
group.skills.columns
|
77
|
+
=> ["typeName", "groupID", "typeID", "published"]
|
78
|
+
group.skills.get(2403).typeName
|
79
|
+
=> "Advanced Planetology"
|
80
|
+
group.skills.entries.each { |skill| puts skill.typeName }
|
81
|
+
Advanced Planetology
|
82
|
+
Planetology
|
83
|
+
Interplanetary Consolidation
|
84
|
+
Command Center Upgrades
|
85
|
+
```
|
86
|
+
|
87
|
+
Example, get [server status](https://api.eveonline.com/server/ServerStatus.xml.aspx/)
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
api = EOAT::EveApi.new(:scope => 'server')
|
91
|
+
server_status = api.ServerStatus
|
92
|
+
server_status.result
|
93
|
+
=> ["serverOpen", "onlinePlayers"]
|
94
|
+
server_status.serverOpen # String
|
95
|
+
=> "True"
|
96
|
+
server_status.onlinePlayers # String
|
97
|
+
=> "6361"
|
98
|
+
```
|
99
|
+
|
100
|
+
Example, get [character info for characterID=208974814](https://api.eveonline.com/eve/CharacterInfo.xml.aspx?characterID=208974814)
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
api = EOAT::EveApi.new
|
104
|
+
char_info = api.CharacterInfo(characterID: 208974814)
|
105
|
+
char_info.result
|
106
|
+
=> ["characterID", "characterName", "race", "bloodline", "corporationID", "corporation", ...]
|
107
|
+
char_info.characterName # String
|
108
|
+
=> "Evor Endo"
|
109
|
+
char_info.corporation # String
|
110
|
+
=> "NeoCorteX Industry"
|
111
|
+
char_info.employmentHistory # EOAT::Result::EveType::RowSet class instance
|
112
|
+
char_info.employmentHistory.entries.last # EOAT::Result::EveType::Row class instance
|
113
|
+
```
|
114
|
+
|
115
|
+
Example, get [factional warfare top stats](https://api.eveonline.com/eve/FacWarTopStats.xml.aspx)
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
fw_stats = EOAT::EveApi.new.FacWarTopStats
|
119
|
+
fw_stats.result
|
120
|
+
=> ["characters", "corporations", "factions"]
|
121
|
+
fw_stats.characters # EOAT::Result::EveType::Row class instance
|
122
|
+
fw_stats.characters.KillsYesterday # EOAT::Result::EveType::RowSet class instance
|
123
|
+
fw_stats.characters.KillsYesterday.key
|
124
|
+
=> "characterID"
|
125
|
+
fw_stats.characters.KillsYesterday.columns
|
126
|
+
=> ["characterID", "characterName", "kills"]
|
127
|
+
fw_stats.characters.KillsYesterday.entries.first # EOAT::Result::EveType::Row class instance
|
128
|
+
fw_stats.characters.KillsYesterday.entries.first.characterName
|
129
|
+
=> "trigger99"
|
130
|
+
```
|
131
|
+
|
132
|
+
#### Authorized requests
|
133
|
+
|
134
|
+
Example, get [API key info](https://wiki.eveonline.com/en/wiki/EVE_API_Account_APIKeyInfo)
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
key_info = EOAT::EveApi.new(keyID, 'vCode', scope: 'account').APIKeyInfo
|
138
|
+
key_info.result
|
139
|
+
=> ["key"]
|
140
|
+
key_info.key # EOAT::Result::EveType::Row class instance
|
141
|
+
key_info.key.expires
|
142
|
+
=> ""
|
143
|
+
key_info.key.characters # EOAT::Result::EveType::RowSet class instance
|
144
|
+
key_info.key.characters.key
|
145
|
+
=> "characterID"
|
146
|
+
key_info.key.characters.columns
|
147
|
+
=> ["characterID", "characterName", "corporationID", "corporationName"]
|
148
|
+
key_info.key.characters.get(208974814).characterName
|
149
|
+
=> "Evor Endo"
|
150
|
+
```
|
151
|
+
|
152
|
+
Example, get [members tracking](https://wiki.eveonline.com/en/wiki/EVE_API_Corporation_Member_Tracking)
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
api = EOAT::EveApi.new(keyID, 'vCode', :scope => 'corp')
|
156
|
+
tracking = api.MemberTracking(extended: true)
|
157
|
+
tracking.result
|
158
|
+
=> ["members"]
|
159
|
+
member = tracking.members.get(208974814)
|
160
|
+
member.name
|
161
|
+
=> "Evor Endo"
|
162
|
+
```
|
163
|
+
|
164
|
+
### ZKillboard API
|
165
|
+
|
166
|
+
Use `EOAT::ZKApi` class to retrieve data from the EVE API.
|
167
|
+
|
168
|
+
#### Examples
|
169
|
+
|
170
|
+
Get latest solo kill ([url](http://zkillboard.com/api/solo/xml))
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
require 'eoat'
|
174
|
+
solo = EOAT::ZKApi.new.solo
|
175
|
+
solo.result
|
176
|
+
=> ["kills"]
|
177
|
+
solo.kills.entries.size
|
178
|
+
=> 200
|
179
|
+
solo.kills.entries.first.killID
|
180
|
+
=> "33070118"
|
181
|
+
solo.kills.entries.first.victim.characterName
|
182
|
+
=> "Glorfinda Elundario"
|
183
|
+
```
|
184
|
+
|
185
|
+
or only 10 records ([url](http://zkillboard.com/api/solo/limit/10/xml))
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
solo = EOAT::ZKApi.new.solo(:limit => 10)
|
189
|
+
solo.kills.entries.size
|
190
|
+
=> 10
|
191
|
+
```
|
192
|
+
|
193
|
+
Get the last 50 kill of a alliance No Value with no items and api verified ([url](http://zkillboard.com/api/kills/no-items/api-only/alliance/99002003/limit/50/xml)).
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
result = EOAT::ZKApi.new('no-items', 'api-only').kills(allianceID: 99002003, limit: 50)
|
197
|
+
result.kills.entries.size
|
198
|
+
=> 50
|
199
|
+
```
|
200
|
+
|
201
|
+
### Response errors
|
202
|
+
|
203
|
+
All specific errors for gem are described in the module `EOAT::Exception`. Three of these will be described in detail.
|
204
|
+
|
205
|
+
<dl>
|
206
|
+
<dt><b>HTTP404Error</b></dt>
|
207
|
+
<dd>The error occurs when the response comes back with code 404.</dd>
|
208
|
+
<dt><b>HTTPError</b></dt>
|
209
|
+
<dd>
|
210
|
+
The error occurs when the response comes back with a code other than 200 and 404.
|
211
|
+
To get the error code and response headers, use methods <code>status</code> and <code>headers</code>
|
212
|
+
</dd>
|
213
|
+
<dt><b>EveApiError</b></dt>
|
214
|
+
<dd>
|
215
|
+
The error occurs when EVE API returns the custom XML error.
|
216
|
+
To determine the number of error, use the method <code>number</code>
|
217
|
+
For a complete list of errors can be found
|
218
|
+
<a href="https://api.eveonline.com/eve/ErrorList.xml.aspx" target="_blank">here</a>.
|
219
|
+
</dd>
|
220
|
+
</dl>
|
221
|
+
|
222
|
+
Example `EOAT::Exception::HTTP404Error`
|
223
|
+
|
224
|
+
```ruby
|
225
|
+
EOAT::EveApi.new.foo
|
226
|
+
EOAT::Exception::HTTP404Error: Request url path '/eve/foo.xml.aspx' not found
|
227
|
+
```
|
228
|
+
|
229
|
+
Example `EOAT::Exception::HTTPError`
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
begin
|
233
|
+
EOAT::EveApi.new(123, 'bar', scope: 'account').APIKeyInfo
|
234
|
+
rescue EOAT::Exception::HTTPError => e
|
235
|
+
puts e.status
|
236
|
+
puts e.headers
|
237
|
+
puts e.message
|
238
|
+
end
|
239
|
+
403
|
240
|
+
{"content-type"=>["text/html"], "date"=>["Wed, 04 Sep 2013 17:10:05 GMT"], "connection"=>["close"], "content-length"=>["1233"]}
|
241
|
+
Request host 'https://api.eveonline.com' return error: '403 - Forbidden'
|
242
|
+
```
|
243
|
+
|
244
|
+
Example `EOAT::Exception::EveApiError`
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
begin
|
248
|
+
EOAT::EveApi.new(keyID, 'vCode', :scope => 'corp').KillLog
|
249
|
+
rescue EOAT::Exception::EveApiError => e
|
250
|
+
puts e.number
|
251
|
+
puts e.message
|
252
|
+
end
|
253
|
+
120
|
254
|
+
Expected beforeKillID [33012983] but supplied [0]. Please supply the expected killID!
|
255
|
+
If you are not expecting this message it is possible that some other application is using this key!
|
256
|
+
```
|
257
|
+
|
258
|
+
### Caching
|
259
|
+
|
260
|
+
To cache the result can be used three types of storage: file, memcached and redis.
|
261
|
+
In the default configuration is used stub cache `EOAT::Cache::NoneCache` class.
|
262
|
+
|
263
|
+
|
264
|
+
#### File
|
265
|
+
|
266
|
+
The easiest way to cache the result. Since only used space on your hard disk.
|
267
|
+
The default uses the path to store: `~/.eoat/cache`.
|
268
|
+
|
269
|
+
Set store cache to files in the default path
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
EOAT.cache = EOAT::Cache::FileCache.new
|
273
|
+
```
|
274
|
+
|
275
|
+
or set custom path
|
276
|
+
|
277
|
+
```ruby
|
278
|
+
EOAT.cache = EOAT::Cache::FileCache.new('new/path')
|
279
|
+
```
|
280
|
+
|
281
|
+
#### Memcached
|
282
|
+
|
283
|
+
Memcached popular key-value database in memory. This is a good choice of places to store the cache.
|
284
|
+
To use it, you must also install an additional dependence `gem memcache` and of course to have a running memcached.
|
285
|
+
|
286
|
+
Set store cache in Memcached using standard connectivity options
|
287
|
+
|
288
|
+
```ruby
|
289
|
+
EOAT.cache = EOAT::Cache::MemcachedCache.new
|
290
|
+
```
|
291
|
+
|
292
|
+
or set custom address / port
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
EOAT.cache = EOAT::Cache::MemcachedCache.new('address:port')
|
296
|
+
```
|
297
|
+
|
298
|
+
#### Redis
|
299
|
+
|
300
|
+
Redis is a key-value journaling database in memory. Prevents you from losing data after a reboot.
|
301
|
+
To use it, you must also install an additional dependence `gem redis` and running Redis daemon.
|
302
|
+
|
303
|
+
Set store cache in Redis using standard connectivity options
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
EOAT.cache = EOAT::Cache::RedisCache.new
|
307
|
+
```
|
308
|
+
|
309
|
+
or set custom address / port or socket
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
EOAT.cache = EOAT::Cache::RedisCache.new(:host => 'address', :port => port)
|
313
|
+
EOAT.cache = EOAT::Cache::RedisCache.new(:path => 'path/to/socket')
|
314
|
+
```
|
315
|
+
|
316
|
+
#### Additional options
|
317
|
+
|
318
|
+
You can set the maximum cache lifetime in seconds. By default, the maximum TTL is set to 30 days.
|
319
|
+
I do not recommend set it in a larger value than the default, if you use Memcached.
|
320
|
+
|
321
|
+
```ruby
|
322
|
+
EOAT.max_ttl = 259200 # 3 days
|
323
|
+
```
|
324
|
+
|
325
|
+
#### Data checking
|
326
|
+
|
327
|
+
You can check the relevance of the result. For this purpose there is a boolean parameter `from_cache` in Result class
|
328
|
+
|
329
|
+
Example
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
require 'eoat'
|
333
|
+
EOAT.cache = EOAT::Cache::MemcachedCache.new
|
334
|
+
errors = EOAT::EveApi.new.ErrorList
|
335
|
+
errors.from_cache
|
336
|
+
=> false
|
337
|
+
errors = EOAT::EveApi.new.ErrorList
|
338
|
+
errors.from_cache
|
339
|
+
=> true
|
340
|
+
```
|
341
|
+
|
342
|
+
### Additional request parameters
|
343
|
+
|
344
|
+
You can also change or add request headers.
|
345
|
+
It may happen that you will be denied to provide data if you do not specify them.
|
346
|
+
|
347
|
+
```ruby
|
348
|
+
EOAT.headers
|
349
|
+
=> {"User-Agent"=>"EOAT/0.0.1 (Eve Online Api Toolbox;+https://github.com/elDante/eoat)", "Accept-Encoding"=>"gzip", "Accept-Charset"=>"utf-8"}
|
350
|
+
EOAT.headers['User-Agent'] = 'Custom User-Agent'
|
351
|
+
EOAT.headers['Host'] = 'example.com'
|
352
|
+
EOAT.headers['From'] = 'user@example.com'
|
353
|
+
```
|
354
|
+
|
355
|
+
## Contributing
|
356
|
+
|
357
|
+
1. Fork it
|
358
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
359
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
360
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
361
|
+
5. Create new Pull Request
|