eve_online 0.20.0 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +12 -7
  4. data/CHANGELOG.md +26 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +30 -27
  7. data/Gemfile.mutant.lock +20 -25
  8. data/README.md +41 -21
  9. data/TODO.md +1 -0
  10. data/eve_online.gemspec +8 -2
  11. data/lib/eve_online.rb +9 -4
  12. data/lib/eve_online/esi/alliance.rb +4 -2
  13. data/lib/eve_online/esi/alliances.rb +4 -0
  14. data/lib/eve_online/esi/base.rb +7 -11
  15. data/lib/eve_online/esi/character.rb +1 -2
  16. data/lib/eve_online/esi/character_assets.rb +8 -6
  17. data/lib/eve_online/esi/character_assets_locations.rb +8 -6
  18. data/lib/eve_online/esi/character_assets_names.rb +8 -6
  19. data/lib/eve_online/esi/character_attributes.rb +1 -2
  20. data/lib/eve_online/esi/character_blueprints.rb +8 -6
  21. data/lib/eve_online/esi/character_bookmark_folders.rb +8 -6
  22. data/lib/eve_online/esi/character_bookmarks.rb +8 -6
  23. data/lib/eve_online/esi/character_calendar.rb +8 -6
  24. data/lib/eve_online/esi/character_clones.rb +9 -8
  25. data/lib/eve_online/esi/character_fatigue.rb +1 -2
  26. data/lib/eve_online/esi/character_industry_jobs.rb +8 -6
  27. data/lib/eve_online/esi/character_killmails_recent.rb +8 -6
  28. data/lib/eve_online/esi/character_location.rb +1 -2
  29. data/lib/eve_online/esi/character_loyalty_points.rb +8 -6
  30. data/lib/eve_online/esi/character_notifications.rb +9 -6
  31. data/lib/eve_online/esi/character_online.rb +1 -2
  32. data/lib/eve_online/esi/character_orders.rb +8 -6
  33. data/lib/eve_online/esi/character_portrait.rb +1 -2
  34. data/lib/eve_online/esi/character_ship.rb +1 -2
  35. data/lib/eve_online/esi/character_skill_queue.rb +8 -6
  36. data/lib/eve_online/esi/character_skills.rb +8 -6
  37. data/lib/eve_online/esi/character_standings.rb +8 -6
  38. data/lib/eve_online/esi/character_wallet_journal.rb +8 -6
  39. data/lib/eve_online/esi/corporation.rb +5 -3
  40. data/lib/eve_online/esi/corporation_blueprints.rb +8 -6
  41. data/lib/eve_online/esi/corporation_industry_jobs.rb +8 -6
  42. data/lib/eve_online/esi/corporation_killmails_recent.rb +8 -6
  43. data/lib/eve_online/esi/corporation_orders.rb +8 -6
  44. data/lib/eve_online/esi/dogma_attribute.rb +1 -2
  45. data/lib/eve_online/esi/dogma_effect.rb +1 -2
  46. data/lib/eve_online/esi/market_history.rb +8 -6
  47. data/lib/eve_online/esi/models/alliance.rb +4 -1
  48. data/lib/eve_online/esi/models/corporation.rb +4 -1
  49. data/lib/eve_online/esi/models/model_with_etag.rb +13 -0
  50. data/lib/eve_online/esi/models/star.rb +4 -1
  51. data/lib/eve_online/esi/models/stargate.rb +4 -1
  52. data/lib/eve_online/esi/response_with_etag.rb +11 -0
  53. data/lib/eve_online/esi/server_status.rb +1 -2
  54. data/lib/eve_online/esi/{ancestries.rb → universe_ancestries.rb} +13 -7
  55. data/lib/eve_online/esi/{bloodlines.rb → universe_bloodlines.rb} +13 -7
  56. data/lib/eve_online/esi/universe_constellation.rb +1 -2
  57. data/lib/eve_online/esi/{factions.rb → universe_factions.rb} +13 -7
  58. data/lib/eve_online/esi/{races.rb → universe_races.rb} +13 -7
  59. data/lib/eve_online/esi/universe_region.rb +1 -2
  60. data/lib/eve_online/esi/universe_star.rb +5 -3
  61. data/lib/eve_online/esi/universe_stargate.rb +4 -3
  62. data/lib/eve_online/esi/universe_station.rb +1 -2
  63. data/lib/eve_online/esi/universe_system_jumps.rb +8 -6
  64. data/lib/eve_online/esi/universe_system_kills.rb +8 -6
  65. data/lib/eve_online/esi/universe_type.rb +1 -2
  66. data/lib/eve_online/esi/war_killmails.rb +8 -6
  67. data/lib/eve_online/version.rb +1 -1
  68. metadata +15 -38
  69. data/server.http +0 -0
data/TODO.md CHANGED
@@ -5,3 +5,4 @@
5
5
  * Add caching timeout
6
6
  * Add 420 error status
7
7
  * Add errors limits
8
+ * gem install fasterer
data/eve_online.gemspec CHANGED
@@ -15,6 +15,14 @@ Gem::Specification.new do |spec|
15
15
  spec.homepage = 'https://github.com/evemonk/eve_online'
16
16
  spec.license = 'MIT'
17
17
 
18
+ spec.metadata = {
19
+ 'bug_tracker_uri' => 'https://github.com/evemonk/eve_online/issues',
20
+ 'changelog_uri' => 'https://github.com/evemonk/eve_online/blob/master/CHANGELOG.md',
21
+ 'documentation_uri' => 'https://github.com/evemonk/eve_online/blob/master/README.md',
22
+ 'homepage_uri' => 'https://github.com/evemonk/eve_online',
23
+ 'source_code_uri' => 'https://github.com/evemonk/eve_online'
24
+ }
25
+
18
26
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin)/}) }
19
27
  spec.require_paths = ['lib']
20
28
 
@@ -30,6 +38,4 @@ Gem::Specification.new do |spec|
30
38
  spec.add_development_dependency 'mdl'
31
39
 
32
40
  spec.add_runtime_dependency 'activesupport', '>= 4.2.0'
33
- spec.add_runtime_dependency 'json'
34
- spec.add_runtime_dependency 'memoist'
35
41
  end
data/lib/eve_online.rb CHANGED
@@ -17,6 +17,8 @@ require 'eve_online/exceptions/no_content'
17
17
  # ESI API
18
18
  require 'eve_online/esi/base'
19
19
 
20
+ require 'eve_online/esi/response_with_etag'
21
+
20
22
  require 'eve_online/esi/alliances'
21
23
  require 'eve_online/esi/alliance'
22
24
  require 'eve_online/esi/alliance_corporations'
@@ -71,21 +73,21 @@ require 'eve_online/esi/character_skills'
71
73
 
72
74
  require 'eve_online/esi/server_status'
73
75
 
74
- require 'eve_online/esi/ancestries'
76
+ require 'eve_online/esi/universe_ancestries'
75
77
  require 'eve_online/esi/universe_asteroid_belt'
76
- require 'eve_online/esi/bloodlines'
78
+ require 'eve_online/esi/universe_bloodlines'
77
79
  require 'eve_online/esi/universe_categories'
78
80
  require 'eve_online/esi/universe_category'
79
81
  require 'eve_online/esi/universe_constellations'
80
82
  require 'eve_online/esi/universe_constellation'
81
- require 'eve_online/esi/factions'
83
+ require 'eve_online/esi/universe_factions'
82
84
  require 'eve_online/esi/universe_graphics'
83
85
  require 'eve_online/esi/universe_graphic'
84
86
  require 'eve_online/esi/universe_groups'
85
87
  require 'eve_online/esi/universe_group'
86
88
  require 'eve_online/esi/universe_planet'
87
89
  require 'eve_online/esi/universe_moon'
88
- require 'eve_online/esi/races'
90
+ require 'eve_online/esi/universe_races'
89
91
  require 'eve_online/esi/universe_regions'
90
92
  require 'eve_online/esi/universe_region'
91
93
  require 'eve_online/esi/universe_stargate'
@@ -107,6 +109,9 @@ require 'eve_online/esi/war_killmails'
107
109
 
108
110
  # Models
109
111
  require 'eve_online/esi/models/base'
112
+
113
+ require 'eve_online/esi/models/model_with_etag'
114
+
110
115
  require 'eve_online/esi/models/position'
111
116
  require 'eve_online/esi/models/loyalty_point'
112
117
  require 'eve_online/esi/models/skill_queue_entry'
@@ -7,6 +7,8 @@ module EveOnline
7
7
  class Alliance < Base
8
8
  extend Forwardable
9
9
 
10
+ include ResponseWithEtag
11
+
10
12
  API_ENDPOINT = 'https://esi.evetech.net/v3/alliances/%<alliance_id>s/?datasource=%<datasource>s'
11
13
 
12
14
  attr_reader :alliance_id
@@ -19,10 +21,10 @@ module EveOnline
19
21
 
20
22
  def_delegators :model, :as_json, :creator_corporation_id, :creator_id,
21
23
  :date_founded, :executor_corporation_id, :faction_id,
22
- :name, :ticker
24
+ :name, :ticker, :etag
23
25
 
24
26
  def model
25
- @model ||= Models::Alliance.new(response)
27
+ @model ||= Models::Alliance.new(response_with_etag)
26
28
  end
27
29
 
28
30
  def scope; end
@@ -9,6 +9,10 @@ module EveOnline
9
9
  response
10
10
  end
11
11
 
12
+ def etag
13
+ current_etag
14
+ end
15
+
12
16
  def scope; end
13
17
 
14
18
  def url
@@ -3,15 +3,12 @@
3
3
  require 'net/http'
4
4
  require 'openssl'
5
5
  require 'json'
6
- require 'memoist'
7
6
  require 'active_support/time'
8
7
 
9
8
  module EveOnline
10
9
  module ESI
11
10
  class Base
12
- extend Memoist
13
-
14
- attr_reader :token, :parser, :_read_timeout, :_open_timeout, :etag,
11
+ attr_reader :token, :parser, :_read_timeout, :_open_timeout, :_etag,
15
12
  :datasource, :language
16
13
 
17
14
  def initialize(options = {})
@@ -19,7 +16,7 @@ module EveOnline
19
16
  @parser = options.fetch(:parser, JSON)
20
17
  @_read_timeout = options.fetch(:read_timeout, 60)
21
18
  @_open_timeout = options.fetch(:open_timeout, 60)
22
- @etag = options.fetch(:etag, nil)
19
+ @_etag = options.fetch(:etag, nil)
23
20
  @datasource = options.fetch(:datasource, 'tranquility')
24
21
  @language = options.fetch(:language, 'en-us')
25
22
  end
@@ -57,7 +54,7 @@ module EveOnline
57
54
  end
58
55
 
59
56
  def current_etag
60
- resource.header['Etag']&.gsub('"', '')
57
+ resource.header['Etag']&.gsub('W/', '')&.gsub('"', '')
61
58
  end
62
59
 
63
60
  def page; end
@@ -86,7 +83,7 @@ module EveOnline
86
83
  request['Accept'] = 'application/json'
87
84
  request['Accept-Language'] = language
88
85
  request['Authorization'] = "Bearer #{ token }" if token
89
- request['If-None-Match'] = "\"#{ etag }\"" if etag
86
+ request['If-None-Match'] = _etag if _etag
90
87
  request['Content-Type'] = 'application/json' if http_method == 'Post'
91
88
  request.body = payload if http_method == 'Post'
92
89
 
@@ -102,13 +99,14 @@ module EveOnline
102
99
  @resource ||= client.request(request)
103
100
  end
104
101
 
105
- def no_content?
102
+ def not_modified?
106
103
  resource.is_a?(Net::HTTPNotModified)
107
104
  end
108
105
 
109
106
  def content
110
107
  case resource
111
108
  when Net::HTTPOK
109
+ # TODO: memoize resource.body as @content
112
110
  resource.body
113
111
  when Net::HTTPCreated
114
112
  # TODO: write
@@ -141,12 +139,10 @@ module EveOnline
141
139
  rescue Net::OpenTimeout, Net::ReadTimeout
142
140
  raise EveOnline::Exceptions::Timeout
143
141
  end
144
- memoize :content
145
142
 
146
143
  def response
147
- parser.parse(content)
144
+ @response ||= parser.parse(content)
148
145
  end
149
- memoize :response
150
146
 
151
147
  private
152
148
 
@@ -22,9 +22,8 @@ module EveOnline
22
22
  :gender, :name, :race_id, :security_status
23
23
 
24
24
  def model
25
- Models::Character.new(response)
25
+ @model ||= Models::Character.new(response)
26
26
  end
27
- memoize :model
28
27
 
29
28
  def scope; end
30
29
 
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def assets
18
- output = []
19
- response.each do |asset|
20
- output << Models::Asset.new(asset)
21
- end
22
- output
18
+ @assets ||=
19
+ begin
20
+ output = []
21
+ response.each do |asset|
22
+ output << Models::Asset.new(asset)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :assets
25
27
 
26
28
  def scope
27
29
  'esi-assets.read_assets.v1'
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def assets_locations
18
- output = []
19
- response.each do |asset_location|
20
- output << Models::AssetLocation.new(asset_location)
21
- end
22
- output
18
+ @assets_locations ||=
19
+ begin
20
+ output = []
21
+ response.each do |asset_location|
22
+ output << Models::AssetLocation.new(asset_location)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :assets_locations
25
27
 
26
28
  def http_method
27
29
  'Post'
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def assets_names
18
- output = []
19
- response.each do |asset_name|
20
- output << Models::AssetName.new(asset_name)
21
- end
22
- output
18
+ @assets_names ||=
19
+ begin
20
+ output = []
21
+ response.each do |asset_name|
22
+ output << Models::AssetName.new(asset_name)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :assets_names
25
27
 
26
28
  def http_method
27
29
  'Post'
@@ -22,9 +22,8 @@ module EveOnline
22
22
  :memory, :perception, :willpower
23
23
 
24
24
  def model
25
- Models::Attributes.new(response)
25
+ @model ||= Models::Attributes.new(response)
26
26
  end
27
- memoize :model
28
27
 
29
28
  def scope
30
29
  'esi-skills.read_skills.v1'
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def blueprints
18
- output = []
19
- response.each do |blueprint|
20
- output << Models::Blueprint.new(blueprint)
21
- end
22
- output
18
+ @blueprints ||=
19
+ begin
20
+ output = []
21
+ response.each do |blueprint|
22
+ output << Models::Blueprint.new(blueprint)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :blueprints
25
27
 
26
28
  def scope
27
29
  'esi-characters.read_blueprints.v1'
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def bookmark_folders
18
- output = []
19
- response.each do |bookmark_folder|
20
- output << Models::BookmarkFolder.new(bookmark_folder)
21
- end
22
- output
18
+ @bookmark_folders ||=
19
+ begin
20
+ output = []
21
+ response.each do |bookmark_folder|
22
+ output << Models::BookmarkFolder.new(bookmark_folder)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :bookmark_folders
25
27
 
26
28
  def scope
27
29
  'esi-bookmarks.read_character_bookmarks.v1'
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def bookmarks
18
- output = []
19
- response.each do |bookmark|
20
- output << Models::Bookmark.new(bookmark)
21
- end
22
- output
18
+ @bookmarks ||=
19
+ begin
20
+ output = []
21
+ response.each do |bookmark|
22
+ output << Models::Bookmark.new(bookmark)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :bookmarks
25
27
 
26
28
  def scope
27
29
  'esi-bookmarks.read_character_bookmarks.v1'
@@ -14,13 +14,15 @@ module EveOnline
14
14
  end
15
15
 
16
16
  def events
17
- output = []
18
- response.each do |event|
19
- output << Models::Event.new(event)
20
- end
21
- output
17
+ @events ||=
18
+ begin
19
+ output = []
20
+ response.each do |event|
21
+ output << Models::Event.new(event)
22
+ end
23
+ output
24
+ end
22
25
  end
23
- memoize :events
24
26
 
25
27
  def scope
26
28
  'esi-calendar.read_calendar_events.v1'
@@ -14,18 +14,19 @@ module EveOnline
14
14
  end
15
15
 
16
16
  def home_location
17
- Models::HomeLocation.new(response['home_location'])
17
+ @home_location ||= Models::HomeLocation.new(response['home_location'])
18
18
  end
19
- memoize :home_location
20
19
 
21
20
  def jump_clones
22
- output = []
23
- response['jump_clones'].each do |jump_clone|
24
- output << Models::JumpClone.new(jump_clone)
25
- end
26
- output
21
+ @jump_clones ||=
22
+ begin
23
+ output = []
24
+ response['jump_clones'].each do |jump_clone|
25
+ output << Models::JumpClone.new(jump_clone)
26
+ end
27
+ output
28
+ end
27
29
  end
28
- memoize :jump_clones
29
30
 
30
31
  def last_clone_jump_date
31
32
  last_clone_jump_date = response['last_clone_jump_date']
@@ -21,9 +21,8 @@ module EveOnline
21
21
  :last_jump_date, :last_update_date
22
22
 
23
23
  def model
24
- Models::Fatigue.new(response)
24
+ @model ||= Models::Fatigue.new(response)
25
25
  end
26
- memoize :model
27
26
 
28
27
  def scope
29
28
  'esi-characters.read_fatigue.v1'
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def jobs
18
- output = []
19
- response.each do |job|
20
- output << Models::CharacterIndustryJob.new(job)
21
- end
22
- output
18
+ @jobs ||=
19
+ begin
20
+ output = []
21
+ response.each do |job|
22
+ output << Models::CharacterIndustryJob.new(job)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :jobs
25
27
 
26
28
  def scope
27
29
  'esi-industry.read_character_jobs.v1'
@@ -15,13 +15,15 @@ module EveOnline
15
15
  end
16
16
 
17
17
  def killmails
18
- output = []
19
- response.each do |killmail|
20
- output << Models::KillmailShort.new(killmail)
21
- end
22
- output
18
+ @killmails ||=
19
+ begin
20
+ output = []
21
+ response.each do |killmail|
22
+ output << Models::KillmailShort.new(killmail)
23
+ end
24
+ output
25
+ end
23
26
  end
24
- memoize :killmails
25
27
 
26
28
  def scope
27
29
  'esi-killmails.read_killmails.v1'