eve_online 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -0
  3. data/.travis.yml +18 -2
  4. data/Gemfile +5 -1
  5. data/README.md +203 -15
  6. data/eve_online.gemspec +1 -1
  7. data/gemfiles/activesupport_42.gemfile +5 -0
  8. data/gemfiles/activesupport_50.gemfile +5 -0
  9. data/lib/eve_online.rb +9 -0
  10. data/lib/eve_online/account/api_key_info.rb +3 -3
  11. data/lib/eve_online/account/characters.rb +2 -2
  12. data/lib/eve_online/account/status.rb +3 -3
  13. data/lib/eve_online/base.rb +1 -1
  14. data/lib/eve_online/base_xml.rb +8 -2
  15. data/lib/eve_online/blueprint.rb +2 -2
  16. data/lib/eve_online/bookmark.rb +2 -2
  17. data/lib/eve_online/bookmark_folder.rb +29 -2
  18. data/lib/eve_online/character.rb +2 -2
  19. data/lib/eve_online/character_implants.rb +23 -0
  20. data/lib/eve_online/character_jump_clones.rb +23 -0
  21. data/lib/eve_online/character_skills.rb +23 -0
  22. data/lib/eve_online/characters/account_balance.rb +1 -1
  23. data/lib/eve_online/characters/asset_list.rb +2 -2
  24. data/lib/eve_online/characters/blueprints.rb +2 -2
  25. data/lib/eve_online/characters/bookmarks.rb +2 -2
  26. data/lib/eve_online/characters/character_sheet.rb +184 -0
  27. data/lib/eve_online/characters/medals.rb +21 -0
  28. data/lib/eve_online/characters/skill_in_training.rb +4 -4
  29. data/lib/eve_online/characters/standings.rb +65 -0
  30. data/lib/eve_online/characters/upcoming_calendar_events.rb +2 -2
  31. data/lib/eve_online/event.rb +3 -3
  32. data/lib/eve_online/implant.rb +24 -0
  33. data/lib/eve_online/item.rb +2 -2
  34. data/lib/eve_online/jump_clone.rb +34 -0
  35. data/lib/eve_online/server/status.rb +1 -1
  36. data/lib/eve_online/skill.rb +34 -0
  37. data/lib/eve_online/standing.rb +29 -0
  38. data/lib/eve_online/version.rb +1 -1
  39. data/mutant.sh +4 -0
  40. metadata +16 -4
@@ -12,7 +12,7 @@ module EveOnline
12
12
  @v_code = v_code
13
13
  end
14
14
 
15
- def as_json(*args)
15
+ def as_json
16
16
  {
17
17
  current_time: current_time,
18
18
  paid_until: paid_until,
@@ -24,11 +24,11 @@ module EveOnline
24
24
  end
25
25
 
26
26
  def paid_until
27
- @paid_until ||= ActiveSupport::TimeZone['UTC'].parse(result.fetch('paidUntil'))
27
+ @paid_until ||= parse_datetime_with_timezone(result.fetch('paidUntil'))
28
28
  end
29
29
 
30
30
  def create_date
31
- @create_date ||= ActiveSupport::TimeZone['UTC'].parse(result.fetch('createDate'))
31
+ @create_date ||= parse_datetime_with_timezone(result.fetch('createDate'))
32
32
  end
33
33
 
34
34
  def logon_count
@@ -7,7 +7,7 @@ module EveOnline
7
7
  end
8
8
 
9
9
  def user_agent
10
- @user_agent ||= "EveOnline API (https://github.com/biow0lf/eve_online) v#{ EveOnline::VERSION }"
10
+ @user_agent ||= "EveOnline API (https://github.com/biow0lf/eve_online) v#{ VERSION }"
11
11
  end
12
12
 
13
13
  def content
@@ -14,11 +14,11 @@ module EveOnline
14
14
  end
15
15
 
16
16
  def cached_until
17
- @cached_until ||= ActiveSupport::TimeZone['UTC'].parse(eveapi.fetch('cachedUntil'))
17
+ @cached_until ||= parse_datetime_with_timezone(eveapi.fetch('cachedUntil'))
18
18
  end
19
19
 
20
20
  def current_time
21
- @current_time ||= ActiveSupport::TimeZone['UTC'].parse(eveapi.fetch('currentTime'))
21
+ @current_time ||= parse_datetime_with_timezone(eveapi.fetch('currentTime'))
22
22
  end
23
23
 
24
24
  def version
@@ -28,5 +28,11 @@ module EveOnline
28
28
  def eveapi
29
29
  @eveapi ||= response.fetch('eveapi')
30
30
  end
31
+
32
+ private
33
+
34
+ def parse_datetime_with_timezone(value)
35
+ ActiveSupport::TimeZone['UTC'].parse(value)
36
+ end
31
37
  end
32
38
  end
@@ -2,11 +2,11 @@ module EveOnline
2
2
  class Blueprint
3
3
  attr_reader :options
4
4
 
5
- def initialize(options = {})
5
+ def initialize(options)
6
6
  @options = options
7
7
  end
8
8
 
9
- def as_json(*args)
9
+ def as_json
10
10
  {
11
11
  item_id: item_id,
12
12
  location_id: location_id,
@@ -2,11 +2,11 @@ module EveOnline
2
2
  class Bookmark
3
3
  attr_reader :options
4
4
 
5
- def initialize(options = {})
5
+ def initialize(options)
6
6
  @options = options
7
7
  end
8
8
 
9
- def as_json(*args)
9
+ def as_json
10
10
  {
11
11
  bookmark_id: bookmark_id,
12
12
  creator_id: creator_id,
@@ -2,11 +2,11 @@ module EveOnline
2
2
  class BookmarkFolder
3
3
  attr_reader :options
4
4
 
5
- def initialize(options = {})
5
+ def initialize(options)
6
6
  @options = options
7
7
  end
8
8
 
9
- def as_json(*args)
9
+ def as_json
10
10
  {
11
11
  folder_id: folder_id,
12
12
  folder_name: folder_name
@@ -20,5 +20,32 @@ module EveOnline
20
20
  def folder_name
21
21
  @folder_name ||= options.fetch('@folderName')
22
22
  end
23
+
24
+ def bookmarks
25
+ @bookmarks ||= begin
26
+ case row
27
+ when Hash
28
+ [Bookmark.new(row)]
29
+ when Array
30
+ bookmarks = []
31
+ row.each do |bookmark|
32
+ bookmarks << Bookmark.new(bookmark)
33
+ end
34
+ bookmarks
35
+ else
36
+ raise ArgumentError
37
+ end
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def rowset
44
+ @rowset ||= options.fetch('rowset')
45
+ end
46
+
47
+ def row
48
+ @row ||= rowset.fetch('row')
49
+ end
23
50
  end
24
51
  end
@@ -2,11 +2,11 @@ module EveOnline
2
2
  class Character
3
3
  attr_reader :options
4
4
 
5
- def initialize(options = {})
5
+ def initialize(options)
6
6
  @options = options
7
7
  end
8
8
 
9
- def as_json(*args)
9
+ def as_json
10
10
  {
11
11
  character_id: character_id,
12
12
  character_name: character_name,
@@ -0,0 +1,23 @@
1
+ module EveOnline
2
+ class CharacterImplants
3
+ attr_reader :result
4
+
5
+ def initialize(result)
6
+ @result = result
7
+ end
8
+
9
+ def implants
10
+ output = []
11
+ rowset.each do |implant|
12
+ output << Implant.new(implant)
13
+ end
14
+ output
15
+ end
16
+
17
+ private
18
+
19
+ def rowset
20
+ @rowset ||= result.fetch('rowset').reject { |a| a.fetch('@name') != 'implants' }.first.fetch('row')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module EveOnline
2
+ class CharacterJumpClones
3
+ attr_reader :result
4
+
5
+ def initialize(result)
6
+ @result = result
7
+ end
8
+
9
+ def jump_clones
10
+ output = []
11
+ rowset.each do |jump_clone|
12
+ output << JumpClone.new(jump_clone)
13
+ end
14
+ output
15
+ end
16
+
17
+ private
18
+
19
+ def rowset
20
+ @rowset ||= result.fetch('rowset').reject { |a| a.fetch('@name') != 'jumpClones' }.first.fetch('row')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module EveOnline
2
+ class CharacterSkills
3
+ attr_reader :result
4
+
5
+ def initialize(result)
6
+ @result = result
7
+ end
8
+
9
+ def skills
10
+ output = []
11
+ rowset.each do |skill|
12
+ output << Skill.new(skill)
13
+ end
14
+ output
15
+ end
16
+
17
+ private
18
+
19
+ def rowset
20
+ @rowset ||= result.fetch('rowset').reject { |a| a.fetch('@name') != 'skills' }.first.fetch('row')
21
+ end
22
+ end
23
+ end
@@ -13,7 +13,7 @@ module EveOnline
13
13
  @character_id = character_id
14
14
  end
15
15
 
16
- def as_json(*args)
16
+ def as_json
17
17
  {
18
18
  account_id: account_id,
19
19
  account_key: account_key,
@@ -17,11 +17,11 @@ module EveOnline
17
17
  def assets
18
18
  case row
19
19
  when Hash
20
- [EveOnline::Item.new(row)]
20
+ [Item.new(row)]
21
21
  when Array
22
22
  output = []
23
23
  row.each do |item|
24
- output << EveOnline::Item.new(item)
24
+ output << Item.new(item)
25
25
  end
26
26
  output
27
27
  else
@@ -16,11 +16,11 @@ module EveOnline
16
16
  def blueprints
17
17
  case row
18
18
  when Hash
19
- [EveOnline::Blueprint.new(row)]
19
+ [Blueprint.new(row)]
20
20
  when Array
21
21
  output = []
22
22
  row.each do |blueprint|
23
- output << EveOnline::Blueprint.new(blueprint)
23
+ output << Blueprint.new(blueprint)
24
24
  end
25
25
  output
26
26
  else
@@ -17,11 +17,11 @@ module EveOnline
17
17
  @bookmark_folders ||= begin
18
18
  case row
19
19
  when Hash
20
- [EveOnline::BookmarkFolder.new(row)]
20
+ [BookmarkFolder.new(row)]
21
21
  when Array
22
22
  bookmark_folders = []
23
23
  row.each do |bookmark_folder|
24
- bookmark_folders << EveOnline::BookmarkFolder.new(bookmark_folder)
24
+ bookmark_folders << BookmarkFolder.new(bookmark_folder)
25
25
  end
26
26
  bookmark_folders
27
27
  else
@@ -13,9 +13,193 @@ module EveOnline
13
13
  @character_id = character_id
14
14
  end
15
15
 
16
+ def as_json
17
+ {
18
+ character_id: character_id,
19
+ name: name,
20
+ home_station_id: home_station_id,
21
+ dob: dob,
22
+ race: race,
23
+ blood_line_id: blood_line_id,
24
+ blood_line: blood_line,
25
+ ancestry_id: ancestry_id,
26
+ ancestry: ancestry,
27
+ gender: gender,
28
+ corporation_name: corporation_name,
29
+ corporation_id: corporation_id,
30
+ alliance_name: alliance_name,
31
+ alliance_id: alliance_id,
32
+ faction_name: faction_name,
33
+ faction_id: faction_id,
34
+ clone_type_id: clone_type_id,
35
+ clone_name: clone_name,
36
+ clone_skill_points: clone_skill_points,
37
+ free_skill_points: free_skill_points,
38
+ free_respecs: free_respecs,
39
+ clone_jump_date: clone_jump_date,
40
+ last_respec_date: last_respec_date,
41
+ last_timed_respec: last_timed_respec,
42
+ remote_station_date: remote_station_date
43
+ }
44
+ end
45
+
46
+ def name
47
+ @name ||= result.fetch('name')
48
+ end
49
+
50
+ def home_station_id
51
+ @home_station_id ||= result.fetch('homeStationID').to_i
52
+ end
53
+
54
+ def dob
55
+ @dob ||= parse_datetime_with_timezone(result.fetch('DoB'))
56
+ end
57
+
58
+ def race
59
+ @race ||= result.fetch('race')
60
+ end
61
+
62
+ def blood_line_id
63
+ @blood_line_id ||= result.fetch('bloodLineID').to_i
64
+ end
65
+
66
+ def blood_line
67
+ @blood_line ||= result.fetch('bloodLine')
68
+ end
69
+
70
+ def ancestry_id
71
+ @ancestry_id ||= result.fetch('ancestryID').to_i
72
+ end
73
+
74
+ def ancestry
75
+ @ancestry ||= result.fetch('ancestry')
76
+ end
77
+
78
+ def gender
79
+ @gender ||= result.fetch('gender').downcase.to_sym
80
+ end
81
+
82
+ def corporation_name
83
+ @corporation_name ||= result.fetch('corporationName')
84
+ end
85
+
86
+ def corporation_id
87
+ @corporation_id ||= result.fetch('corporationID').to_i
88
+ end
89
+
90
+ def alliance_name
91
+ # TODO: Corporation "Federal Navy Academy" doesn't have allianceName in response
92
+ @alliance_name ||= result.fetch('allianceName')
93
+ end
94
+
95
+ def alliance_id
96
+ # TODO: Corporation "Federal Navy Academy" doesn't have allianceID in response
97
+ @alliance_id ||= result.fetch('allianceID').to_i
98
+ end
99
+
100
+ def faction_name
101
+ # TODO: Corporation "Federal Navy Academy" doesn't have factionName in response
102
+ @faction_name ||= result.fetch('factionName')
103
+ end
104
+
105
+ def faction_id
106
+ # TODO: Corporation "Federal Navy Academy" doesn't have factionID in response
107
+ @faction_id ||= result.fetch('factionID').to_i
108
+ end
109
+
110
+ def clone_type_id
111
+ @clone_type_id ||= result.fetch('cloneTypeID').to_i
112
+ end
113
+
114
+ def clone_name
115
+ @clone_name ||= result.fetch('cloneName')
116
+ end
117
+
118
+ def clone_skill_points
119
+ @clone_skill_points ||= result.fetch('cloneSkillPoints').to_i
120
+ end
121
+
122
+ def free_skill_points
123
+ @free_skill_points ||= result.fetch('freeSkillPoints').to_i
124
+ end
125
+
126
+ def free_respecs
127
+ @free_respecs ||= result.fetch('freeRespecs').to_i
128
+ end
129
+
130
+ def clone_jump_date
131
+ @clone_jump_date ||= parse_datetime_with_timezone(result.fetch('cloneJumpDate'))
132
+ end
133
+
134
+ def last_respec_date
135
+ @last_respec_date ||= parse_datetime_with_timezone(result.fetch('lastRespecDate'))
136
+ end
137
+
138
+ def last_timed_respec
139
+ @last_timed_respec ||= parse_datetime_with_timezone(result.fetch('lastTimedRespec'))
140
+ end
141
+
142
+ def remote_station_date
143
+ @remote_station_date ||= parse_datetime_with_timezone(result.fetch('remoteStationDate'))
144
+ end
145
+
146
+ def jump_activation
147
+ @jump_activation ||= parse_datetime_with_timezone(result.fetch('jumpActivation'))
148
+ end
149
+
150
+ def jump_fatigue
151
+ @jump_fatigue ||= parse_datetime_with_timezone(result.fetch('jumpFatigue'))
152
+ end
153
+
154
+ def jump_last_update
155
+ @jump_last_update ||= parse_datetime_with_timezone(result.fetch('jumpLastUpdate'))
156
+ end
157
+
158
+ def balance
159
+ @balance ||= result.fetch('balance')
160
+ end
161
+
162
+ def base_intelligence
163
+ @intelligence ||= attributes.fetch('intelligence').to_i
164
+ end
165
+
166
+ def base_memory
167
+ @memory ||= attributes.fetch('memory').to_i
168
+ end
169
+
170
+ def base_charisma
171
+ @charisma ||= attributes.fetch('charisma').to_i
172
+ end
173
+
174
+ def base_perception
175
+ @perception ||= attributes.fetch('perception').to_i
176
+ end
177
+
178
+ def base_willpower
179
+ @willpower ||= attributes.fetch('willpower').to_i
180
+ end
181
+
182
+ def implants
183
+ @implants ||= CharacterImplants.new(result).implants
184
+ end
185
+
186
+ def skills
187
+ @skills ||= CharacterSkills.new(result).skills
188
+ end
189
+
190
+ def jump_clones
191
+ @jump_clones ||= CharacterJumpClones.new(result).jump_clones
192
+ end
193
+
16
194
  def url
17
195
  "#{ API_ENDPOINT }?keyID=#{ key_id }&vCode=#{ v_code }&characterID=#{ character_id }"
18
196
  end
197
+
198
+ private
199
+
200
+ def attributes
201
+ @attributes ||= result.fetch('attributes')
202
+ end
19
203
  end
20
204
  end
21
205
  end