admiral_stats_parser 1.17.0 → 1.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8a532fc6d719dca51bff3ac91ee7e8bb9897ee6
4
- data.tar.gz: 49bb96a6f5fa6ce7dc5b2ebd46a671cc5d563689
3
+ metadata.gz: f7e916096d4ff8a797ee0cd64beffda36eff3963
4
+ data.tar.gz: 330fbb035d329a4d476fd8d96acca39e55343a10
5
5
  SHA512:
6
- metadata.gz: a8a5916ec9b77b552bb39096d2b2999a5b6db7c2d4e3aa4ac0e363454f94ea26e18bea92ca6a501f7e5c5a6690a79e567d1e426512435f262a03581f33c49230
7
- data.tar.gz: d6f27c93cd393546cac9ac983f9483782af798d95be97c1e53ec73191708999b2c86571792c808f158c1360519443e9c659070cbb340a2c9f04d9b33537f8452
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
- when 1
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
 
@@ -1,3 +1,3 @@
1
1
  module AdmiralStatsParser
2
- VERSION = '1.17.0'
2
+ VERSION = '1.17.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admiral_stats_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.0
4
+ version: 1.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Yoshizawa