admiral_stats_parser 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -9
- data/lib/admiral_stats_parser.rb +27 -10
- data/lib/admiral_stats_parser/parser/equip_list_info_parser.rb +39 -5
- data/lib/admiral_stats_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a71d8cdf82776ba8470feed23cbc37df7b153b4c
|
4
|
+
data.tar.gz: d538dd7b527aceb0818208b4817ae1526ed6d27b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83ad7209a9976a200cb2710617d633c543ba889be25824223d78b923b5b5e13390ba1a2729bb69cfc18bcaf04388c732ed57272b51ecb1b250480c1c825067c3
|
7
|
+
data.tar.gz: 1aebe7b34f6e301bbddd9cb2541d19c3703cb2e81081ee187f8773f538b2b095836937678b54d04f3a3b8cf49a179533b54882456d02853e092f34bb8c6e3cfd
|
data/README.md
CHANGED
@@ -63,7 +63,8 @@ AdmiralStatsParser は、以下の API version をサポートしています。
|
|
63
63
|
| 5 | 2016-12-21 〜 2017-02-13 |
|
64
64
|
| 6 | 2017-02-14 〜 2017-04-25 |
|
65
65
|
| 7 | 2017-04-26 〜 2017-05-31(第2回イベントの終了日) |
|
66
|
-
| 8 | 2017-06-01 〜 |
|
66
|
+
| 8 | 2017-06-01 〜 2017-07-30 |
|
67
|
+
| 9 | 2017-07-31 〜 |
|
67
68
|
|
68
69
|
各 API version でパースできる JSON の種類は以下の通りです。また、同じ情報でも、API version によって、含まれる情報量が異なる場合があります。その場合は Supported (1), Supported (2) のように記載して区別しています。
|
69
70
|
|
@@ -71,22 +72,23 @@ AdmiralStatsParser は、以下の API version をサポートしています。
|
|
71
72
|
|------------:|:-----|:-----|:-----|:-----|
|
72
73
|
| 1 | Supported (1) | Supported (1) | Supported (1) | Supported |
|
73
74
|
| 2 〜 6 | Supported (2) | Supported (2) | Supported (2) | Supported |
|
74
|
-
| 7 〜
|
75
|
+
| 7 〜 9 | Supported (3) | Supported (3) | Supported (2) | Supported |
|
75
76
|
|
76
77
|
| API version | 艦娘一覧 | 装備一覧 | イベント海域情報 |
|
77
78
|
|------------:|:-----|:-----|:-----|
|
78
79
|
| 1 | Unsupported | Unsupported | Unsupported |
|
79
|
-
| 2 | Supported (1) | Supported
|
80
|
-
| 3 | Supported (2) | Supported
|
81
|
-
| 4 | Supported (2) | Supported
|
82
|
-
| 5 〜 6 | Supported (3) | Supported
|
83
|
-
| 7 〜 8 | Supported (4) | Supported
|
80
|
+
| 2 | Supported (1) | Supported (1)| Unsupported |
|
81
|
+
| 3 | Supported (2) | Supported (1) | Unsupported |
|
82
|
+
| 4 | Supported (2) | Supported (1) | Supported (1) |
|
83
|
+
| 5 〜 6 | Supported (3) | Supported (1) | Supported (1) |
|
84
|
+
| 7 〜 8 | Supported (4) | Supported (1) | Supported (2) |
|
85
|
+
| 9 | Supported (4) | Supported (2) | Supported (2) |
|
84
86
|
|
85
87
|
| API version | 改装設計図一覧 |
|
86
88
|
|------------:|:-----|
|
87
89
|
| 1 〜 6 | Unsupported |
|
88
|
-
| 7
|
89
|
-
| 8 | Supported (2) |
|
90
|
+
| 7 | Supported (1) |
|
91
|
+
| 8 〜 9 | Supported (2) |
|
90
92
|
|
91
93
|
## Development
|
92
94
|
|
data/lib/admiral_stats_parser.rb
CHANGED
@@ -12,7 +12,7 @@ require 'admiral_stats_parser/parser/blueprint_list_info_parser'
|
|
12
12
|
module AdmiralStatsParser
|
13
13
|
# 最新の API バージョンを返します。
|
14
14
|
def self.get_latest_api_version
|
15
|
-
return
|
15
|
+
return 9
|
16
16
|
end
|
17
17
|
|
18
18
|
# エクスポート時刻を元に、API バージョンを推測して返します。
|
@@ -38,6 +38,9 @@ module AdmiralStatsParser
|
|
38
38
|
# version 8 の開始日
|
39
39
|
return 7 if exported_at < Time.parse('2017-06-01T07:00:00+0900')
|
40
40
|
|
41
|
+
# version 9 の開始日
|
42
|
+
return 8 if exported_at < Time.parse('2017-07-31T07:00:00+0900')
|
43
|
+
|
41
44
|
return self.get_latest_api_version
|
42
45
|
end
|
43
46
|
|
@@ -48,7 +51,7 @@ module AdmiralStatsParser
|
|
48
51
|
PersonalBasicInfoParser.parse(json, 1)
|
49
52
|
when 2..6
|
50
53
|
PersonalBasicInfoParser.parse(json, 2)
|
51
|
-
when 7..
|
54
|
+
when 7..9
|
52
55
|
PersonalBasicInfoParser.parse(json, 3)
|
53
56
|
else
|
54
57
|
raise 'unsupported API version'
|
@@ -62,7 +65,7 @@ module AdmiralStatsParser
|
|
62
65
|
AreaCaptureInfoParser.parse(json, 1)
|
63
66
|
when 2..6
|
64
67
|
AreaCaptureInfoParser.parse(json, 2)
|
65
|
-
when 7..
|
68
|
+
when 7..9
|
66
69
|
AreaCaptureInfoParser.parse(json, 3)
|
67
70
|
else
|
68
71
|
raise 'unsupported API version'
|
@@ -74,7 +77,7 @@ module AdmiralStatsParser
|
|
74
77
|
case api_version
|
75
78
|
when 1
|
76
79
|
TcBookInfoParser.parse(json, 1)
|
77
|
-
when 2..
|
80
|
+
when 2..9
|
78
81
|
TcBookInfoParser.parse(json, 2)
|
79
82
|
else
|
80
83
|
raise 'unsupported API version'
|
@@ -84,7 +87,7 @@ module AdmiralStatsParser
|
|
84
87
|
# 装備図鑑をパースします。
|
85
88
|
def self.parse_equip_book_info(json, api_version)
|
86
89
|
case api_version
|
87
|
-
when 1..
|
90
|
+
when 1..9
|
88
91
|
EquipBookInfoParser.parse(json)
|
89
92
|
else
|
90
93
|
raise 'unsupported API version'
|
@@ -102,7 +105,7 @@ module AdmiralStatsParser
|
|
102
105
|
CharacterListInfoParser.parse(json, 2)
|
103
106
|
when 5..6
|
104
107
|
CharacterListInfoParser.parse(json, 3)
|
105
|
-
when 7..
|
108
|
+
when 7..9
|
106
109
|
CharacterListInfoParser.parse(json, 4)
|
107
110
|
else
|
108
111
|
raise 'unsupported API version'
|
@@ -115,7 +118,21 @@ module AdmiralStatsParser
|
|
115
118
|
when 1
|
116
119
|
raise 'API version 1 does not support equip list info'
|
117
120
|
when 2..8
|
118
|
-
EquipListInfoParser.parse(json)
|
121
|
+
EquipListInfoParser.parse(json, 1)
|
122
|
+
when 9
|
123
|
+
EquipListInfoParser.parse(json, 2)
|
124
|
+
else
|
125
|
+
raise 'unsupported API version'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# 装備一覧をパースして、最大装備保有数のみを取得します。
|
130
|
+
def self.parse_max_slot_num(json, api_version)
|
131
|
+
case api_version
|
132
|
+
when 1..8
|
133
|
+
EquipListInfoParser.parse_max_slot_num(json, 1)
|
134
|
+
when 9
|
135
|
+
EquipListInfoParser.parse_max_slot_num(json, 2)
|
119
136
|
else
|
120
137
|
raise 'unsupported API version'
|
121
138
|
end
|
@@ -128,7 +145,7 @@ module AdmiralStatsParser
|
|
128
145
|
raise "API version #{api_version} does not support event info"
|
129
146
|
when 4..6
|
130
147
|
EventInfoParser.parse(json, 1)
|
131
|
-
when 7..
|
148
|
+
when 7..9
|
132
149
|
EventInfoParser.parse(json, 2)
|
133
150
|
else
|
134
151
|
raise 'unsupported API version'
|
@@ -140,7 +157,7 @@ module AdmiralStatsParser
|
|
140
157
|
case api_version
|
141
158
|
when 1..3
|
142
159
|
raise "API version #{api_version} does not support event info"
|
143
|
-
when 4..
|
160
|
+
when 4..9
|
144
161
|
{
|
145
162
|
opened: EventInfoParser.opened?(event_info_list, level, period),
|
146
163
|
all_cleared: EventInfoParser.all_cleared?(event_info_list, level, period),
|
@@ -161,7 +178,7 @@ module AdmiralStatsParser
|
|
161
178
|
raise "API version #{api_version} does not support blueprint list info"
|
162
179
|
when 7
|
163
180
|
BlueprintListInfoParser.parse(json, 1)
|
164
|
-
when 8
|
181
|
+
when 8..9
|
165
182
|
BlueprintListInfoParser.parse(json, 2)
|
166
183
|
else
|
167
184
|
raise 'unsupported API version'
|
@@ -10,15 +10,49 @@ class EquipListInfoParser
|
|
10
10
|
img: String,
|
11
11
|
}
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
# 装備一覧のみをパースした結果を返します。
|
14
|
+
def self.parse(json, api_version)
|
15
|
+
case api_version
|
16
|
+
when 1
|
17
|
+
# 最初のバージョンには、装備情報の配列のみが入っている
|
18
|
+
equip_list = JSON.parse(json)
|
19
|
+
unless equip_list.is_a?(Array)
|
20
|
+
raise 'json is not an Array'
|
21
|
+
end
|
22
|
+
|
23
|
+
parse_equip_list(equip_list)
|
24
|
+
when 2
|
25
|
+
# 第2のバージョンには、連想配列が入っている
|
26
|
+
info = JSON.parse(json)
|
27
|
+
unless info.is_a?(Hash)
|
28
|
+
raise 'json is not a Hash'
|
29
|
+
end
|
15
30
|
|
16
|
-
|
17
|
-
raise 'json is not an Array'
|
31
|
+
parse_equip_list(info['equipList'])
|
18
32
|
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# 最大装備保有数のみをパースした結果を返します。
|
36
|
+
def self.parse_max_slot_num(json, api_version)
|
37
|
+
case api_version
|
38
|
+
when 1
|
39
|
+
# 最大装備保有数の拡張に対応する前なので、常に 500
|
40
|
+
500
|
41
|
+
when 2
|
42
|
+
info = JSON.parse(json)
|
43
|
+
unless info.is_a?(Hash)
|
44
|
+
raise 'json is not a Hash'
|
45
|
+
end
|
46
|
+
info['maxSlotNum']
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
19
51
|
|
52
|
+
# version 1 の配列、および version 2 の equipList キーの値を受け取り、その結果を EquipListInfo[] に変換して返します。
|
53
|
+
def self.parse_equip_list(equip_list)
|
20
54
|
results = []
|
21
|
-
|
55
|
+
equip_list.each do |items|
|
22
56
|
result = EquipListInfo.new
|
23
57
|
|
24
58
|
MANDATORY_KEYS.each do |key, key_class|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admiral_stats_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Yoshizawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|