eveapi 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +8 -8
  2. data/.document +0 -4
  3. data/.gitignore +2 -0
  4. data/.yardopts +1 -0
  5. data/CONTRIBUTING.md +31 -0
  6. data/README.md +90 -56
  7. data/Rakefile +5 -41
  8. data/gemspec.yml +1 -1
  9. data/lib/eveapi.rb +17 -31
  10. data/lib/eveapi/alliance.rb +21 -8
  11. data/lib/eveapi/character.rb +44 -14
  12. data/lib/eveapi/client.rb +141 -15
  13. data/lib/eveapi/crest.rb +24 -10
  14. data/lib/eveapi/request.rb +5 -0
  15. data/lib/eveapi/util.rb +60 -3
  16. data/lib/eveapi/version.rb +1 -1
  17. data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_corporations_to_be_an_Array.yml +194 -206
  18. data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_find_to_fill_short_name_and_name_values.yml +25 -31
  19. data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_info_to_be_a_Hash.yml +195 -207
  20. data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_new_with_id_argument_to_create_an_Alliance.yml +18 -18
  21. data/spec/cassettes/EVEApi/EVEApi_Alliance/expect_Alliance_to_h_to_be_a_Hash.yml +192 -204
  22. data/spec/cassettes/EVEApi/EVEApi_Character/expect_Character_new_args_to_create_a_Character.yml +28 -28
  23. data/spec/cassettes/EVEApi/EVEApi_Character/expect_a_Character_account_balance_to_return_a_Hash.yml +32 -32
  24. data/spec/cassettes/EVEApi/{EVEApi_Client/calling_api_method_account_characters.yml → EVEApi_Character/raises_ArgumentError_on_non-existing_instance_variable.yml} +54 -23
  25. data/spec/cassettes/EVEApi/{EVEApi_Client/calling_api_method_char_wallet_journal.yml → EVEApi_Character/sets_Client_instance_variable_if_method_argument_key_matches_name.yml} +85 -23
  26. data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_account_account_status.yml → calling_api_method_account_status.yml} +22 -22
  27. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_api_methods.yml +288 -0
  28. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_call_list.yml +288 -0
  29. data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_char_notifications.yml → calling_api_method_characters.yml} +58 -24
  30. data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_account_api_key_info.yml → calling_api_method_key_info.yml} +23 -23
  31. data/spec/cassettes/EVEApi/EVEApi_Client/{calling_api_method_server_server_status.yml → calling_api_method_server_status.yml} +23 -23
  32. data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_characters_to_handle_mutiple_characters_differently.yml +18 -18
  33. data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_charcaters_to_succeed.yml +18 -18
  34. data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_connection_to_be_an_Excon_Connection.yml +18 -18
  35. data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_new_to_succeed.yml +18 -18
  36. data/spec/cassettes/EVEApi/EVEApi_Client/expect_Client_params_to_return_an_empty_hash_when_on_no_param.yml +18 -18
  37. data/spec/cassettes/EVEApi/EVEApi_Client/{expect_check_path_to_return_a_non-empty_String_for_a_muti-part_name.yml → expect_Symbol_to_path_to_return_a_String_for_a_muti-part_name.yml} +18 -18
  38. data/spec/cassettes/EVEApi/EVEApi_Client/{expect_check_path_to_return_an_empty_String_for_a_one_part_name.yml → expect_Symbol_to_path_to_return_an_empty_String_for_a_one_part_name.yml} +18 -18
  39. data/spec/cassettes/EVEApi/EVEApi_Client/expect_api_methods_to_return_an_Array_of_method_symobls.yml +23 -23
  40. data/spec/cassettes/EVEApi/EVEApi_Client/expect_calling_a_non-existing_API_method_to_fail.yml +21 -21
  41. data/spec/cassettes/EVEApi/EVEApi_Client/expect_calling_an_existing_API_method_to_succeed.yml +23 -23
  42. data/spec/cassettes/EVEApi/EVEApi_Crest/expect_Crest_alliances_to_be_an_Array.yml +192 -204
  43. data/spec/cassettes/EVEApi/EVEApi_Crest/expect_Crest_new_to_succeed.yml +18 -18
  44. data/spec/cassettes/EVEApi/EVEApi_Crest/expect_Crest_types_to_be_an_Array.yml +25972 -0
  45. data/spec/cassettes/EVEApi/EVEApi_Crest/expect_details_to_return_Hash_when_called_on_Hash_with_href_key.yml +26023 -0
  46. data/spec/cassettes/EVEApi/EVEApi_Request/expect_there_to_be_a_EVEApi_Request_class.yml +18 -18
  47. data/spec/eve_api_spec.rb +19 -5
  48. metadata +31 -41
  49. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_account_balance.yml +0 -160
  50. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_asset_list.yml +0 -207
  51. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_character_sheet.yml +0 -207
  52. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_contact_list.yml +0 -175
  53. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_contact_notifications.yml +0 -159
  54. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_contracts.yml +0 -159
  55. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_industry_jobs.yml +0 -159
  56. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_mail_messages.yml +0 -159
  57. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_mailing_lists.yml +0 -159
  58. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_market_orders.yml +0 -159
  59. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_medals.yml +0 -160
  60. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_research.yml +0 -159
  61. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_skill_in_training.yml +0 -159
  62. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_skill_queue.yml +0 -159
  63. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_standings.yml +0 -173
  64. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_upcoming_calendar_events.yml +0 -169
  65. data/spec/cassettes/EVEApi/EVEApi_Client/calling_api_method_char_wallet_transactions.yml +0 -159
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YmY0MjNhN2NlZmU0NmRlMmJlYzlkNGFlOTY4NDZkOTA4NzU0MDk2NA==
4
+ YjcxM2EzYTRlNzY2ZTY4MmJkZDRiYWUyOTUxMjc5YTRhYmFkNWY5Ng==
5
5
  data.tar.gz: !binary |-
6
- YWJmOWI0MDUyMzVkOGQyZDM1NjljNzE1N2Q4NTgyNTJmOTk0YTM5MQ==
6
+ NjZhMWI5ZjYwNjVlNzQzYjkwNDI4YTZiZDJmNjRmYmI0ZmU1NWVlNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjczYTQwYmE1OWI5NDY0OGE3ODYzMjhjMmUxMGU5MWM2MzJkODU4MjU0MGQ1
10
- NDE2ZTdiYzVjZDBlYjZiNzRmODY3ZWRmOGYxM2U4MTQyZmI3Y2IxMzAxY2U4
11
- MTU2ZmM5NGFkNmM2NzA1ZTNiM2E0ZGJjYzg5ZGQ0ZmJiMjAzMWI=
9
+ MDExYTlhZGE4MGJhYTExZGYyNzYyMDlmYjUzMTgzOWE5MWJlNWVlOTMxNGE2
10
+ YzhiODc2NTRjNDdhYjQxOWU5Y2ZlN2Q5YmMzNTIxZjkwYWM2YWE0NzEyZTZk
11
+ MjY4ZmIyODU1NzhiYmIxMTU5MWU5ZjgyZTVkYzIzYzViYTU1NmM=
12
12
  data.tar.gz: !binary |-
13
- ODY5MzMyNDVlZjllNTA4NWE1ODdmYmE1OTM4ODQ2ZDNlN2YwYzFjYmNmMjA2
14
- NTZhMDQxNGYzMzVkNDZmNDE3NzZlNDkyNmM0NGUzNmIyNmZmYzU3NWRmNjVj
15
- MjI0YzMzMTA4NzE0NmFlYzMwYzFjOWE2NjExNWVmMDY1OGY4YTg=
13
+ YWM1NjVkNzBhODg2MDQ0ZWYwMWYxYzNkYTE4NzI4MjdkOWM4M2QyMzVmYmM2
14
+ M2JlYjNkOTljYjFiZDA1ZjI0ZmVjMWE3NDIyMjg5ZDNjMWQ0MzU4ZDNmN2Rm
15
+ M2M1MzJhNGE0NzI1OTM0N2Q4NjQzNDY4MWI0NjVkNDg0MWVhNDQ=
data/.document CHANGED
@@ -1,5 +1 @@
1
1
  lib/**/*.rb
2
- README.md
3
- ChangeLog.md
4
-
5
- LICENSE.txt
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
+ /.yardoc
1
2
  /.bundle
2
3
  /Gemfile.lock
3
4
  /html/
4
5
  /pkg/
5
6
  /vendor/cache/*.gem
6
7
  /coverage
8
+ /doc/yard
@@ -0,0 +1 @@
1
+ --output-dir ./doc/yard
@@ -0,0 +1,31 @@
1
+ 1. Fork the repo <iframe src="https://ghbtns.com/github-btn.html?user=aladac&repo=eveapi&type=fork&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>
2
+ 2. Create a feature branch with a reasonable name like `add_client_foobar_method`
3
+
4
+ ```
5
+ $ git checkout -b add_client_foobar_method
6
+
7
+ ```
8
+
9
+ 3. Push your changes to your repo
10
+
11
+ ```
12
+ $ git push
13
+ Counting objects: 7, done.
14
+ Delta compression using up to 4 threads.
15
+ Compressing objects: 100% (2/2), done.
16
+ Writing objects: 100% (3/3), 269 bytes | 0 bytes/s, done.
17
+ Total 3 (delta 1), reused 0 (delta 0)
18
+ To git@github.com:saidenpl/eveapi.git
19
+ * [new branch] add_client_foobar_method -> add_client_foobar_method
20
+ ```
21
+
22
+ 4. Make a pull request to this repos `master`
23
+ - Click on `Compare & pull request`
24
+
25
+ ![pull request 1](https://i.imgur.com/8YUuQ76.png)
26
+
27
+ - Make sure that `aladac/eveapi` and your feature branch are selectedd
28
+ - Write a comment
29
+ - Click `Create pull request`
30
+
31
+ ![pull request 2](https://i.imgur.com/WNvaMsm.png)
data/README.md CHANGED
@@ -10,51 +10,57 @@
10
10
  [![Latest Version Downloads](https://img.shields.io/gem/dtv/eveapi.svg)](https://rubygems.org/gems/eveapi)
11
11
 
12
12
 
13
- ## Disclaimer!
14
- *This work in progress in a very early stage. Not documented. Only a couple of methods are tested.*
15
-
16
- ~~Most~~ working methods names can be listed by calling ~~`EVEApi::Client#api_methods`~~ `EVEApi::Client#working_methods`
17
-
18
- Because of the way the paths are being built from the method names - some methods may look funky eq. `server_server_status`.
19
-
20
- ## Auto Methods
21
- These methods are procedurally handled.
22
-
23
- ```ruby
24
- def method_missing(name, *_args, &_block)
25
- fail 'Invalid Method Name' if check_path(name).empty?
26
- check_path(name)
27
- http = connection.get(path: check_path(name), query: params)
28
- request = EVEApi::Request.new(http)
29
- request.result
30
- end
31
- ```
32
-
33
- The ones listed below are known to work, provided the instance variables listed in the *Requires* column are supplied.
34
-
35
- | Method Name | Requires | Output Class |
36
- | ------------- | ------------- | ------------- |
37
- | [account_api_key_info](https://github.com/aladac/eveapi/wiki/account_api_key_info) | `key_id`, `vcode` | `Hash` |
38
- | [account_account_status](https://github.com/aladac/eveapi/wiki/account_account_status) | `key_id`, `vcode` | `Hash` |
39
- | [account_characters](https://github.com/aladac/eveapi/wiki/account_characters) | `key_id`, `vcode` | `Array` |
40
- | [server_server_status](https://github.com/aladac/eveapi/wiki/server_server_status) | - | `Hash` |
41
- | [char_wallet_transactions](https://github.com/aladac/eveapi/wiki/char_wallet_transactions) | `key_id`, `vcode`, `character_id` | `Array` |
42
- | [char_wallet_journal](https://github.com/aladac/eveapi/wiki/char_wallet_journal) | `key_id`, `vcode`, `character_id` | `Array` |
43
- | [char_standings](https://github.com/aladac/eveapi/wiki/char_standings) | `key_id`, `vcode`, `character_id` | `Array` |
44
- | [char_skill_queue](https://github.com/aladac/eveapi/wiki/char_skill_queue) | `key_id`, `vcode`, `character_id` | `Array` |
45
- | [char_skill_in_training](https://github.com/aladac/eveapi/wiki/char_skill_in_training) | `key_id`, `vcode`, `character_id` | `Hash` |
46
- | [char_research](https://github.com/aladac/eveapi/wiki/char_research) | `key_id`, `vcode`, `character_id` | `Array` |
47
- | [char_notifications](https://github.com/aladac/eveapi/wiki/char_notifications) | `key_id`, `vcode`, `character_id` | `Array` |
48
- | [char_medals](https://github.com/aladac/eveapi/wiki/char_medals) | `key_id`, `vcode`, `character_id` | `Hash` |
49
- | [char_market_orders](https://github.com/aladac/eveapi/wiki/char_market_orders) | `key_id`, `vcode`, `character_id` | `Array` |
50
- | [char_mail_messages](https://github.com/aladac/eveapi/wiki/char_mail_messages) | `key_id`, `vcode`, `character_id` | `Array` |
51
- | [char_mailing_lists](https://github.com/aladac/eveapi/wiki/char_mailing_lists) | `key_id`, `vcode`, `character_id` | `Array` |
52
- | [char_industry_jobs](https://github.com/aladac/eveapi/wiki/char_industry_jobs) | `key_id`, `vcode`, `character_id` | `Array` |
53
- | [char_contact_notifications](https://github.com/aladac/eveapi/wiki/char_contact_notifications) | `key_id`, `vcode`, `character_id` | `Array` |
54
- | [char_contact_list](https://github.com/aladac/eveapi/wiki/char_contact_list) | `key_id`, `vcode`, `character_id` | `Array` |
55
- | [char_character_sheet](https://github.com/aladac/eveapi/wiki/char_character_sheet) | `key_id`, `vcode`, `character_id` | `Hash` |
56
- | [char_asset_list](https://github.com/aladac/eveapi/wiki/char_asset_list) | `key_id`, `vcode`, `character_id` | `Array` |
57
- | [char_account_balance](https://github.com/aladac/eveapi/wiki/char_account_balance) | `key_id`, `vcode`, `character_id` | `Array` |
13
+ ## General
14
+
15
+ Working methods names can be listed by calling `EVEApi::Client#working_methods`.
16
+
17
+ ## Working methods
18
+
19
+ Check out [rubydoc.info](http://www.rubydoc.info/github/aladac/eveapi) for the documentation.
20
+
21
+ *Legacy methods are available [here](https://github.com/aladac/eveapi/wiki)*
22
+
23
+ #### Client
24
+ - `EVEApi::Client.new`
25
+ - `EVEApi::Client#characters`
26
+ - `EVEApi::Client#server_status`
27
+ - `EVEApi::Client#call_list`
28
+ - `EVEApi::Client#working_methods`
29
+ - `EVEApi::Client#account_status`
30
+ - `EVEApi::Client#key_info`
31
+
32
+ #### Character
33
+
34
+ - `EVEApi::Character#wallet_journal`
35
+ - `EVEApi::Character#contracts`
36
+ - `EVEApi::Character#wallet_transactions`
37
+ - `EVEApi::Character#upcoming_calendar_events`
38
+ - `EVEApi::Character#standings`
39
+ - `EVEApi::Character#skill_queue`
40
+ - `EVEApi::Character#skill_in_training`
41
+ - `EVEApi::Character#research`
42
+ - `EVEApi::Character#notifications`
43
+ - `EVEApi::Character#medals`
44
+ - `EVEApi::Character#market_orders`
45
+ - `EVEApi::Character#mail_messages`
46
+ - `EVEApi::Character#mailing_lists`
47
+ - `EVEApi::Character#industry_jobs`
48
+ - `EVEApi::Character#contact_notifications`
49
+ - `EVEApi::Character#contact_list`
50
+ - `EVEApi::Character#character_sheet`
51
+ - `EVEApi::Character#asset_list`
52
+ - `EVEApi::Character#account_balance`
53
+
54
+ #### Crest
55
+ - `EVEApi::Crest.new`
56
+ - `EVEApi::Crest#allainces`
57
+ - `EVEApi::Crest#types`
58
+
59
+ #### Alliance
60
+ - `EVEApi::Alliance.find(id = nil)`
61
+ - `EVEApi::Alliance#info`
62
+ - `EVEApi::Alliance#corporations`
63
+ - `EVEApi::Alliance#to_h`
58
64
 
59
65
  ## CREST
60
66
  Rudimentary CREST support is added via the `EVEApi::Crest` class.
@@ -110,22 +116,50 @@ Uses [excon](https://github.com/excon/excon), [crack](https://github.com/jnunem
110
116
 
111
117
  ## Examples
112
118
 
119
+ ### Getting Implant names for character
120
+ ```ruby
121
+ require 'eveapi'
122
+ # initialize the client with key_id, vcode, character_id
123
+ client = Client.new(4278167, "supersecretstuff", 95512059)
124
+ # => #<EVEApi::Client:0x007fe349ad0d48 ... >
125
+ client.characters.first.character_sheet[:implants].map { |i| i[:type_name] }
126
+ # => [
127
+ # [0] "Social Adaptation Chip - Basic",
128
+ # [1] "Cybernetic Subprocessor - Standard",
129
+ # [2] "Memory Augmentation - Standard",
130
+ # [3] "Neural Boost - Standard",
131
+ # [4] "Ocular Filter - Standard"
132
+ # ]
133
+ ```
134
+
135
+ ### Server status
136
+ ```ruby
137
+ require 'eveapi'
138
+ client.server_status
139
+ # => {
140
+ # :server_open => "True",
141
+ # :online_players => "32500"
142
+ # }
143
+ ```
144
+
145
+ ### Showing accounts characters
146
+
113
147
  ```ruby
114
148
  require 'eveapi'
115
149
  client = EVEApi::Client.new
116
150
  client.key_id = 4278167
117
151
  client.vcode = "7QJg6p5BZNpDBp2FIz39dGwa7jnNaXAuYyLUVitlTQ3rY60VPBcaTpJVfYIkiW5l"
118
- client.account_characters
119
- => {
120
- :name => "Quint Slade",
121
- :character_id => "95512059",
122
- :corporation_name => "Imperial Academy",
123
- :corporation_id => "1000166",
124
- :alliance_id => "0",
125
- :alliance_name => "",
126
- :faction_id => "0",
127
- :faction_name => ""
128
- }
152
+ client.characters
153
+ # => {
154
+ # :name => "Quint Slade",
155
+ # :character_id => "95512059",
156
+ # :corporation_name => "Imperial Academy",
157
+ # :corporation_id => "1000166",
158
+ # :alliance_id => "0",
159
+ # :alliance_name => "",
160
+ # :faction_id => "0",
161
+ # :faction_name => ""
162
+ # }
129
163
  ```
130
164
 
131
165
  ## Requirements
data/Rakefile CHANGED
@@ -1,7 +1,4 @@
1
1
  # encoding: utf-8
2
-
3
- require 'rubygems'
4
-
5
2
  begin
6
3
  require 'bundler/setup'
7
4
  rescue LoadError => e
@@ -9,12 +6,12 @@ rescue LoadError => e
9
6
  end
10
7
 
11
8
  require 'rake'
12
-
9
+ require 'rubygems'
13
10
  require 'bundler/gem_tasks'
14
11
 
15
- require 'rdoc/task'
16
- RDoc::Task.new
17
- task doc: :rdoc
12
+ require 'yard'
13
+ YARD::Rake::YardocTask.new
14
+ task doc: :yard
18
15
 
19
16
  require 'rspec/core/rake_task'
20
17
  RSpec::Core::RakeTask.new
@@ -37,39 +34,6 @@ task :console do
37
34
  Pry.start
38
35
  end
39
36
 
40
- desc 'Generate method docs'
41
- task :methods do
42
- Bundler.require
43
- require 'awesome_print'
44
- EVEApi::Client.new.working_methods.each do |m|
45
- p m
46
- @client = EVEApi::Client.new
47
- @client.key_id = 4_278_167
48
- @client.vcode = 'supersecretstuff'
49
- @client.character_id = '95512059'
50
- out = ''
51
- begin
52
- out << @client.api_methods_hash.find { |me| me[:name] == m }[:desc]
53
- rescue
54
- out << "TODO Description (#{m})"
55
- end
56
- out << "\n\n"
57
- out << "```ruby\n@client = EVEApi::Client.new\n"
58
- out << "@client.key_id = 4278167\n"
59
- out << "@client.vcode = 'supersecretstuff'\n\n"
60
- out << "@client.#{m}\n\n"
61
- begin
62
- out << @client.send(m).pretty_inspect
63
- out << '```'
64
- f = File.new("./doc/wiki/#{m}.md", 'w')
65
- f.puts out
66
- f.close
67
- rescue => e
68
- puts e.message
69
- end
70
- end
71
- end
72
-
73
37
  task c: :console
74
38
  task test: :spec
75
- task default: [:spec, :rubocop]
39
+ task default: [:spec, :"rubocop:auto_correct", :rubocop]
@@ -18,9 +18,9 @@ development_dependencies:
18
18
  bundler: ~> 1
19
19
  codeclimate-test-reporter: ~> 0.1
20
20
  rake: ~> 10.0
21
- rdoc: ~> 4.0
22
21
  rspec: ~> 3.0
23
22
  vcr: ~> 2.9
24
23
  webmock: ~> 1
25
24
  pry: ~> 0.10
26
25
  awesome_print: ~> 1.6
26
+ yard: ~> 0.8
@@ -1,6 +1,23 @@
1
1
  lib_dir = File.dirname(__FILE__)
2
2
  $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
3
3
 
4
+ # EVEApi namespace
5
+ module EVEApi
6
+ # CREST API endpoint
7
+ CREST_ENDPOINT = 'https://public-crest.eveonline.com/'
8
+ # v2 API endpoint
9
+ API_ENDPOINT = 'https://api.eveonline.com'
10
+ # Client methods implemented
11
+ WORKING_METHODS = [
12
+ :account_status,
13
+ :server_status,
14
+ :characters,
15
+ :api_methods,
16
+ :key_info,
17
+ :call_list
18
+ ]
19
+ end
20
+
4
21
  require 'eveapi/version'
5
22
  require 'eveapi/client'
6
23
  require 'eveapi/request'
@@ -12,34 +29,3 @@ require 'excon'
12
29
  require 'crack'
13
30
 
14
31
  include EVEApi::Util
15
-
16
- # EVEApi namespace
17
- module EVEApi
18
- CREST_ENDPOINT = 'https://public-crest.eveonline.com/'
19
- API_ENDPOINT = 'https://api.eveonline.com'
20
- WORKING_METHODS = [
21
- :account_api_key_info,
22
- :account_account_status,
23
- :account_characters,
24
- :server_server_status,
25
- :char_contracts,
26
- :char_wallet_transactions,
27
- :char_wallet_journal,
28
- :char_upcoming_calendar_events,
29
- :char_standings,
30
- :char_skill_queue,
31
- :char_skill_in_training,
32
- :char_research,
33
- :char_notifications,
34
- :char_medals,
35
- :char_market_orders,
36
- :char_mail_messages,
37
- :char_mailing_lists,
38
- :char_industry_jobs,
39
- :char_contact_notifications,
40
- :char_contact_list,
41
- :char_character_sheet,
42
- :char_asset_list,
43
- :char_account_balance
44
- ]
45
- end
@@ -1,14 +1,15 @@
1
1
  module EVEApi
2
2
  # Alliance CREST object
3
3
  class Alliance
4
- BASE_URI = 'https://public-crest.eveonline.com/alliances/'
4
+ # CREST alliances endpoint
5
+ BASE_URI = CREST_ENDPOINT + 'alliances/'
5
6
 
6
- attr_accessor :href
7
- attr_accessor :id_str
8
- attr_accessor :short_name
9
- attr_accessor :name
10
- attr_accessor :id
11
- attr_accessor :info
7
+ attr_accessor :href # @return [String] href
8
+ attr_accessor :id_str # @return [String] String ID
9
+ attr_accessor :short_name # @return [String] Short name
10
+ attr_accessor :name # @return [String] Name
11
+ attr_accessor :id # @return [Fixnum] ID
12
+ attr_accessor :info # @return [Hash] Info
12
13
 
13
14
  def initialize(args)
14
15
  case args
@@ -23,20 +24,32 @@ module EVEApi
23
24
  end
24
25
  end
25
26
 
27
+ # Get detailed Alliance info from CREST
28
+ #
29
+ # @return [Hash] Alliance info
26
30
  def info
27
- @info ||= convert_hash_keys json_get(href)
31
+ @info ||= json_get(href)
28
32
  end
29
33
 
34
+ # Show corporations belonging to the Alliance
35
+ #
36
+ # @return [Array] List of corporations
30
37
  def corporations
31
38
  info[:corporations]
32
39
  end
33
40
 
41
+ # Get Alliance from CREST by ID
42
+ #
43
+ # @return [Alliance] Alliance object
34
44
  def find
35
45
  @short_name = info[:short_name]
36
46
  @name = info[:name]
37
47
  self
38
48
  end
39
49
 
50
+ # Converts {Alliance} to {Hash}
51
+ #
52
+ # @return [Hash] Alliance in {Hash} format
40
53
  def to_h
41
54
  h = {}
42
55
  instance_variables.each do |var|
@@ -1,17 +1,17 @@
1
1
  module EVEApi
2
2
  # Character class
3
3
  class Character
4
- attr_accessor :name
5
- attr_accessor :character_id
6
- attr_accessor :corporation_name
7
- attr_accessor :corporation_id
8
- attr_accessor :alliance_id
9
- attr_accessor :alliance_name
10
- attr_accessor :faction_id
11
- attr_accessor :faction_name
12
- attr_accessor :key_id
13
- attr_accessor :vcode
14
- attr_accessor :client
4
+ attr_accessor :name # @return [String] Character name
5
+ attr_accessor :character_id # @return [String] Character ID
6
+ attr_accessor :corporation_name # @return [String] Corporation name
7
+ attr_accessor :corporation_id # @return [String] Corporation ID
8
+ attr_accessor :alliance_id # @return [String] Alliance ID
9
+ attr_accessor :alliance_name # @return [String] Alliance name
10
+ attr_accessor :faction_id # @return [String] Faction ID
11
+ attr_accessor :faction_name # @return [String] Faction name
12
+ attr_accessor :key_id # @return [String] API key ID
13
+ attr_accessor :vcode # @return [String] API key verification code
14
+ attr_accessor :client # @return [Client] {EVEApi::Client} instance
15
15
 
16
16
  def initialize(args = {})
17
17
  @key_id = args[:key_id]
@@ -30,10 +30,11 @@ module EVEApi
30
30
  @client ||= Client.new(key_id, vcode, character_id)
31
31
  end
32
32
 
33
+ # Character methods known to work
33
34
  METHODS = [
35
+ :wallet_journal,
34
36
  :contracts,
35
37
  :wallet_transactions,
36
- :wallet_journal,
37
38
  :upcoming_calendar_events,
38
39
  :standings,
39
40
  :skill_queue,
@@ -52,9 +53,38 @@ module EVEApi
52
53
  :account_balance
53
54
  ]
54
55
 
56
+ # Converts the {Character} method name to {Client} method name
57
+ #
58
+ # @param [Symbol] method_name +Character+ method name
59
+ # @return [Symbol] {Client} method name
60
+ def client_method(method_name)
61
+ "char_#{method_name}".to_sym
62
+ end
63
+ private :client_method
64
+
65
+ # Process arguments for Client method
66
+ #
67
+ # @param [Hash] args = {} Client method arguments
68
+ def process_args(args = {})
69
+ args.each_pair do |k, v|
70
+ fail ArgumentError unless client.respond_to?(k)
71
+ client.instance_variable_set("@#{k}".to_sym, v)
72
+ end
73
+ end
74
+ private :process_args
75
+
76
+ # Send a method to a {Client} instance
77
+ #
78
+ # @param [String] method_name Method name
79
+ # @param [Hash] args = {} Method arguments
80
+ def send_client_method(method_name, args = {})
81
+ process_args(args)
82
+ client.send(client_method(method_name))
83
+ end
84
+ private :send_client_method
85
+
55
86
  METHODS.each do |m|
56
- name = "char_#{m}".to_sym
57
- define_method(m) { client.send(name) }
87
+ define_method(m) { |args = {}| send_client_method(m, args) }
58
88
  end
59
89
  end
60
90
  end