admiral_stats_parser 1.17.0 → 1.17.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e916096d4ff8a797ee0cd64beffda36eff3963
|
4
|
+
data.tar.gz: 330fbb035d329a4d476fd8d96acca39e55343a10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b6f1348cd11d1b613dadb61ef1f6c028a695322dbe77c6f8fa717ade4fcffb80e59f576c0c450079d38ed09f976618d0c873a1b8e677d561ff12b0e3a2ab564
|
7
|
+
data.tar.gz: f2b40544d51e7dce513931de0a4691b48b50e67f2b1bc88ca43f7edceb555c637cacc477fcfccaf82e9e4839b089e9ef1b43a3674e694d60a501819eb7f106a2
|
@@ -90,12 +90,17 @@ class TcBookInfoParser
|
|
90
90
|
5 => {
|
91
91
|
priority: Integer,
|
92
92
|
card_img_list: Array,
|
93
|
-
status_img: Array,
|
94
93
|
variation_num_in_page: Integer,
|
95
94
|
acquire_num_in_page: Integer,
|
96
95
|
},
|
97
96
|
}
|
98
97
|
|
98
|
+
CARD_LIST_OPTIONAL_KEYS = {
|
99
|
+
5 => {
|
100
|
+
status_img: Array,
|
101
|
+
},
|
102
|
+
}
|
103
|
+
|
99
104
|
def self.parse(json, api_version)
|
100
105
|
items_array = JSON.parse(json)
|
101
106
|
|
@@ -158,7 +163,7 @@ class TcBookInfoParser
|
|
158
163
|
# 必須のキーが含まれなければエラー
|
159
164
|
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
160
165
|
unless c.include?(camel_case_key)
|
161
|
-
raise "Mandatory key #{key} does not exist"
|
166
|
+
raise "Mandatory key #{key} does not exist: #{tc_book_info.book_no}"
|
162
167
|
end
|
163
168
|
|
164
169
|
# 結果のクラスが合わなければエラー
|
@@ -169,19 +174,33 @@ class TcBookInfoParser
|
|
169
174
|
result.instance_variable_set("@#{key.to_s}", c[camel_case_key])
|
170
175
|
end
|
171
176
|
|
177
|
+
CARD_LIST_OPTIONAL_KEYS[api_version].each do |key, key_class|
|
178
|
+
# キーが含まれなければ、処理をスキップ
|
179
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
180
|
+
next unless c.include?(camel_case_key)
|
181
|
+
|
182
|
+
# 結果のクラスが合わなければエラー
|
183
|
+
unless c[camel_case_key].is_a?(key_class)
|
184
|
+
raise "Optional key #{key} is not class #{key_class}"
|
185
|
+
end
|
186
|
+
|
187
|
+
result.instance_variable_set("@#{key.to_s}", c[camel_case_key])
|
188
|
+
end
|
189
|
+
|
172
190
|
results << result
|
173
191
|
end
|
174
192
|
|
193
|
+
# admiral_stats_parser は限定カード未対応のため、priority == 0 の要素のみを処理する
|
194
|
+
results = results.select{|r| r.priority == 0 }
|
195
|
+
|
175
196
|
case results.size
|
176
197
|
when 0
|
177
|
-
#
|
198
|
+
# 未入手、または priority == 0 のデータが存在しない場合
|
178
199
|
tc_book_info.card_img_list = []
|
179
200
|
tc_book_info.status_img = []
|
180
|
-
|
201
|
+
else
|
181
202
|
tc_book_info.card_img_list = results[0].card_img_list
|
182
203
|
tc_book_info.status_img = results[0].status_img
|
183
|
-
else
|
184
|
-
raise "Number of entry in card_list is #{results.size}"
|
185
204
|
end
|
186
205
|
end
|
187
206
|
|