eve 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +174 -0
  3. data/PostInstall.txt +6 -0
  4. data/README.rdoc +126 -0
  5. data/Rakefile +128 -0
  6. data/features/support/env.rb +1 -0
  7. data/lib/eve.rb +31 -0
  8. data/lib/eve/api.rb +247 -0
  9. data/lib/eve/api/connectivity.rb +39 -0
  10. data/lib/eve/api/request.rb +74 -0
  11. data/lib/eve/api/response.rb +100 -0
  12. data/lib/eve/api/response/inspection.rb +62 -0
  13. data/lib/eve/api/response/rowset.rb +56 -0
  14. data/lib/eve/api/response/rowsets.rb +42 -0
  15. data/lib/eve/api/response/wrap_object.rb +15 -0
  16. data/lib/eve/api/services.rb +20 -0
  17. data/lib/eve/api/services/account.rb +12 -0
  18. data/lib/eve/api/services/character.rb +96 -0
  19. data/lib/eve/api/services/corporation.rb +150 -0
  20. data/lib/eve/api/services/eve.rb +76 -0
  21. data/lib/eve/api/services/map.rb +45 -0
  22. data/lib/eve/api/services/misc.rb +24 -0
  23. data/lib/eve/api/services/server.rb +20 -0
  24. data/lib/eve/core_extensions.rb +3 -0
  25. data/lib/eve/core_extensions/hash.rb +51 -0
  26. data/lib/eve/core_extensions/string.rb +11 -0
  27. data/lib/eve/dependencies.rb +18 -0
  28. data/lib/eve/errors.rb +129 -0
  29. data/lib/eve/errors/authentication_errors.rb +33 -0
  30. data/lib/eve/errors/internal_errors.rb +64 -0
  31. data/lib/eve/errors/miscellaneous_errors.rb +19 -0
  32. data/lib/eve/errors/user_input_errors.rb +62 -0
  33. data/lib/eve/helpers.rb +12 -0
  34. data/lib/eve/helpers/javascript_helper.rb +198 -0
  35. data/lib/eve/helpers/view_helper.rb +13 -0
  36. data/lib/eve/trust.rb +88 -0
  37. data/lib/eve/trust/controller_helpers.rb +90 -0
  38. data/lib/eve/trust/igb_interface.rb +88 -0
  39. data/lib/eve/trust/mime_types.rb +4 -0
  40. data/script/console +10 -0
  41. data/script/console.cmd +1 -0
  42. data/script/destroy +14 -0
  43. data/script/destroy.cmd +1 -0
  44. data/script/generate +14 -0
  45. data/script/generate.cmd +1 -0
  46. data/spec/lib/eve/api/calls/account/characters_spec.rb +22 -0
  47. data/spec/lib/eve/api/calls/character/account_balance_spec.rb +21 -0
  48. data/spec/lib/eve/api/calls/character/asset_list_spec.rb +23 -0
  49. data/spec/lib/eve/api/calls/character/character_sheet_spec.rb +51 -0
  50. data/spec/lib/eve/api/calls/character/fac_war_stats_spec.rb +31 -0
  51. data/spec/lib/eve/api/calls/character/industry_jobs_spec.rb +27 -0
  52. data/spec/lib/eve/api/calls/character/kill_log_spec.rb +27 -0
  53. data/spec/lib/eve/api/calls/character/mail_messages_spec.rb +21 -0
  54. data/spec/lib/eve/api/calls/character/mailing_lists_spec.rb +21 -0
  55. data/spec/lib/eve/api/calls/character/market_orders_spec.rb +21 -0
  56. data/spec/lib/eve/api/calls/character/medals_spec.rb +24 -0
  57. data/spec/lib/eve/api/calls/character/research_spec.rb +21 -0
  58. data/spec/lib/eve/api/calls/character/skill_in_training_spec.rb +44 -0
  59. data/spec/lib/eve/api/calls/character/skill_queue_spec.rb +21 -0
  60. data/spec/lib/eve/api/calls/character/standings_spec.rb +26 -0
  61. data/spec/lib/eve/api/calls/character/wallet_journal_spec.rb +21 -0
  62. data/spec/lib/eve/api/calls/character/wallet_transactions_spec.rb +21 -0
  63. data/spec/lib/eve/api/calls/character_portrait_spec.rb +17 -0
  64. data/spec/lib/eve/api/calls/corporation/account_balances_spec.rb +21 -0
  65. data/spec/lib/eve/api/calls/corporation/asset_list_spec.rb +25 -0
  66. data/spec/lib/eve/api/calls/corporation/container_log_spec.rb +23 -0
  67. data/spec/lib/eve/api/calls/corporation/corporation_sheet_spec.rb +36 -0
  68. data/spec/lib/eve/api/calls/corporation/fac_war_stats_spec.rb +23 -0
  69. data/spec/lib/eve/api/calls/corporation/industry_jobs_spec.rb +30 -0
  70. data/spec/lib/eve/api/calls/corporation/kill_log_spec.rb +27 -0
  71. data/spec/lib/eve/api/calls/corporation/market_orders_spec.rb +22 -0
  72. data/spec/lib/eve/api/calls/corporation/medals_spec.rb +21 -0
  73. data/spec/lib/eve/api/calls/corporation/member_medals_spec.rb +21 -0
  74. data/spec/lib/eve/api/calls/corporation/member_security_log_spec.rb +24 -0
  75. data/spec/lib/eve/api/calls/corporation/member_security_spec.rb +25 -0
  76. data/spec/lib/eve/api/calls/corporation/member_tracking_spec.rb +22 -0
  77. data/spec/lib/eve/api/calls/corporation/shareholders_spec.rb +23 -0
  78. data/spec/lib/eve/api/calls/corporation/standings_spec.rb +30 -0
  79. data/spec/lib/eve/api/calls/corporation/starbase_detail_spec.rb +32 -0
  80. data/spec/lib/eve/api/calls/corporation/starbase_list_spec.rb +22 -0
  81. data/spec/lib/eve/api/calls/corporation/titles_spec.rb +26 -0
  82. data/spec/lib/eve/api/calls/corporation/wallet_journal_spec.rb +22 -0
  83. data/spec/lib/eve/api/calls/corporation/wallet_transactions_spec.rb +22 -0
  84. data/spec/lib/eve/api/calls/empty_call_spec.rb +29 -0
  85. data/spec/lib/eve/api/calls/eve/alliance_list_spec.rb +26 -0
  86. data/spec/lib/eve/api/calls/eve/certificate_tree_spec.rb +18 -0
  87. data/spec/lib/eve/api/calls/eve/character_id_spec.rb +27 -0
  88. data/spec/lib/eve/api/calls/eve/conquerable_station_list_spec.rb +11 -0
  89. data/spec/lib/eve/api/calls/eve/error_list_spec.rb +21 -0
  90. data/spec/lib/eve/api/calls/eve/fac_war_stats_spec.rb +25 -0
  91. data/spec/lib/eve/api/calls/eve/fac_war_top_stats_spec.rb +54 -0
  92. data/spec/lib/eve/api/calls/eve/ref_types_spec.rb +11 -0
  93. data/spec/lib/eve/api/calls/eve/skill_tree_spec.rb +17 -0
  94. data/spec/lib/eve/api/calls/map/fac_war_systems_spec.rb +11 -0
  95. data/spec/lib/eve/api/calls/map/jumps_spec.rb +11 -0
  96. data/spec/lib/eve/api/calls/map/kills_spec.rb +15 -0
  97. data/spec/lib/eve/api/calls/map/sovereignty_spec.rb +11 -0
  98. data/spec/lib/eve/api/calls/server_status_spec.rb +24 -0
  99. data/spec/lib/eve/api/request_spec.rb +17 -0
  100. data/spec/lib/eve/api/response/error_spec.rb +13 -0
  101. data/spec/lib/eve/api/response/rowset_spec.rb +28 -0
  102. data/spec/lib/eve/api/response_spec.rb +79 -0
  103. data/spec/lib/eve/api_spec.rb +13 -0
  104. data/spec/lib/eve/core_extensions/hash_spec.rb +23 -0
  105. data/spec/lib/eve/core_extensions/string_spec.rb +8 -0
  106. data/spec/lib/eve/helpers/javascript_helper_spec.rb +80 -0
  107. data/spec/lib/eve/helpers/view_helper_spec.rb +12 -0
  108. data/spec/lib/eve/trust/controller_helpers_spec.rb +70 -0
  109. data/spec/lib/eve/trust/igb_interface_spec.rb +102 -0
  110. data/spec/rcov.opts +2 -0
  111. data/spec/readme_spec.rb +36 -0
  112. data/spec/sample_api_key.yml +20 -0
  113. data/spec/spec.opts +4 -0
  114. data/spec/spec_helper.rb +22 -0
  115. data/spec/support/behaves_like_rowset.rb +50 -0
  116. data/spec/support/controllers/trust_controller.rb +7 -0
  117. data/spec/support/jpg/mock_portrait.jpg +0 -0
  118. data/spec/support/mock_api_helpers.rb +41 -0
  119. data/spec/support/xml/account/characters.xml +15 -0
  120. data/spec/support/xml/character/account_balance.xml +10 -0
  121. data/spec/support/xml/character/asset_list.xml +50 -0
  122. data/spec/support/xml/character/character_sheet.xml +65 -0
  123. data/spec/support/xml/character/fac_war_stats.xml +20 -0
  124. data/spec/support/xml/character/industry_jobs.xml +70 -0
  125. data/spec/support/xml/character/kill_log.xml +51 -0
  126. data/spec/support/xml/character/mail_messages.xml +12 -0
  127. data/spec/support/xml/character/mailing_lists.xml +12 -0
  128. data/spec/support/xml/character/market_orders.xml +11 -0
  129. data/spec/support/xml/character/medals.xml +13 -0
  130. data/spec/support/xml/character/research.xml +13 -0
  131. data/spec/support/xml/character/skill_in_training.xml +14 -0
  132. data/spec/support/xml/character/skill_not_in_training.xml +7 -0
  133. data/spec/support/xml/character/skill_queue.xml +11 -0
  134. data/spec/support/xml/character/standings.xml +32 -0
  135. data/spec/support/xml/character/wallet_journal.xml +39 -0
  136. data/spec/support/xml/character/wallet_transactions.xml +44 -0
  137. data/spec/support/xml/corporation/account_balance.xml +15 -0
  138. data/spec/support/xml/corporation/asset_list.xml +50 -0
  139. data/spec/support/xml/corporation/container_log.xml +32 -0
  140. data/spec/support/xml/corporation/fac_war_stats.xml +19 -0
  141. data/spec/support/xml/corporation/industry_jobs.xml +70 -0
  142. data/spec/support/xml/corporation/kill_log.xml +51 -0
  143. data/spec/support/xml/corporation/market_orders.xml +37 -0
  144. data/spec/support/xml/corporation/medals.xml +8 -0
  145. data/spec/support/xml/corporation/member_corporation_sheet.xml +51 -0
  146. data/spec/support/xml/corporation/member_medals.xml +10 -0
  147. data/spec/support/xml/corporation/member_security.xml +21 -0
  148. data/spec/support/xml/corporation/member_security_log.xml +55 -0
  149. data/spec/support/xml/corporation/member_tracking.xml +18 -0
  150. data/spec/support/xml/corporation/non_member_corporation_sheet.xml +30 -0
  151. data/spec/support/xml/corporation/shareholders.xml +11 -0
  152. data/spec/support/xml/corporation/standings.xml +33 -0
  153. data/spec/support/xml/corporation/starbase_detail.xml +33 -0
  154. data/spec/support/xml/corporation/starbase_list.xml +17 -0
  155. data/spec/support/xml/corporation/titles.xml +34 -0
  156. data/spec/support/xml/corporation/wallet_journal.xml +40 -0
  157. data/spec/support/xml/corporation/wallet_transactions.xml +12 -0
  158. data/spec/support/xml/errors/106.xml +5 -0
  159. data/spec/support/xml/errors/516.xml +5 -0
  160. data/spec/support/xml/eve/alliance_list.xml +22 -0
  161. data/spec/support/xml/eve/certificate_tree.xml +49 -0
  162. data/spec/support/xml/eve/character_id.xml +15 -0
  163. data/spec/support/xml/eve/conquerable_station_list.xml +24 -0
  164. data/spec/support/xml/eve/error_list.xml +78 -0
  165. data/spec/support/xml/eve/fac_war_stats.xml +31 -0
  166. data/spec/support/xml/eve/fac_war_top_stats.xml +238 -0
  167. data/spec/support/xml/eve/ref_types.xml +105 -0
  168. data/spec/support/xml/eve/skill_tree.xml +52 -0
  169. data/spec/support/xml/map/fac_war_systems.xml +180 -0
  170. data/spec/support/xml/map/jumps.xml +166 -0
  171. data/spec/support/xml/map/kills.xml +191 -0
  172. data/spec/support/xml/map/sovereignty.xml +20 -0
  173. data/spec/support/xml/rowset_with_mismatched_attributes.xml +6 -0
  174. data/spec/support/xml/server/server_status.xml +9 -0
  175. metadata +364 -0
@@ -0,0 +1,102 @@
1
+ require 'spec_helper'
2
+
3
+ describe Eve::Trust::IgbInterface do
4
+ @@igb_headers = {
5
+ 'HTTP_USER_AGENT' => 'eve-minibrowser',
6
+ 'HTTP_EVE_TRUSTED' => 'yes',
7
+ 'HTTP_EVE_SERVERIP' => '1.2.3.4',
8
+ 'HTTP_EVE_CHARNAME' => 'Jolia Darkstrider',
9
+ 'HTTP_EVE_CHARID' => '1234567890',
10
+ 'HTTP_EVE_CORPNAME' => 'Frogs of Armageddon',
11
+ 'HTTP_EVE_CORPID' => '9876543210',
12
+ 'HTTP_EVE_ALLIANCENAME' => 'Afro Mexicans',
13
+ 'HTTP_EVE_ALLIANCEID' => '1928374',
14
+ 'HTTP_EVE_REGIONNAME' => 'Solitude',
15
+ 'HTTP_EVE_CONSTELLATIONNAME' => 'Morbault',
16
+ 'HTTP_EVE_SOLARSYSTEMNAME' => 'Elore',
17
+ 'HTTP_EVE_STATIONNAME' => 'Caldari Navy Assembly Plant',
18
+ 'HTTP_EVE_STATIONID' => '1234',
19
+ 'HTTP_EVE_CORPROLE' => '0'
20
+ }
21
+ @@igb_requested_headers = {
22
+ 'HTTP_EVE_MILITIANAME' => 'militia name',
23
+ 'HTTP_EVE_MILITIAID' => '1234567',
24
+ 'HTTP_EVE_REGIONID' => '1929',
25
+ 'HTTP_EVE_CONSTELLATIONID' => '100',
26
+ 'HTTP_EVE_SOLARSYSTEMID' => '101',
27
+ 'HTTP_EVE_SHIPID' => '102',
28
+ 'HTTP_EVE_SYSTEMSECURITY' => '0.9',
29
+ 'HTTP_EVE_VALIDATION_STRING' => 'abcdefghijklmnopqrstuvwxyz'
30
+ }
31
+
32
+ subject { Eve::Trust::IgbInterface.new(ActionController::Request.new(@rack_env)) }
33
+
34
+ shared_examples_for "any igb with trust" do
35
+ it "should be trusted" do
36
+ subject.trusted?.should be_true
37
+ end
38
+
39
+ it "should convert strings to objects using YAML where possible" do
40
+ subject.char_id.should == 1234567890
41
+ subject.corp_id.should == 9876543210
42
+ subject.alliance_id.should == 1928374
43
+ subject.station_id.should == 1234
44
+ subject.corp_role.should == 0
45
+ end
46
+
47
+ it "should have all methods delegated properly" do
48
+ subject.server_ip.should == '1.2.3.4'
49
+ subject.char_name.should == 'Jolia Darkstrider'
50
+ subject.corp_name.should == 'Frogs of Armageddon'
51
+ subject.alliance_name.should == 'Afro Mexicans'
52
+ subject.region_name.should == 'Solitude'
53
+ subject.constellation_name.should == 'Morbault'
54
+ subject.solar_system_name.should == 'Elore'
55
+ subject.station_name.should == 'Caldari Navy Assembly Plant'
56
+ end
57
+ end
58
+
59
+ context "without any IGB headers" do
60
+ before(:all) do
61
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '', 'HTTP_USER_AGENT' => 'eve-minibrowser')
62
+ end
63
+
64
+ it("should not be trusted") { subject.trusted?.should_not be_true }
65
+ end
66
+
67
+ context "without trust" do
68
+ before(:all) do
69
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '',
70
+ 'HTTP_USER_AGENT' => 'eve-minibrowser',
71
+ 'HTTP_EVE_TRUST' => 'no')
72
+ end
73
+
74
+ it("should not be trusted") { subject.trusted?.should_not be_true }
75
+ end
76
+
77
+ context "with trust" do
78
+ it_should_behave_like "any igb with trust"
79
+ before(:all) do
80
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '').merge(@@igb_headers)
81
+ end
82
+
83
+ context "after requests are implemented" do
84
+ it_should_behave_like "any igb with trust"
85
+
86
+ before(:all) do
87
+ @rack_env = Rack::MockRequest.env_for("/").merge('REQUEST_URI' => '').merge(@@igb_headers).merge(@@igb_requested_headers)
88
+ end
89
+
90
+ it "should load the additional data" do
91
+ subject.militia_name.should == 'militia name'
92
+ subject.militia_id.should == 1234567
93
+ subject.region_id.should == 1929
94
+ subject.constellation_id.should == 100
95
+ subject.solar_system_id.should == 101
96
+ subject.ship_id.should == 102
97
+ subject.system_security.should == 0.9
98
+ subject.validation_string.should == 'abcdefghijklmnopqrstuvwxyz'
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,2 @@
1
+ --exclude "spec/*,gems/*"
2
+ --aggregate coverage.data
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ # Runs the examples found in the synopsis of the README.rdoc file. We need to verify that they work because they should
4
+ # be copy-and-paste ready.
5
+
6
+ if !$mock_services # only run these if the credentials are (theoretically) valid
7
+ describe "Readme Examples" do
8
+ it "should be copy-and-paste ready" do
9
+ # Get the current server status
10
+ api = Eve::API.new()
11
+ server_status = api.server_status
12
+ puts "Server reports status #{server_status.server_open ? "ONLINE" : "OFFLINE"}"
13
+ puts "\tCurrent time is #{server_status.current_time}"
14
+ puts "\t#{server_status.online_players} players currently online"
15
+ puts
16
+
17
+ # Get a list of characters
18
+ api = Eve::API.new(:user_id => $user_id, :api_key => $limited_api_key)
19
+ result = api.account.characters
20
+ puts "Choose a character:"
21
+ result.characters.each_with_index { |char, index| puts "\t#{index}: #{char.name} (#{char.character_id})" }
22
+ choice = gets.chomp.to_i
23
+ puts
24
+
25
+ # Get the current training queue. Need a full API key and a character ID for that.
26
+ api.set(:api_key => $full_api_key, :character_id => result.characters[choice].character_id)
27
+ result = api.character.skill_queue
28
+ result.skillqueue.each do |skill|
29
+ result.skillqueue.columns.each do |column|
30
+ print column.ljust(20), ":\t", skill[column], "\n"
31
+ end
32
+ puts
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,20 @@
1
+ # This information can be retrieved from http://www.eveonline.com/api/default.asp
2
+ #
3
+ # ! IMPORTANT !
4
+ # Copy this file to "api_key.yml" in the same directory. This file ("sample_api_key.yml")
5
+ # is not even used, and if you put your real API info into it there's a fair chance you'll
6
+ # wind up accidentally committing it. The "api_key.yml" file is already in .gitignore, so
7
+ # you won't do so if you remember to copy this file first.
8
+ #
9
+ # Note that it doesn't really matter what any of this stuff is if $mock_services is true,
10
+ # which it really always should be unless you need to test end-to-end connectivity.
11
+ #
12
+ # Note, also, that the tests were designed around mock data. They WILL fail if you use real
13
+ # data. However, you should be able to judge pretty easily by the error messages whether
14
+ # they're failing because of the data mismatch, or whether they're failing for some other
15
+ # (more catastrophic) reason.
16
+ #
17
+ User ID: your_user_id
18
+ Limited API Key: your_limited_api_key
19
+ Full API Key: your_full_api_key
20
+ Character ID: your_character_id
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,22 @@
1
+ require 'lib/eve'
2
+
3
+ # Set to false to disable mock web service responses. Real requests will be used
4
+ # whenever Eve.cache does not suffice. The API information above must be real and
5
+ # valid in this case.
6
+ $mock_services = true
7
+
8
+ keyfile = File.join(File.dirname(__FILE__), 'api_key.yml')
9
+ cred_hash = !$mock_services && File.file?(keyfile) ? YAML::load(File.read(keyfile)) || {} : {}
10
+
11
+ # ! IMPORTANT !
12
+ # It's a lot safer to put this information in a file called "api_key.yml" in the same
13
+ # directory as spec_helper.rb. This file is in the .gitignore list and so you won't
14
+ # accidentally commit your API key that way. Leave the hash below for FAKE data (which
15
+ # is what you'll usually spec with anyways), unless $mock_services == false.
16
+ #
17
+ $user_id = cred_hash['User ID'] || '01234567890'
18
+ $limited_api_key = cred_hash['Limited API Key'] || 'a_valid_limited_api_key'
19
+ $full_api_key = cred_hash['Full API Key'] || 'a_valid_full_api_key'
20
+ $character_id = cred_hash['Character ID'] || '0123456789'
21
+
22
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each { |f| require f }
@@ -0,0 +1,50 @@
1
+ class BehavesLikeRowset
2
+ attr_reader :failure_message, :negative_failure_message
3
+
4
+ def initialize(columns, &block)
5
+ @expected_columns = (columns.kind_of?(Array) ? columns : columns.split(/,/)).collect { |c| c.strip }
6
+ @block = block if block_given?
7
+ @missing = []
8
+ end
9
+
10
+ def matches?(target)
11
+ @target = target
12
+ check_for_column_mismatches
13
+
14
+ @target.each_with_index do |row, index|
15
+ @expected_columns.each do |column|
16
+ check_column(row, column)
17
+ end
18
+ return false if !check_for_missing(index)
19
+ @block.call(row) if @block
20
+ end
21
+ true
22
+ end
23
+
24
+ private
25
+ def check_for_missing(id)
26
+ if !@missing.empty?
27
+ @failure_message = "expected row #{id} in #{@target.inspect} to respond_to each of #{@missing.inspect}"
28
+ @negative_failure_message = "expected row in #{@target.inspect} not to respond_to each of #{@missing.inspect}"
29
+ return false
30
+ end
31
+ true
32
+ end
33
+
34
+ def check_for_column_mismatches
35
+ @target.columns.should == @expected_columns
36
+ end
37
+
38
+ def check_column(row, column)
39
+ check_for_response(row, column)
40
+ check_for_response(row, column.underscore)
41
+ end
42
+
43
+ def check_for_response(row, method_name)
44
+ @missing << method_name if !row.respond_to?(method_name)
45
+ end
46
+ end
47
+
48
+ def behave_like_rowset(expected_columns, &block)
49
+ BehavesLikeRowset.new(expected_columns, &block)
50
+ end
@@ -0,0 +1,7 @@
1
+ class TrustController < ApplicationController
2
+ requires_trust
3
+
4
+ def index
5
+ render :nothing => true
6
+ end
7
+ end
@@ -0,0 +1,41 @@
1
+ module MockAPIHelpers
2
+ def eve_api(options = {})
3
+ @eve_api ||= {}
4
+ @eve_api[ActiveSupport::Cache.expand_cache_key(options)] ||= ::Eve::API.new(options)
5
+ end
6
+ alias api eve_api
7
+
8
+ def mock_response_body(base, service = nil)
9
+ if service.nil?
10
+ fi = File.expand_path File.join("spec/support", base)
11
+ else
12
+ namespace = base
13
+ service = service.to_s.underscore
14
+ fi = File.expand_path File.join("spec/support/xml", namespace.to_s, "#{service}.xml")
15
+ end
16
+ raise "Cannot find mock request for (#{base}, #{service}) - expected it in #{fi}" unless File.file?(fi)
17
+ return File.read(fi)
18
+ end
19
+
20
+ def mock_http_response(base, service = nil)
21
+ mock = mock('Net::HTTPOK', :body => mock_response_body(base, service))
22
+ end
23
+
24
+ def mock_service(base, options = {}, more_options = {})
25
+ options = { :service => options } unless options.kind_of?(Hash)
26
+ options.merge! more_options
27
+ if $mock_services
28
+ Net::HTTP.should_receive(:post_form).any_number_of_times.and_return(mock_http_response(base,
29
+ options[:service]))
30
+ end
31
+ if options[:service] && eve_api(options).respond_to?(base)
32
+ eve_api(options).send(base).send(options[:service], *(options[:args] || []))
33
+ else
34
+ eve_api(options)
35
+ end
36
+ end
37
+ end
38
+
39
+ Spec::Runner.configure do |config|
40
+ config.include(MockAPIHelpers)
41
+ end
@@ -0,0 +1,15 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="1">
3
+ <currentTime>2007-12-12 11:48:50</currentTime>
4
+ <result>
5
+ <rowset name="characters" key="characterID" columns="name,characterID,corporationName,corporationID">
6
+ <row name="Mary" characterID="150267069"
7
+ corporationName="Starbase Anchoring Corp" corporationID="150279367" />
8
+ <row name="Marcus" characterID="150302299"
9
+ corporationName="Marcus Corp" corporationID="150333466" />
10
+ <row name="Dieinafire" characterID="150340823"
11
+ corporationName="Center for Advanced Studies" corporationID="1000169" />
12
+ </rowset>
13
+ </result>
14
+ <cachedUntil>2007-12-12 12:48:50</cachedUntil>
15
+ </eveapi>
@@ -0,0 +1,10 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2007-12-16 11:55:31</currentTime>
4
+ <result>
5
+ <rowset name="accounts" key="accountID" columns="accountID,accountKey,balance">
6
+ <row accountID="4807144" accountKey="1000" balance="209127823.31" />
7
+ </rowset>
8
+ </result>
9
+ <cachedUntil>2007-12-16 12:10:31</cachedUntil>
10
+ </eveapi>
@@ -0,0 +1,50 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="1">
3
+ <currentTime>2007-12-01 17:55:07</currentTime>
4
+ <result>
5
+ <rowset name="assets" key="itemID" columns="itemID,locationID,typeID,quantity,flag,singleton">
6
+ <row itemID="150354641" locationID="30000380" typeID="11019" quantity="1" flag="0" singleton="1">
7
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
8
+ <row itemID="150354709" typeID="16275" quantity="200000" flag="5" singleton="0" />
9
+ <row itemID="150354710" typeID="16272" quantity="150000" flag="5" singleton="0" />
10
+ <row itemID="150354711" typeID="16273" quantity="150000" flag="5" singleton="0" />
11
+ <row itemID="150354712" typeID="24597" quantity="1000" flag="5" singleton="0" />
12
+ <row itemID="150354713" typeID="24596" quantity="1000" flag="5" singleton="0" />
13
+ <row itemID="150354714" typeID="24595" quantity="1000" flag="5" singleton="0" />
14
+ <row itemID="150354715" typeID="24594" quantity="1000" flag="5" singleton="0" />
15
+ <row itemID="150354716" typeID="24593" quantity="1000" flag="5" singleton="0" />
16
+ <row itemID="150354717" typeID="24592" quantity="1000" flag="5" singleton="0" />
17
+ <row itemID="150354718" typeID="16274" quantity="450000" flag="5" singleton="0" />
18
+ <row itemID="150354719" typeID="9848" quantity="1000" flag="5" singleton="0" />
19
+ <row itemID="150354720" typeID="9832" quantity="8000" flag="5" singleton="0" />
20
+ <row itemID="150354721" typeID="3689" quantity="5000" flag="5" singleton="0" />
21
+ <row itemID="150354722" typeID="3683" quantity="25000" flag="5" singleton="0" />
22
+ <row itemID="150354723" typeID="44" quantity="4000" flag="5" singleton="0" />
23
+ </rowset>
24
+ </row>
25
+ <row itemID="150354706" locationID="30001984" typeID="11019" quantity="1" flag="0" singleton="1">
26
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
27
+ <row itemID="150354741" typeID="24593" quantity="400" flag="5" singleton="0" />
28
+ <row itemID="150354742" typeID="24592" quantity="400" flag="5" singleton="0" />
29
+ <row itemID="150354755" typeID="16275" quantity="199000" flag="5" singleton="0" />
30
+ <row itemID="150354837" typeID="24597" quantity="400" flag="5" singleton="0" />
31
+ <row itemID="150354838" typeID="24596" quantity="400" flag="5" singleton="0" />
32
+ <row itemID="150354839" typeID="24595" quantity="400" flag="5" singleton="0" />
33
+ <row itemID="150354840" typeID="24594" quantity="400" flag="5" singleton="0" />
34
+ <row itemID="150356329" typeID="14343" quantity="1" flag="5" singleton="0" />
35
+ </rowset>
36
+ </row>
37
+ <row itemID="150212056" locationID="60001078" typeID="25851" quantity="10" flag="4" singleton="0" />
38
+ <row itemID="150212057" locationID="60001078" typeID="20424" quantity="20" flag="4" singleton="0" />
39
+ <row itemID="150212058" locationID="60001078" typeID="20421" quantity="20" flag="4" singleton="0" />
40
+ <row itemID="150357641" locationID="30001984" typeID="23" quantity="1" flag="0" singleton="1">
41
+ <rowset name="contents" key="itemID" columns="itemID,typeID,quantity,flag,singleton">
42
+ <row itemID="150357740" typeID="16275" quantity="9166" flag="0" singleton="0" />
43
+ </rowset>
44
+ </row>
45
+ <row itemID="150212062" locationID="60001078" typeID="944" quantity="1" flag="4" singleton="1" />
46
+ <row itemID="150212063" locationID="60001078" typeID="597" quantity="1" flag="4" singleton="0" />
47
+ </rowset>
48
+ </result>
49
+ <cachedUntil>2007-12-02 16:55:07</cachedUntil>
50
+ </eveapi>
@@ -0,0 +1,65 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2009-08-26 12:00:09</currentTime>
4
+ <result>
5
+ <characterID>150337897</characterID>
6
+ <name>corpslave</name>
7
+ <race>Minmatar</race>
8
+ <bloodLine>Brutor</bloodLine>
9
+ <gender>Female</gender>
10
+ <corporationName>corpexport Corp</corporationName>
11
+ <corporationID>150337746</corporationID>
12
+ <cloneName>Clone Grade Pi</cloneName>
13
+ <cloneSkillPoints>54600000</cloneSkillPoints>
14
+ <balance>190210393.87</balance>
15
+ <attributeEnhancers>
16
+ <intelligenceBonus>
17
+ <augmentatorName>Snake Delta</augmentatorName>
18
+ <augmentatorValue>3</augmentatorValue>
19
+ </intelligenceBonus>
20
+ <memoryBonus>
21
+ <augmentatorName>Memory Augmentation - Basic</augmentatorName>
22
+ <augmentatorValue>3</augmentatorValue>
23
+ </memoryBonus>
24
+ </attributeEnhancers>
25
+ <attributes>
26
+ <intelligence>6</intelligence>
27
+ <memory>4</memory>
28
+ <charisma>7</charisma>
29
+ <perception>12</perception>
30
+ <willpower>10</willpower>
31
+ </attributes>
32
+ <rowset name="skills" key="typeID" columns="typeID,skillpoints,level,unpublished">
33
+ <row typeID="3431" skillpoints="8000" level="3"/>
34
+ <row typeID="3413" skillpoints="8000" level="3"/>
35
+ <row typeID="21059" skillpoints="500" level="1"/>
36
+ <row typeID="3416" skillpoints="8000" level="3"/>
37
+ <row typeID="3445" skillpoints="277578" unpublished="1"/>
38
+ </rowset>
39
+ <rowset name="certificates" key="certificateID" columns="certificateID">
40
+ <row certificateID="1"/>
41
+ <row certificateID="5"/>
42
+ <row certificateID="19"/>
43
+ <row certificateID="239"/>
44
+ <row certificateID="282"/>
45
+ <row certificateID="32"/>
46
+ <row certificateID="258"/>
47
+ </rowset>
48
+ <rowset name="corporationRoles" key="roleID" columns="roleID,roleName">
49
+ <row roleID="1" roleName="roleDirector" />
50
+ </rowset>
51
+ <rowset name="corporationRolesAtHQ" key="roleID" columns="roleID,roleName">
52
+ <row roleID="1" roleName="roleDirector" />
53
+ </rowset>
54
+ <rowset name="corporationRolesAtBase" key="roleID" columns="roleID,roleName">
55
+ <row roleID="1" roleName="roleDirector" />
56
+ </rowset>
57
+ <rowset name="corporationRolesAtOther" key="roleID" columns="roleID,roleName">
58
+ <row roleID="1" roleName="roleDirector" />
59
+ </rowset>
60
+ <rowset name="corporationTitles" key="titleID" columns="titleID,titleName">
61
+ <row titleID="1" titleName="Member" />
62
+ </rowset>
63
+ </result>
64
+ <cachedUntil>2009-08-26 13:00:09</cachedUntil>
65
+ </eveapi>
@@ -0,0 +1,20 @@
1
+ <?xml version='1.0' encoding='UTF-8'?>
2
+ <eveapi version="2">
3
+ <currentTime>2008-07-10 13:12:49</currentTime>
4
+ <result>
5
+ <factionID>500001</factionID>
6
+ <factionName>Caldari State</factionName>
7
+ <enlisted>2008-06-10 22:10:00</enlisted>
8
+ <currentRank>4</currentRank>
9
+
10
+ <highestRank>4</highestRank>
11
+ <killsYesterday>0</killsYesterday>
12
+ <killsLastWeek>0</killsLastWeek>
13
+ <killsTotal>0</killsTotal>
14
+ <victoryPointsYesterday>0</victoryPointsYesterday>
15
+ <victoryPointsLastWeek>1044</victoryPointsLastWeek>
16
+
17
+ <victoryPointsTotal>0</victoryPointsTotal>
18
+ </result>
19
+ <cachedUntil>2008-07-10 14:12:49</cachedUntil>
20
+ </eveapi>