neweden 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +20 -0
- data/README.md +7 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/init.rb +15 -0
- data/lib/neweden/account.rb +13 -0
- data/lib/neweden/api.rb +5 -0
- data/lib/neweden/character.rb +48 -0
- data/lib/neweden/corporation.rb +24 -0
- data/lib/neweden/errors.rb +10 -0
- data/lib/neweden/eve.rb +25 -0
- data/lib/neweden/image.rb +24 -0
- data/lib/neweden/map.rb +14 -0
- data/lib/neweden/server.rb +5 -0
- data/lib/neweden.rb +134 -0
- data/neweden.gemspec +85 -0
- data/test/.gitignore +1 -0
- data/test/config/.keep +0 -0
- data/test/helper.rb +20 -0
- data/test/test_neweden.rb +98 -0
- data/test/test_neweden_live.rb +52 -0
- metadata +202 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "typhoeus"
|
4
|
+
gem "nokogiri"
|
5
|
+
gem "json"
|
6
|
+
gem "awesome_print"
|
7
|
+
gem "active_support"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
gem "shoulda-context"
|
13
|
+
gem "bundler"
|
14
|
+
gem "jeweler"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
active_support (3.0.0)
|
5
|
+
activesupport (= 3.0.0)
|
6
|
+
activesupport (3.0.0)
|
7
|
+
awesome_print (1.0.2)
|
8
|
+
git (1.2.5)
|
9
|
+
jeweler (1.8.3)
|
10
|
+
bundler (~> 1.0)
|
11
|
+
git (>= 1.2.5)
|
12
|
+
rake
|
13
|
+
json (1.6.6)
|
14
|
+
mime-types (1.18)
|
15
|
+
nokogiri (1.5.2)
|
16
|
+
rake (0.9.2.2)
|
17
|
+
shoulda-context (1.0.0)
|
18
|
+
typhoeus (0.3.3)
|
19
|
+
mime-types
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
active_support
|
26
|
+
awesome_print
|
27
|
+
bundler
|
28
|
+
jeweler
|
29
|
+
json
|
30
|
+
nokogiri
|
31
|
+
shoulda-context
|
32
|
+
typhoeus
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Jason Adams
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "neweden"
|
18
|
+
gem.homepage = "http://github.com/ealdent/neweden"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Ruby library for accessing Eve Online API}
|
21
|
+
gem.email = "jasonmadams@gmail.com"
|
22
|
+
gem.authors = ["Jason Adams"]
|
23
|
+
# dependencies defined in Gemfile
|
24
|
+
end
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :test
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "neweden #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/init.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'awesome_print'
|
4
|
+
require 'active_support/core_ext/hash/conversions'
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'errors')
|
7
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'account')
|
8
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'api')
|
9
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'character')
|
10
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'corporation')
|
11
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'eve')
|
12
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'image')
|
13
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'map')
|
14
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden', 'server')
|
15
|
+
require File.join(File.dirname(__FILE__), 'lib', 'neweden.rb')
|
data/lib/neweden/api.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Character
|
2
|
+
CHARACTER_ENDPOINTS = %w{ AccountBalance AssetList CharacterSheet ContactList ContactNotifications Contracts FacWarStats
|
3
|
+
IndustryJobs Killlog MailBodies MailingLists MailMessages MarketOrders Medals Notifications Research
|
4
|
+
SkillinTraining SkillQueue Standings WalletJournal WalletTransactions
|
5
|
+
}
|
6
|
+
|
7
|
+
CHARACTER_ENDPOINTS.each do |endpoint|
|
8
|
+
module_eval <<-RUBY
|
9
|
+
def #{endpoint.underscore}(character_id)
|
10
|
+
character_request("/char/#{endpoint}.xml.aspx", character_id)
|
11
|
+
end
|
12
|
+
RUBY
|
13
|
+
end
|
14
|
+
|
15
|
+
def notification_texts(character_id, *notification_ids)
|
16
|
+
request("/char/NotificationTexts.xml.aspx", :post, :characterID => character_id, :IDs => notification_ids.map { |nid| nid.to_s }.join(','))
|
17
|
+
end
|
18
|
+
|
19
|
+
def all_notification_texts(character_id)
|
20
|
+
n_results = self.notifications(character_id)
|
21
|
+
if n_results[:rowset][:row].nil?
|
22
|
+
nil
|
23
|
+
else
|
24
|
+
notification_ids = n_results[:rowset][:row].map { |row| row[:notificationID] }
|
25
|
+
notification_texts(character_id, notification_ids)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def calendar_event_attendees(character_id)
|
30
|
+
upcoming_calendar_events(character_id)
|
31
|
+
character_request("/char/CalendarEventAttendees.xml.aspx", character_id)
|
32
|
+
end
|
33
|
+
|
34
|
+
def upcoming_calendar_events(character_id)
|
35
|
+
@upcoming_events ||= {}
|
36
|
+
@upcoming_events[character_id.to_s] ||= character_request("/char/UpcomingCalendarEvents.xml.aspx", character_id)
|
37
|
+
end
|
38
|
+
|
39
|
+
alias :factional_warfare_stats :fac_war_stats
|
40
|
+
alias :kill_log :killlog
|
41
|
+
alias :skill_in_training :skillin_training
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def character_request(endpoint, character_id)
|
46
|
+
request(endpoint, :post, :characterID => character_id)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Corporation
|
2
|
+
CORPORATION_ENDPOINTS = %w{ AccountBalance AssetList ContactList ContainerLog Contracts CorporationSheet FacWarStats
|
3
|
+
IndustryJobs Killlog MarketOrders Medals MemberMedals MemberSecurity MemberSecurityLog MemberTracking OutpostList
|
4
|
+
OutpostServiceDetail Shareholders Standings StarbaseDetail StarbaseList Titles WalletJournal WalletTransactions
|
5
|
+
}
|
6
|
+
|
7
|
+
CORPORATION_ENDPOINTS.each do |endpoint|
|
8
|
+
module_eval <<-RUBY
|
9
|
+
def corp_#{endpoint.underscore}(character_id)
|
10
|
+
corportaion_request("/corp/#{endpoint}.xml.aspx", character_id)
|
11
|
+
end
|
12
|
+
RUBY
|
13
|
+
end
|
14
|
+
|
15
|
+
alias :corp_account_balances :corp_account_balance
|
16
|
+
alias :corp_factional_warfare_stats :corp_fac_war_stats
|
17
|
+
alias :corp_kill_log :corp_killlog
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def corportaion_request(endpoint, character_id)
|
22
|
+
request(endpoint, :post, :characterID => character_id)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Errors
|
2
|
+
class TimeoutError < StandardError; end
|
3
|
+
class AuthenticationError < StandardError; end
|
4
|
+
class NoResponseError < StandardError; end
|
5
|
+
class UnsuccessfulResponseError < StandardError; end
|
6
|
+
class NotFoundError < StandardError; end
|
7
|
+
class ApiError < StandardError; end
|
8
|
+
class XMLParsingError < StandardError; end
|
9
|
+
class NotInvolvedInFactionalWarfare < StandardError; end
|
10
|
+
end
|
data/lib/neweden/eve.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Eve
|
2
|
+
EVE_ENDPOINTS = %w{ AllianceList CertificateTree ConquerableStationList ErrorList FacWarStats FacWarTopStats RefTypes SkillTree }
|
3
|
+
|
4
|
+
EVE_ENDPOINTS.each do |endpoint|
|
5
|
+
module_eval <<-RUBY
|
6
|
+
def eve_#{endpoint.underscore}
|
7
|
+
request("/eve/#{endpoint}.xml.aspx")
|
8
|
+
end
|
9
|
+
RUBY
|
10
|
+
end
|
11
|
+
|
12
|
+
def character_ids(*names)
|
13
|
+
request("/eve/CharacterID.xml.aspx", :post, :names => names.join(","))
|
14
|
+
end
|
15
|
+
alias :character_id :character_ids
|
16
|
+
|
17
|
+
def character_info(character_id)
|
18
|
+
request("/eve/CharacterInfo.xml.aspx", :post, :characterID => character_id)
|
19
|
+
end
|
20
|
+
|
21
|
+
def character_names(*ids)
|
22
|
+
request("/eve/CharacterName.xml.aspx", :post, :ids => ids.join(","))
|
23
|
+
end
|
24
|
+
alias :character_name :character_names
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Image
|
2
|
+
IMAGE_ENDPOINTS = {
|
3
|
+
:Character => [30, 32, 64, 128, 200, 256, 512, 1024],
|
4
|
+
:Corporation => [30, 32, 64, 128, 256],
|
5
|
+
:Alliance => [30, 32, 64, 128],
|
6
|
+
:InventoryType => [32, 64],
|
7
|
+
:Render => [32, 64, 128, 256, 512]
|
8
|
+
}
|
9
|
+
IMAGE_ENDPOINTS.each_pair do |endpoint, sizes|
|
10
|
+
sizes.each do |size|
|
11
|
+
module_eval <<-RUBY
|
12
|
+
def #{endpoint.to_s.underscore}_image_url_#{size}(relevant_id, extension = :png)
|
13
|
+
image_url(#{endpoint}, relevant_id, #{size}, extension)
|
14
|
+
end
|
15
|
+
RUBY
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def image_url(type, relevant_id, size, extension = :png)
|
22
|
+
"http://image.eveonline.com/#{type}/#{relevant_id}_#{size}.#{extension.to_s}"
|
23
|
+
end
|
24
|
+
end
|
data/lib/neweden/map.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Map
|
2
|
+
MAP_ENDPOINTS = %w{ FacWarSystems Jumps Kills Sovereignty }
|
3
|
+
|
4
|
+
MAP_ENDPOINTS.each do |endpoint|
|
5
|
+
module_eval <<-RUBY
|
6
|
+
def map_#{endpoint.to_s.underscore}
|
7
|
+
request("/map/#{endpoint}.xml.aspx")
|
8
|
+
end
|
9
|
+
RUBY
|
10
|
+
end
|
11
|
+
|
12
|
+
alias :map_factional_warfare_systems :map_fac_war_systems
|
13
|
+
alias :factional_warfare_systems :map_fac_war_systems
|
14
|
+
end
|
data/lib/neweden.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
class NewEden
|
2
|
+
include Account
|
3
|
+
include Api
|
4
|
+
include Character
|
5
|
+
include Corporation
|
6
|
+
include Errors
|
7
|
+
include Eve
|
8
|
+
include Image
|
9
|
+
include Map
|
10
|
+
include Server
|
11
|
+
|
12
|
+
REQUEST_TIMEOUT = 60000 # 60 seconds
|
13
|
+
CACHE_TIMEOUT = 300 # 5 minutes
|
14
|
+
|
15
|
+
attr_reader :key_id, :vcode, :server, :game_server, :test_server, :hydra
|
16
|
+
|
17
|
+
def initialize(key_id, vcode, use_test = false)
|
18
|
+
@key_id = key_id
|
19
|
+
@vcode = vcode
|
20
|
+
@game_server = "api.eveonline.com".freeze
|
21
|
+
@test_server = "apitest.eveonline.com".freeze
|
22
|
+
@server = use_test ? @test_server : @game_server
|
23
|
+
@hydra = Typhoeus::Hydra.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def request(endpoint, method = :post, params = {})
|
27
|
+
xml = handle_response(raw_request(endpoint, method, params))
|
28
|
+
if xml
|
29
|
+
symbolize_keys(Hash.from_xml((xml/:eveapi/:result).to_s))[:result] rescue raise XMLParsingError, "No result in set"
|
30
|
+
else
|
31
|
+
raise XMLParsingError, "No XML parsed successfully"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def raw_request(endpoint, method = :post, params = {})
|
36
|
+
url = "https://#{@server}/#{sanitize_endpoint(endpoint)}"
|
37
|
+
case method
|
38
|
+
when :get
|
39
|
+
Typhoeus::Request.get(url, request_params(params))
|
40
|
+
when :put
|
41
|
+
Typhoeus::Request.put(url, request_params(params))
|
42
|
+
when :delete
|
43
|
+
Typhoeus::Request.delete(url, request_params(params))
|
44
|
+
else
|
45
|
+
Typhoeus::Request.post(url, request_params(params))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle_response(response)
|
50
|
+
if response.timed_out?
|
51
|
+
raise TimeoutError, "Response timed out."
|
52
|
+
elsif response.code == 0
|
53
|
+
raise NoResponseError, "No response received."
|
54
|
+
elsif response.code == 404
|
55
|
+
raise NotFoundError, "API endpoint not found."
|
56
|
+
elsif !response.success?
|
57
|
+
raise UnsuccessfulResponseError, "Received HTTP response: #{response.code.to_s}"
|
58
|
+
end
|
59
|
+
|
60
|
+
xml = Nokogiri::XML.parse(response.body)
|
61
|
+
|
62
|
+
unless (xml/:eveapi/:error).empty?
|
63
|
+
error_code = (xml/:error).attribute('code').value.to_i
|
64
|
+
case error_code
|
65
|
+
when 203
|
66
|
+
raise AuthenticationError, "Invalid key id or vcode."
|
67
|
+
when 124, 125
|
68
|
+
raise NotInvolvedInFactionalWarfare, "Not involved in factional warfare."
|
69
|
+
else
|
70
|
+
raise ApiError, (xml/:eveapi/:error).children.map { |e| e.to_s.gsub(/\.$/, '') }.join(", ")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
xml
|
75
|
+
end
|
76
|
+
|
77
|
+
def use_game_server
|
78
|
+
@server = @game_server
|
79
|
+
end
|
80
|
+
|
81
|
+
def use_test_server
|
82
|
+
@server = @test_server
|
83
|
+
end
|
84
|
+
|
85
|
+
def request_url
|
86
|
+
"https://#{@server}/#{sanitize_endpoint(endpoint)}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def request_params(params = {})
|
90
|
+
if @key_id.nil? || @vcode.nil?
|
91
|
+
{
|
92
|
+
:headers => { :Accept => "application/xml" },
|
93
|
+
:timeout => REQUEST_TIMEOUT,
|
94
|
+
:cache_timeout => CACHE_TIMEOUT
|
95
|
+
}
|
96
|
+
else
|
97
|
+
{
|
98
|
+
:headers => { :Accept => "application/xml" },
|
99
|
+
:timeout => REQUEST_TIMEOUT,
|
100
|
+
:cache_timeout => CACHE_TIMEOUT,
|
101
|
+
:params => params.merge({ :keyID => @key_id, :vCode => @vcode })
|
102
|
+
}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def sanitize_endpoint(endpoint)
|
109
|
+
endpoint.strip.gsub(/^\/+/, '')
|
110
|
+
end
|
111
|
+
|
112
|
+
def symbolize_keys(myhash)
|
113
|
+
myhash.symbolize_keys!
|
114
|
+
myhash.keys.each do |key|
|
115
|
+
if myhash[key].kind_of?(Hash)
|
116
|
+
symbolize_keys(myhash[key])
|
117
|
+
elsif myhash[key].kind_of?(Array)
|
118
|
+
myhash[key].each do |element|
|
119
|
+
symbolize_keys(element) if element.kind_of?(Hash)
|
120
|
+
end
|
121
|
+
elsif myhash[key].is_a?(String)
|
122
|
+
if myhash[key].strip =~ /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/
|
123
|
+
myhash[key] = DateTime.parse(myhash[key]).to_time
|
124
|
+
elsif myhash[key].strip =~ /^\d+$/
|
125
|
+
myhash[key] = myhash[key].to_i
|
126
|
+
elsif myhash[key].strip =~ /^\d+\.\d+$/
|
127
|
+
myhash[key] = myhash[key].to_f
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
myhash
|
133
|
+
end
|
134
|
+
end
|
data/neweden.gemspec
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{neweden}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Jason Adams}]
|
12
|
+
s.date = %q{2011-09-16}
|
13
|
+
s.email = %q{jasonmadams@gmail.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE.txt",
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/neweden.rb",
|
27
|
+
"lib/neweden/account.rb",
|
28
|
+
"lib/neweden/api.rb",
|
29
|
+
"lib/neweden/character.rb",
|
30
|
+
"lib/neweden/corporation.rb",
|
31
|
+
"lib/neweden/errors.rb",
|
32
|
+
"lib/neweden/eve.rb",
|
33
|
+
"lib/neweden/image.rb",
|
34
|
+
"lib/neweden/map.rb",
|
35
|
+
"lib/neweden/server.rb",
|
36
|
+
"neweden.gemspec",
|
37
|
+
"test/.gitignore",
|
38
|
+
"test/config/.keep",
|
39
|
+
"test/helper.rb",
|
40
|
+
"test/test_neweden.rb",
|
41
|
+
"test/test_neweden_live.rb"
|
42
|
+
]
|
43
|
+
s.homepage = %q{http://github.com/ealdent/neweden}
|
44
|
+
s.licenses = [%q{MIT}]
|
45
|
+
s.require_paths = [%q{lib}]
|
46
|
+
s.rubygems_version = %q{1.8.6}
|
47
|
+
s.summary = %q{Ruby library for accessing Eve Online API}
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<typhoeus>, ["= 0.2.4"])
|
54
|
+
s.add_runtime_dependency(%q<nokogiri>, ["= 1.5.0"])
|
55
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
56
|
+
s.add_runtime_dependency(%q<awesome_print>, [">= 0"])
|
57
|
+
s.add_runtime_dependency(%q<active_support>, ["= 3.0.0"])
|
58
|
+
s.add_development_dependency(%q<shoulda-context>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<typhoeus>, ["= 0.2.4"])
|
64
|
+
s.add_dependency(%q<nokogiri>, ["= 1.5.0"])
|
65
|
+
s.add_dependency(%q<json>, [">= 0"])
|
66
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
67
|
+
s.add_dependency(%q<active_support>, ["= 3.0.0"])
|
68
|
+
s.add_dependency(%q<shoulda-context>, [">= 0"])
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
71
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
72
|
+
end
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<typhoeus>, ["= 0.2.4"])
|
75
|
+
s.add_dependency(%q<nokogiri>, ["= 1.5.0"])
|
76
|
+
s.add_dependency(%q<json>, [">= 0"])
|
77
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
78
|
+
s.add_dependency(%q<active_support>, ["= 3.0.0"])
|
79
|
+
s.add_dependency(%q<shoulda-context>, [">= 0"])
|
80
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
81
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
82
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
data/test/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
config/eve-api.yml
|
data/test/config/.keep
ADDED
File without changes
|
data/test/helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'psych'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'test/unit'
|
13
|
+
require 'shoulda-context'
|
14
|
+
|
15
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
+
require 'neweden'
|
18
|
+
|
19
|
+
class Test::Unit::TestCase
|
20
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestNeweden < Test::Unit::TestCase
|
4
|
+
context "without credentials" do
|
5
|
+
setup do
|
6
|
+
# set up a NewEden object with nil api values to ensure everything is defined
|
7
|
+
@neweden = NewEden.new(nil, nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "a character" do
|
11
|
+
NewEden::CHARACTER_ENDPOINTS.each do |endpoint|
|
12
|
+
should "define method for #{endpoint} character endpoint" do
|
13
|
+
assert @neweden.respond_to? endpoint.to_s.underscore
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
should "define method for calendar event attendees" do
|
18
|
+
assert @neweden.respond_to? 'calendar_event_attendees'
|
19
|
+
end
|
20
|
+
|
21
|
+
should "define method upcoming calendar events" do
|
22
|
+
assert @neweden.respond_to? 'upcoming_calendar_events'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "an account" do
|
27
|
+
should "define method for account status" do
|
28
|
+
assert @neweden.respond_to? 'account_status'
|
29
|
+
end
|
30
|
+
|
31
|
+
should "define method for api key info" do
|
32
|
+
assert @neweden.respond_to? 'api_key_info'
|
33
|
+
end
|
34
|
+
|
35
|
+
should "define method for list of characters on account" do
|
36
|
+
assert @neweden.respond_to? 'characters'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "a corporation" do
|
41
|
+
NewEden::CORPORATION_ENDPOINTS.each do |endpoint|
|
42
|
+
should "define method for #{endpoint} corporation endpoint" do
|
43
|
+
assert @neweden.respond_to? "corp_#{endpoint.to_s.underscore}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "general eve" do
|
49
|
+
NewEden::EVE_ENDPOINTS.each do |endpoint|
|
50
|
+
should "define method for #{endpoint} eve endpoint" do
|
51
|
+
assert @neweden.respond_to? "eve_#{endpoint.to_s.underscore}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
should "define method for getting a list of character ids" do
|
56
|
+
assert @neweden.respond_to? 'character_ids'
|
57
|
+
end
|
58
|
+
|
59
|
+
should "define method for getting basic character info" do
|
60
|
+
assert @neweden.respond_to? 'character_info'
|
61
|
+
end
|
62
|
+
|
63
|
+
should "define method for getting character names from ids" do
|
64
|
+
assert @neweden.respond_to? 'character_names'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "maps" do
|
69
|
+
NewEden::MAP_ENDPOINTS.each do |endpoint|
|
70
|
+
should "define method for #{endpoint} map endpoint" do
|
71
|
+
assert @neweden.respond_to? "map_#{endpoint.to_s.underscore}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "server" do
|
77
|
+
should "define methods for getting server status" do
|
78
|
+
assert @neweden.respond_to? 'server_status'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "api" do
|
83
|
+
should "define method for getting call list" do
|
84
|
+
assert @neweden.respond_to? 'call_list'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'images' do
|
89
|
+
NewEden::IMAGE_ENDPOINTS.each_pair do |endpoint, sizes|
|
90
|
+
sizes.each do |size|
|
91
|
+
should "define methods for getting the url for #{endpoint} of size #{size}" do
|
92
|
+
assert @neweden.respond_to? "#{endpoint.to_s.underscore}_image_url_#{size}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestNewedenLive < Test::Unit::TestCase
|
4
|
+
# comment out these next two contexts if you do not want to test against the live api
|
5
|
+
context "with character credentials" do
|
6
|
+
setup do
|
7
|
+
# These tests are all meant to be run against the actual API
|
8
|
+
@config = Psych.load_file(File.join(File.dirname(__FILE__), 'config', 'eve-api.yml'))[:character]
|
9
|
+
@neweden = NewEden.new(@config[:key_id], @config[:vcode])
|
10
|
+
end
|
11
|
+
|
12
|
+
should "have credentials present" do
|
13
|
+
assert !@config.blank?
|
14
|
+
end
|
15
|
+
|
16
|
+
context "a character" do
|
17
|
+
endpoints_to_check = NewEden::CHARACTER_ENDPOINTS + ['CalendarEventAttendees', 'UpcomingCalendarEvents']
|
18
|
+
endpoints_to_check.each do |endpoint|
|
19
|
+
next if ['NotificationTexts', 'MailBodies'].include?(endpoint)
|
20
|
+
should "respond to #{endpoint} endpoint" do
|
21
|
+
begin
|
22
|
+
result = @neweden.send(endpoint.to_s.underscore, @config[:character_id])
|
23
|
+
assert result.is_a?(Hash)
|
24
|
+
assert !result.blank?
|
25
|
+
rescue NewEden::NotInvolvedInFactionalWarfare
|
26
|
+
assert true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
should "respond to NotificationTexts endpoint" do
|
32
|
+
result = @neweden.all_notification_texts(@config[:character_id])
|
33
|
+
if result.nil?
|
34
|
+
assert true
|
35
|
+
else
|
36
|
+
assert result.is_a?(Hash)
|
37
|
+
assert !result.blank?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with corporate credentials" do
|
44
|
+
setup do
|
45
|
+
@config = Psych.load_file(File.join(File.dirname(__FILE__), 'config', 'eve-api.yml'))[:corporation]
|
46
|
+
end
|
47
|
+
|
48
|
+
should "have credentials present" do
|
49
|
+
assert !@config.blank?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neweden
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Adams
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: typhoeus
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: nokogiri
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: awesome_print
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: active_support
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: shoulda-context
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: bundler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: jeweler
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description:
|
143
|
+
email: jasonmadams@gmail.com
|
144
|
+
executables: []
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files:
|
147
|
+
- LICENSE.txt
|
148
|
+
- README.md
|
149
|
+
files:
|
150
|
+
- .document
|
151
|
+
- Gemfile
|
152
|
+
- Gemfile.lock
|
153
|
+
- LICENSE.txt
|
154
|
+
- README.md
|
155
|
+
- Rakefile
|
156
|
+
- VERSION
|
157
|
+
- init.rb
|
158
|
+
- lib/neweden.rb
|
159
|
+
- lib/neweden/account.rb
|
160
|
+
- lib/neweden/api.rb
|
161
|
+
- lib/neweden/character.rb
|
162
|
+
- lib/neweden/corporation.rb
|
163
|
+
- lib/neweden/errors.rb
|
164
|
+
- lib/neweden/eve.rb
|
165
|
+
- lib/neweden/image.rb
|
166
|
+
- lib/neweden/map.rb
|
167
|
+
- lib/neweden/server.rb
|
168
|
+
- neweden.gemspec
|
169
|
+
- test/.gitignore
|
170
|
+
- test/config/.keep
|
171
|
+
- test/helper.rb
|
172
|
+
- test/test_neweden.rb
|
173
|
+
- test/test_neweden_live.rb
|
174
|
+
homepage: http://github.com/ealdent/neweden
|
175
|
+
licenses:
|
176
|
+
- MIT
|
177
|
+
post_install_message:
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
segments:
|
188
|
+
- 0
|
189
|
+
hash: -1927723617298482446
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
none: false
|
192
|
+
requirements:
|
193
|
+
- - ! '>='
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0'
|
196
|
+
requirements: []
|
197
|
+
rubyforge_project:
|
198
|
+
rubygems_version: 1.8.23
|
199
|
+
signing_key:
|
200
|
+
specification_version: 3
|
201
|
+
summary: Ruby library for accessing Eve Online API
|
202
|
+
test_files: []
|