admiral_stats_parser 1.7.0 → 1.8.0

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: da1d3ff4a8d20f013e58c619f48d3f7953d407d1
4
- data.tar.gz: 84a8217dc2bfc9519209eebd3d3e37c0278e5f95
3
+ metadata.gz: e127fced6bcbd3b3b30fc503155a7eecb737cdbf
4
+ data.tar.gz: bce717d8e702a710a8f67c1dd7b593977636db5f
5
5
  SHA512:
6
- metadata.gz: 0a0e5cbddb030c82d41c7de3ed21eba8d6249baecb26bdf26fdfd756564b7069283feeaaa47e47656a8ed33ae767ca9bb03b8e124fd67e87b54b081bd4295b9e
7
- data.tar.gz: 507d3df27ff2b4f30a8403a2890f9fc5fbcc1d9510351b3f925d9ea7fc1b221b9f969a5b30e572f192f7d1b21559bd9276ccc6a9f472e36ca4847e71cb402850
6
+ metadata.gz: 699296f94e500e263f7859b4e9afcb2c02af3e87e606b07f6f1db74f2298cc6ddfe4823594f3dfdd2dd6a9aa6aa91496f30a09fc292fe20e0c4cbefd7becfb10
7
+ data.tar.gz: 20ae2987ada2b1026d5ead9769ee4940dff1422a9997fab2297025573f50ca94448cb4b13cc0db02e7002ac3c856d546f8f5f0125d52010ad2fe38d8db5683dd
data/README.md CHANGED
@@ -62,7 +62,8 @@ AdmiralStatsParser は、以下の API version をサポートしています。
62
62
  | 4 | 2016-10-27 〜 2016-12-20 |
63
63
  | 5 | 2016-12-21 〜 2017-02-13 |
64
64
  | 6 | 2017-02-14 〜 2017-04-25 |
65
- | 7 | 2017-04-26 〜 |
65
+ | 7 | 2017-04-26 〜 2017-05-31(第2回イベントの終了日) |
66
+ | 8 | 2017-06-01 〜 |
66
67
 
67
68
  各 API version でパースできる JSON の種類は以下の通りです。また、同じ情報でも、API version によって、含まれる情報量が異なる場合があります。その場合は Supported (1), Supported (2) のように記載して区別しています。
68
69
 
@@ -70,7 +71,7 @@ AdmiralStatsParser は、以下の API version をサポートしています。
70
71
  |------------:|:-----|:-----|:-----|:-----|
71
72
  | 1 | Supported (1) | Supported (1) | Supported (1) | Supported |
72
73
  | 2 〜 6 | Supported (2) | Supported (2) | Supported (2) | Supported |
73
- | 7 | Supported (3) | Supported (3) | Supported (2) | Supported |
74
+ | 7 〜 8 | Supported (3) | Supported (3) | Supported (2) | Supported |
74
75
 
75
76
  | API version | 艦娘一覧 | 装備一覧 | イベント海域情報 |
76
77
  |------------:|:-----|:-----|:-----|
@@ -79,7 +80,13 @@ AdmiralStatsParser は、以下の API version をサポートしています。
79
80
  | 3 | Supported (2) | Supported | Unsupported |
80
81
  | 4 | Supported (2) | Supported | Supported (1) |
81
82
  | 5 〜 6 | Supported (3) | Supported | Supported (1) |
82
- | 7 | Supported (4) | Supported | Supported (2) |
83
+ | 7 〜 8 | Supported (4) | Supported | Supported (2) |
84
+
85
+ | API version | 改装設計図一覧 |
86
+ |------------:|:-----|
87
+ | 1 〜 6 | Unsupported |
88
+ | 7 | Supported (1) |
89
+ | 8 | Supported (2) |
83
90
 
84
91
  ## Development
85
92
 
@@ -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 7
15
+ return 8
16
16
  end
17
17
 
18
18
  # エクスポート時刻を元に、API バージョンを推測して返します。
@@ -35,6 +35,9 @@ module AdmiralStatsParser
35
35
  # version 7 の開始日
36
36
  return 6 if exported_at < Time.parse('2017-04-26T07:00:00+0900')
37
37
 
38
+ # version 8 の開始日
39
+ return 7 if exported_at < Time.parse('2017-06-01T07:00:00+0900')
40
+
38
41
  return self.get_latest_api_version
39
42
  end
40
43
 
@@ -45,7 +48,7 @@ module AdmiralStatsParser
45
48
  PersonalBasicInfoParser.parse(json, 1)
46
49
  when 2..6
47
50
  PersonalBasicInfoParser.parse(json, 2)
48
- when 7
51
+ when 7..8
49
52
  PersonalBasicInfoParser.parse(json, 3)
50
53
  else
51
54
  raise 'unsupported API version'
@@ -59,7 +62,7 @@ module AdmiralStatsParser
59
62
  AreaCaptureInfoParser.parse(json, 1)
60
63
  when 2..6
61
64
  AreaCaptureInfoParser.parse(json, 2)
62
- when 7
65
+ when 7..8
63
66
  AreaCaptureInfoParser.parse(json, 3)
64
67
  else
65
68
  raise 'unsupported API version'
@@ -71,7 +74,7 @@ module AdmiralStatsParser
71
74
  case api_version
72
75
  when 1
73
76
  TcBookInfoParser.parse(json, 1)
74
- when 2..7
77
+ when 2..8
75
78
  TcBookInfoParser.parse(json, 2)
76
79
  else
77
80
  raise 'unsupported API version'
@@ -81,7 +84,7 @@ module AdmiralStatsParser
81
84
  # 装備図鑑をパースします。
82
85
  def self.parse_equip_book_info(json, api_version)
83
86
  case api_version
84
- when 1..7
87
+ when 1..8
85
88
  EquipBookInfoParser.parse(json)
86
89
  else
87
90
  raise 'unsupported API version'
@@ -99,7 +102,7 @@ module AdmiralStatsParser
99
102
  CharacterListInfoParser.parse(json, 2)
100
103
  when 5..6
101
104
  CharacterListInfoParser.parse(json, 3)
102
- when 7
105
+ when 7..8
103
106
  CharacterListInfoParser.parse(json, 4)
104
107
  else
105
108
  raise 'unsupported API version'
@@ -111,7 +114,7 @@ module AdmiralStatsParser
111
114
  case api_version
112
115
  when 1
113
116
  raise 'API version 1 does not support equip list info'
114
- when 2..7
117
+ when 2..8
115
118
  EquipListInfoParser.parse(json)
116
119
  else
117
120
  raise 'unsupported API version'
@@ -125,7 +128,7 @@ module AdmiralStatsParser
125
128
  raise "API version #{api_version} does not support event info"
126
129
  when 4..6
127
130
  EventInfoParser.parse(json, 1)
128
- when 7
131
+ when 7..8
129
132
  EventInfoParser.parse(json, 2)
130
133
  else
131
134
  raise 'unsupported API version'
@@ -137,7 +140,7 @@ module AdmiralStatsParser
137
140
  case api_version
138
141
  when 1..3
139
142
  raise "API version #{api_version} does not support event info"
140
- when 4..7
143
+ when 4..8
141
144
  {
142
145
  opened: EventInfoParser.opened?(event_info_list, level, period),
143
146
  all_cleared: EventInfoParser.all_cleared?(event_info_list, level, period),
@@ -158,6 +161,8 @@ module AdmiralStatsParser
158
161
  raise "API version #{api_version} does not support blueprint list info"
159
162
  when 7
160
163
  BlueprintListInfoParser.parse(json, 1)
164
+ when 8
165
+ BlueprintListInfoParser.parse(json, 2)
161
166
  else
162
167
  raise 'unsupported API version'
163
168
  end
@@ -23,6 +23,9 @@ class BlueprintListInfo
23
23
  # 改装設計図の総数
24
24
  attr_accessor :blueprint_total_num
25
25
 
26
+ # 有効期限切れの警告を表示するか (From API version 8)
27
+ attr_accessor :exists_warning_for_expiration
28
+
26
29
  # 有効期限の詳細
27
30
  attr_accessor :expiration_date_list
28
31
 
@@ -36,5 +39,8 @@ class BlueprintListInfo
36
39
 
37
40
  # 上記の有効期限を持つ改装設計図の枚数
38
41
  attr_accessor :blueprint_num
42
+
43
+ # 今月で有効期限切れかどうか (From API version 8)
44
+ attr_accessor :expire_this_month
39
45
  end
40
46
  end
@@ -13,11 +13,29 @@ class BlueprintListInfoParser
13
13
  blueprint_total_num: Integer,
14
14
  expiration_date_list: :expiration_date_list,
15
15
  },
16
+ 2 => {
17
+ ship_class_id: Integer,
18
+ ship_class_index: Integer,
19
+ ship_sort_no: Integer,
20
+ ship_type: String,
21
+ ship_name: String,
22
+ status_img: String,
23
+ blueprint_total_num: Integer,
24
+ exists_warning_for_expiration: :boolean,
25
+ expiration_date_list: :expiration_date_list,
26
+ }
16
27
  }
17
28
 
18
29
  EXPIRATION_DATE_MANDATORY_KEYS = {
19
- expiration_date: Integer,
20
- blueprint_num: Integer,
30
+ 1 => {
31
+ expiration_date: Integer,
32
+ blueprint_num: Integer,
33
+ },
34
+ 2 => {
35
+ expiration_date: Integer,
36
+ blueprint_num: Integer,
37
+ expire_this_month: :boolean,
38
+ }
21
39
  }
22
40
 
23
41
  def self.parse(json, api_version)
@@ -41,13 +59,20 @@ class BlueprintListInfoParser
41
59
  # 有効期限の情報を格納するために、特別な処理を追加
42
60
  if key_class == :expiration_date_list
43
61
  result.instance_variable_set(
44
- "@#{key.to_s}", BlueprintListInfoParser.parse_expiration_date_list(items[camel_case_key]))
62
+ "@#{key.to_s}", BlueprintListInfoParser.parse_expiration_date_list(items[camel_case_key], api_version))
45
63
  next
46
64
  end
47
65
 
48
66
  # 結果のクラスが合わなければエラー
49
- unless items[camel_case_key].is_a?(key_class)
50
- raise "Mandatory key #{key} is not class #{key_class}"
67
+ # ruby には Boolean クラスがないので、そこだけ特別な処理を用意する
68
+ if key_class == :boolean
69
+ unless [true, false].include?(items[camel_case_key])
70
+ raise "Mandatory key #{key} is not boolean"
71
+ end
72
+ else
73
+ unless items[camel_case_key].is_a?(key_class)
74
+ raise "Mandatory key #{key} is not class #{key_class}"
75
+ end
51
76
  end
52
77
 
53
78
  result.instance_variable_set("@#{key.to_s}", items[camel_case_key])
@@ -59,13 +84,13 @@ class BlueprintListInfoParser
59
84
  results
60
85
  end
61
86
 
62
- def self.parse_expiration_date_list(expiration_date_list)
87
+ def self.parse_expiration_date_list(expiration_date_list, api_version)
63
88
  results = []
64
89
 
65
90
  expiration_date_list.each do |ed|
66
91
  result = BlueprintListInfo::ExpirationDate.new
67
92
 
68
- EXPIRATION_DATE_MANDATORY_KEYS.each do |key, key_class|
93
+ EXPIRATION_DATE_MANDATORY_KEYS[api_version].each do |key, key_class|
69
94
  # 必須のキーが含まれなければエラー
70
95
  camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
71
96
  unless ed.include?(camel_case_key)
@@ -73,8 +98,15 @@ class BlueprintListInfoParser
73
98
  end
74
99
 
75
100
  # 結果のクラスが合わなければエラー
76
- unless ed[camel_case_key].is_a?(key_class)
77
- raise "Mandatory key #{key} is not class #{key_class}"
101
+ # ruby には Boolean クラスがないので、そこだけ特別な処理を用意する
102
+ if key_class == :boolean
103
+ unless [true, false].include?(ed[camel_case_key])
104
+ raise "Mandatory key #{key} is not boolean"
105
+ end
106
+ else
107
+ unless ed[camel_case_key].is_a?(key_class)
108
+ raise "Mandatory key #{key} is not class #{key_class}"
109
+ end
78
110
  end
79
111
 
80
112
  result.instance_variable_set("@#{key.to_s}", ed[camel_case_key])
@@ -1,3 +1,3 @@
1
1
  module AdmiralStatsParser
2
- VERSION = "1.7.0"
2
+ VERSION = "1.8.0"
3
3
  end
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.7.0
4
+ version: 1.8.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-04-29 00:00:00.000000000 Z
11
+ date: 2017-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler