admiral_stats_parser 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +6 -0
- data/admiral_stats_parser.gemspec +25 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/admiral_stats_parser/model/area_capture_info.rb +60 -0
- data/lib/admiral_stats_parser/model/character_list_info.rb +26 -0
- data/lib/admiral_stats_parser/model/equip_book_info.rb +17 -0
- data/lib/admiral_stats_parser/model/equip_list_info.rb +25 -0
- data/lib/admiral_stats_parser/model/personal_basic_info.rb +46 -0
- data/lib/admiral_stats_parser/model/tc_book_info.rb +47 -0
- data/lib/admiral_stats_parser/parser/area_capture_info_parser.rb +77 -0
- data/lib/admiral_stats_parser/parser/character_list_info_parser.rb +47 -0
- data/lib/admiral_stats_parser/parser/equip_book_info_parser.rb +44 -0
- data/lib/admiral_stats_parser/parser/equip_list_info_parser.rb +45 -0
- data/lib/admiral_stats_parser/parser/personal_basic_info_parser.rb +56 -0
- data/lib/admiral_stats_parser/parser/tc_book_info_parser.rb +66 -0
- data/lib/admiral_stats_parser/version.rb +3 -0
- data/lib/admiral_stats_parser.rb +75 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 15a61b2178653f51b485092de86610692e07b3fd
|
4
|
+
data.tar.gz: 57db109cd0d32925ee00bb1bf8deae3b24ea15c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6fdcb4926dd56b28b57ab0a2ba92ee1f91eea80c114fe362239a23f9cd778b0bb7bc4d17e7a6ccb5bb63ecaa9db89fa87a257c906271a839057f8794fe3fe1ee
|
7
|
+
data.tar.gz: 3965ee565b083a15d363fb6e09d949b0f33d54e2d5e3189a5d6655425e1b49576fc0a6743915d092448774cb87fc03eed16cb2df6d5d70681eaeee4e7dc3da51
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at muziyoshiz@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Masahiro Yoshizawa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# admiral_stats_parser
|
2
|
+
|
3
|
+
Parser for admiral stats JSON data exported from kancolle-arcade.net
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'admiral_stats_parser'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install admiral_stats_parser
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
AdmiralStatsParser.parse_personal_basic(json, api_version)
|
25
|
+
AdmiralStatsParser.parse_area_capture(json, api_version)
|
26
|
+
AdmiralStatsParser.parse_tc_book(json, api_version)
|
27
|
+
AdmiralStatsParser.parse_equip_book(json, api_version)
|
28
|
+
AdmiralStatsParser.parse_character_list(json, api_version)
|
29
|
+
AdmiralStatsParser.parse_equip_list(json, api_version)
|
30
|
+
```
|
31
|
+
|
32
|
+
## Specification
|
33
|
+
|
34
|
+
提督情報ページから返される JSON メッセージの形式は、過去に一度変更されており、今後も変更される可能性があります。このツールでは、kancolle-arcade.net が返す JSON メッセージの形式のことを API version と呼びます。
|
35
|
+
|
36
|
+
AdmiralStatsParser は、以下の API version をサポートしています。
|
37
|
+
|
38
|
+
| API version | 期間 |
|
39
|
+
|------------:|:-----|
|
40
|
+
| 1 | 2016-04-26 〜 2016-06-29 |
|
41
|
+
| 2 | 2016-06-30(REVISION 2 のリリース日)〜 |
|
42
|
+
|
43
|
+
各 API version でパースできる JSON の種類は以下の通りです。また、同じ情報でも、API version によって、含まれる情報量が異なる場合があります。その場合は Supported (1), Supported (2) のように記載して区別しています。
|
44
|
+
|
45
|
+
| 提督情報での表示 | URL | API version 1 | API version 2 |
|
46
|
+
|:----------------|:----|:--------------|:--------------|
|
47
|
+
| 基本情報 | Personal/basicInfo | Supported (1) | Supported (2) |
|
48
|
+
| 海域情報 | Area/captureInfo | Supported (1) | Supported (2) |
|
49
|
+
| 艦娘図鑑 | TcBook/info | Supported (1) | Supported (2) |
|
50
|
+
| 装備図鑑 | EquipBook/info | Supported | Supported |
|
51
|
+
| 艦娘一覧 | CharacterList/info | - | Supported |
|
52
|
+
| 装備一覧 | EquipList/info | - | Supported |
|
53
|
+
|
54
|
+
## Development
|
55
|
+
|
56
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
57
|
+
|
58
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/admiral_stats_parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
63
|
+
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
68
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'admiral_stats_parser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "admiral_stats_parser"
|
8
|
+
spec.version = AdmiralStatsParser::VERSION
|
9
|
+
spec.authors = ["Masahiro Yoshizawa"]
|
10
|
+
spec.email = ["muziyoshiz@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{JSON data parser for kancolle-arcade.net}
|
13
|
+
spec.description = %q{Parser for admiral stats JSON data exported from kancolle-arcade.net}
|
14
|
+
spec.homepage = "https://github.com/muziyoshiz/admiral_stats_parser"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "admiral_stats_parser"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class AreaCaptureInfo
|
3
|
+
# 海域番号
|
4
|
+
# 1: 鎮守府海域
|
5
|
+
# 2: 南西諸島海域
|
6
|
+
# 3: 北方海域
|
7
|
+
# 4: 西方海域
|
8
|
+
attr_accessor :area_id
|
9
|
+
|
10
|
+
# サブ海域番号
|
11
|
+
attr_accessor :area_sub_id
|
12
|
+
|
13
|
+
# 作戦時間(秒)
|
14
|
+
# 未表示の場合は 0
|
15
|
+
attr_accessor :limit_sec
|
16
|
+
|
17
|
+
# 必要GP (From API version 2)
|
18
|
+
# 未表示の場合は 0
|
19
|
+
attr_accessor :require_gp
|
20
|
+
|
21
|
+
# 追撃戦かどうか(true なら追撃戦)
|
22
|
+
attr_accessor :pursuit_map
|
23
|
+
|
24
|
+
# 追撃戦が出現しているかどうか(true なら出現している)
|
25
|
+
# 追撃戦の場合は常に false
|
26
|
+
attr_accessor :pursuit_map_open
|
27
|
+
|
28
|
+
# 出撃条件の有無(true ならある) (From API version 2)
|
29
|
+
attr_accessor :sortie_limit
|
30
|
+
|
31
|
+
# 海域画像のファイル名
|
32
|
+
attr_accessor :stage_image_name
|
33
|
+
|
34
|
+
# 作戦名
|
35
|
+
attr_accessor :stage_mission_name
|
36
|
+
|
37
|
+
# 作戦内容
|
38
|
+
attr_accessor :stage_mission_info
|
39
|
+
|
40
|
+
# 海域クリアボーナス
|
41
|
+
# アイテムを表す、以下の文字列のいずれか
|
42
|
+
# MEISTER: 特注家具職人
|
43
|
+
# BUCKET: 修復バケツ
|
44
|
+
# SMALLREC: 伊良湖
|
45
|
+
# SMALLBOX: 家具コイン(小)
|
46
|
+
# MEDIUMBOX: 家具コイン(中)
|
47
|
+
# NONE: ボーナスなし
|
48
|
+
# UNKNOWN: 海域が未表示の場合
|
49
|
+
attr_accessor :stage_clear_item_info
|
50
|
+
|
51
|
+
# 主な出現アイテム
|
52
|
+
# アイテムを表す文字列の配列(要素数は4固定)
|
53
|
+
attr_accessor :stage_drop_item_info
|
54
|
+
|
55
|
+
# クリア状態を表す文字列
|
56
|
+
# CLEAR: クリア済み
|
57
|
+
# NOTCLEAR: 出撃可能だが未クリア
|
58
|
+
# NOOPEN: 出撃不可
|
59
|
+
attr_accessor :area_clear_state
|
60
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class CharacterListInfo
|
3
|
+
# 図鑑No.
|
4
|
+
attr_accessor :book_no
|
5
|
+
|
6
|
+
# Lv.
|
7
|
+
attr_accessor :lv
|
8
|
+
|
9
|
+
# 艦種
|
10
|
+
attr_accessor :ship_type
|
11
|
+
|
12
|
+
# 艦種順でソートする際に使うキー
|
13
|
+
attr_accessor :ship_sort_no
|
14
|
+
|
15
|
+
# 艦娘の改造度合いを表す数値
|
16
|
+
# (未改造の艦娘と、改造済みの艦娘が、別のデータとして返される)
|
17
|
+
# 0: 未改造
|
18
|
+
# 1: 改
|
19
|
+
attr_accessor :remodel_lv
|
20
|
+
|
21
|
+
# 艦名
|
22
|
+
attr_accessor :ship_name
|
23
|
+
|
24
|
+
# 艦娘のステータス画像(横長の画像)のファイル名
|
25
|
+
attr_accessor :status_img
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class EquipBookInfo
|
3
|
+
# 図鑑No.
|
4
|
+
attr_accessor :book_no
|
5
|
+
|
6
|
+
# 種別
|
7
|
+
# 未取得の場合は、空文字列
|
8
|
+
attr_accessor :equip_kind
|
9
|
+
|
10
|
+
# 装備名
|
11
|
+
# 未取得の場合は、空文字列
|
12
|
+
attr_accessor :equip_name
|
13
|
+
|
14
|
+
# 一覧に表示する画像のファイル名
|
15
|
+
# 未取得の場合は、空文字列
|
16
|
+
attr_accessor :equip_img
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class EquipListInfo
|
3
|
+
# 種別
|
4
|
+
# 1: 主砲
|
5
|
+
# 2: 副砲・高角
|
6
|
+
# 3: 魚雷
|
7
|
+
# 4: 艦戦
|
8
|
+
# 5: 艦爆・艦攻
|
9
|
+
# 6: 偵察機
|
10
|
+
# 7: ソナー・爆雷
|
11
|
+
# 8: その他
|
12
|
+
attr_accessor :type
|
13
|
+
|
14
|
+
# 図鑑No.
|
15
|
+
attr_accessor :equipment_id
|
16
|
+
|
17
|
+
# 装備名
|
18
|
+
attr_accessor :name
|
19
|
+
|
20
|
+
# 所持数
|
21
|
+
attr_accessor :num
|
22
|
+
|
23
|
+
# アイコン画像のファイル名
|
24
|
+
attr_accessor :img
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class PersonalBasicInfo
|
3
|
+
# 提督名
|
4
|
+
attr_accessor :admiral_name
|
5
|
+
|
6
|
+
# 燃料
|
7
|
+
attr_accessor :fuel
|
8
|
+
|
9
|
+
# 弾薬
|
10
|
+
attr_accessor :ammo
|
11
|
+
|
12
|
+
# 鋼材
|
13
|
+
attr_accessor :steel
|
14
|
+
|
15
|
+
# ボーキサイト
|
16
|
+
attr_accessor :bauxite
|
17
|
+
|
18
|
+
# 修復バケツ
|
19
|
+
attr_accessor :bucket
|
20
|
+
|
21
|
+
# 艦隊司令部Level
|
22
|
+
attr_accessor :level
|
23
|
+
|
24
|
+
# 家具コイン
|
25
|
+
attr_accessor :room_item_coin
|
26
|
+
|
27
|
+
# 戦果 (From API version 2)
|
28
|
+
# 戦果は数値だが、なぜか STRING 型で返される。どういう場合に文字列が返されるのか?
|
29
|
+
attr_accessor :result_point
|
30
|
+
|
31
|
+
# 暫定順位 (From API version 2)
|
32
|
+
# 数値または「圏外」
|
33
|
+
attr_accessor :rank
|
34
|
+
|
35
|
+
# 階級を表す数値 (From API version 2)
|
36
|
+
# 7: 中将
|
37
|
+
attr_accessor :title_id
|
38
|
+
|
39
|
+
# 最大備蓄可能各資源量 (From API version 2)
|
40
|
+
attr_accessor :material_max
|
41
|
+
|
42
|
+
# 戦略ポイント (From API version 2)
|
43
|
+
attr_accessor :strategy_point
|
44
|
+
|
45
|
+
# {"admiralName":"ムジ","fuel":6750,"ammo":6183,"steel":7126,"bauxite":6513,"bucket":46,"level":32,"roomItemCoin":82,"resultPoint":"3571","rank":"圏外","titleId":7,"materialMax":7200,"strategyPoint":915}
|
46
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
class TcBookInfo
|
3
|
+
# 図鑑No.
|
4
|
+
attr_accessor :book_no
|
5
|
+
|
6
|
+
# 艦型
|
7
|
+
# 未取得の場合は、空文字列
|
8
|
+
attr_accessor :ship_class
|
9
|
+
|
10
|
+
# 艦番号(1〜)
|
11
|
+
# 未取得の場合は、-1
|
12
|
+
attr_accessor :ship_class_index
|
13
|
+
|
14
|
+
# 艦種
|
15
|
+
# 未取得の場合は、空文字列
|
16
|
+
attr_accessor :ship_type
|
17
|
+
|
18
|
+
# 艦名
|
19
|
+
# 未取得の場合は、"未取得"
|
20
|
+
attr_accessor :ship_name
|
21
|
+
|
22
|
+
# 一覧に表示する画像のファイル名
|
23
|
+
# 未取得の場合は、空文字列
|
24
|
+
attr_accessor :card_index_img
|
25
|
+
|
26
|
+
# 取得済み画像のファイル名
|
27
|
+
# Array
|
28
|
+
# 未取得の場合は、空の Array
|
29
|
+
attr_accessor :card_img_list
|
30
|
+
|
31
|
+
# 画像のバリエーション数
|
32
|
+
# 未取得の場合は、0
|
33
|
+
attr_accessor :variation_num
|
34
|
+
|
35
|
+
# 取得済みの画像数
|
36
|
+
# 未取得の場合は、0
|
37
|
+
attr_accessor :acquire_num
|
38
|
+
|
39
|
+
# Lv. (From API version 2)
|
40
|
+
# 未取得の場合は、0
|
41
|
+
attr_accessor :lv
|
42
|
+
|
43
|
+
# 艦娘のステータス画像(横長の画像)のファイル名 (From API version 2)
|
44
|
+
# Array
|
45
|
+
# 未取得の場合は、空の Array
|
46
|
+
attr_accessor :status_img
|
47
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'json'
|
3
|
+
require 'admiral_stats_parser/model/area_capture_info'
|
4
|
+
|
5
|
+
module AreaCaptureInfoParser
|
6
|
+
MANDATORY_KEYS = {
|
7
|
+
1 => {
|
8
|
+
:area_id => Integer,
|
9
|
+
:area_sub_id => Integer,
|
10
|
+
:limit_sec => Integer,
|
11
|
+
# :require_gp => Integer,
|
12
|
+
:pursuit_map => :boolean,
|
13
|
+
:pursuit_map_open => :boolean,
|
14
|
+
# :sortie_limit => :boolean,
|
15
|
+
:stage_image_name => String,
|
16
|
+
:stage_mission_name => String,
|
17
|
+
:stage_mission_info => String,
|
18
|
+
:stage_clear_item_info => String,
|
19
|
+
:stage_drop_item_info => Array,
|
20
|
+
:area_clear_state => String,
|
21
|
+
},
|
22
|
+
2 => {
|
23
|
+
:area_id => Integer,
|
24
|
+
:area_sub_id => Integer,
|
25
|
+
:limit_sec => Integer,
|
26
|
+
:require_gp => Integer,
|
27
|
+
:pursuit_map => :boolean,
|
28
|
+
:pursuit_map_open => :boolean,
|
29
|
+
:sortie_limit => :boolean,
|
30
|
+
:stage_image_name => String,
|
31
|
+
:stage_mission_name => String,
|
32
|
+
:stage_mission_info => String,
|
33
|
+
:stage_clear_item_info => String,
|
34
|
+
:stage_drop_item_info => Array,
|
35
|
+
:area_clear_state => String,
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
def self.parse(json, api_version)
|
40
|
+
items_array = JSON.parse(json)
|
41
|
+
|
42
|
+
unless items_array.is_a?(Array)
|
43
|
+
raise 'json is not an Array'
|
44
|
+
end
|
45
|
+
|
46
|
+
results = []
|
47
|
+
items_array.each do |items|
|
48
|
+
result = AreaCaptureInfo.new
|
49
|
+
|
50
|
+
MANDATORY_KEYS[api_version].each do |key, key_class|
|
51
|
+
# 必須のキーが含まれなければエラー
|
52
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
53
|
+
unless items.include?(camel_case_key)
|
54
|
+
raise "Mandatory key #{key} does not exist"
|
55
|
+
end
|
56
|
+
|
57
|
+
# 結果のクラスが合わなければエラー
|
58
|
+
# ruby には Boolean クラスがないので、そこだけ特別な処理を用意する
|
59
|
+
if key_class == :boolean
|
60
|
+
unless [true, false].include?(items[camel_case_key])
|
61
|
+
raise "Mandatory key #{key} is not boolean"
|
62
|
+
end
|
63
|
+
else
|
64
|
+
unless items[camel_case_key].is_a?(key_class)
|
65
|
+
raise "Mandatory key #{key} is not class #{key_class}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
result.instance_variable_set("@#{key.to_s}", items[camel_case_key])
|
70
|
+
end
|
71
|
+
|
72
|
+
results << result
|
73
|
+
end
|
74
|
+
|
75
|
+
results
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'json'
|
3
|
+
require 'admiral_stats_parser/model/character_list_info'
|
4
|
+
|
5
|
+
module CharacterListInfoParser
|
6
|
+
MANDATORY_KEYS = {
|
7
|
+
:book_no => Integer,
|
8
|
+
:lv => Integer,
|
9
|
+
:ship_type => String,
|
10
|
+
:ship_sort_no => Integer,
|
11
|
+
:remodel_lv => Integer,
|
12
|
+
:ship_name => String,
|
13
|
+
:status_img => String,
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.parse(json)
|
17
|
+
items_array = JSON.parse(json)
|
18
|
+
|
19
|
+
unless items_array.is_a?(Array)
|
20
|
+
raise 'json is not an Array'
|
21
|
+
end
|
22
|
+
|
23
|
+
results = []
|
24
|
+
items_array.each do |items|
|
25
|
+
result = CharacterListInfo.new
|
26
|
+
|
27
|
+
MANDATORY_KEYS.each do |key, key_class|
|
28
|
+
# 必須のキーが含まれなければエラー
|
29
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
30
|
+
unless items.include?(camel_case_key)
|
31
|
+
raise "Mandatory key #{key} does not exist"
|
32
|
+
end
|
33
|
+
|
34
|
+
# 結果のクラスが合わなければエラー
|
35
|
+
unless items[camel_case_key].is_a?(key_class)
|
36
|
+
raise "Mandatory key #{key} is not class #{key_class}"
|
37
|
+
end
|
38
|
+
|
39
|
+
result.instance_variable_set("@#{key.to_s}", items[camel_case_key])
|
40
|
+
end
|
41
|
+
|
42
|
+
results << result
|
43
|
+
end
|
44
|
+
|
45
|
+
results
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'json'
|
3
|
+
require 'admiral_stats_parser/model/equip_book_info'
|
4
|
+
|
5
|
+
module EquipBookInfoParser
|
6
|
+
MANDATORY_KEYS = {
|
7
|
+
:book_no => Integer,
|
8
|
+
:equip_kind => String,
|
9
|
+
:equip_name => String,
|
10
|
+
:equip_img => String,
|
11
|
+
}
|
12
|
+
|
13
|
+
def self.parse(json)
|
14
|
+
items_array = JSON.parse(json)
|
15
|
+
|
16
|
+
unless items_array.is_a?(Array)
|
17
|
+
raise 'json is not an Array'
|
18
|
+
end
|
19
|
+
|
20
|
+
results = []
|
21
|
+
items_array.each do |items|
|
22
|
+
result = EquipBookInfo.new
|
23
|
+
|
24
|
+
MANDATORY_KEYS.each do |key, key_class|
|
25
|
+
# 必須のキーが含まれなければエラー
|
26
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
27
|
+
unless items.include?(camel_case_key)
|
28
|
+
raise "Mandatory key #{key} does not exist"
|
29
|
+
end
|
30
|
+
|
31
|
+
# 結果のクラスが合わなければエラー
|
32
|
+
unless items[camel_case_key].is_a?(key_class)
|
33
|
+
raise "Mandatory key #{key} is not class #{key_class}"
|
34
|
+
end
|
35
|
+
|
36
|
+
result.instance_variable_set("@#{key.to_s}", items[camel_case_key])
|
37
|
+
end
|
38
|
+
|
39
|
+
results << result
|
40
|
+
end
|
41
|
+
|
42
|
+
results
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'json'
|
3
|
+
require 'admiral_stats_parser/model/equip_list_info'
|
4
|
+
|
5
|
+
module EquipListInfoParser
|
6
|
+
MANDATORY_KEYS = {
|
7
|
+
:type => Integer,
|
8
|
+
:equipment_id => Integer,
|
9
|
+
:name => String,
|
10
|
+
:num => Integer,
|
11
|
+
:img => String,
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.parse(json)
|
15
|
+
items_array = JSON.parse(json)
|
16
|
+
|
17
|
+
unless items_array.is_a?(Array)
|
18
|
+
raise 'json is not an Array'
|
19
|
+
end
|
20
|
+
|
21
|
+
results = []
|
22
|
+
items_array.each do |items|
|
23
|
+
result = EquipListInfo.new
|
24
|
+
|
25
|
+
MANDATORY_KEYS.each do |key, key_class|
|
26
|
+
# 必須のキーが含まれなければエラー
|
27
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
28
|
+
unless items.include?(camel_case_key)
|
29
|
+
raise "Mandatory key #{key} does not exist"
|
30
|
+
end
|
31
|
+
|
32
|
+
# 結果のクラスが合わなければエラー
|
33
|
+
unless items[camel_case_key].is_a?(key_class)
|
34
|
+
raise "Mandatory key #{key} is not class #{key_class}"
|
35
|
+
end
|
36
|
+
|
37
|
+
result.instance_variable_set("@#{key.to_s}", items[camel_case_key])
|
38
|
+
end
|
39
|
+
|
40
|
+
results << result
|
41
|
+
end
|
42
|
+
|
43
|
+
results
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'json'
|
3
|
+
require 'admiral_stats_parser/model/personal_basic_info'
|
4
|
+
|
5
|
+
module PersonalBasicInfoParser
|
6
|
+
MANDATORY_KEYS = {
|
7
|
+
1 => {
|
8
|
+
:admiral_name => String,
|
9
|
+
:fuel => Integer,
|
10
|
+
:ammo => Integer,
|
11
|
+
:steel => Integer,
|
12
|
+
:bauxite => Integer,
|
13
|
+
:bucket => Integer,
|
14
|
+
:level => Integer,
|
15
|
+
:room_item_coin => Integer,
|
16
|
+
},
|
17
|
+
2 => {
|
18
|
+
:admiral_name => String,
|
19
|
+
:fuel => Integer,
|
20
|
+
:ammo => Integer,
|
21
|
+
:steel => Integer,
|
22
|
+
:bauxite => Integer,
|
23
|
+
:bucket => Integer,
|
24
|
+
:level => Integer,
|
25
|
+
:room_item_coin => Integer,
|
26
|
+
:result_point => String,
|
27
|
+
:rank => String,
|
28
|
+
:title_id => Integer,
|
29
|
+
:material_max => Integer,
|
30
|
+
:strategy_point => Integer,
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
def self.parse(json, api_version)
|
35
|
+
items = JSON.parse(json)
|
36
|
+
|
37
|
+
result = PersonalBasicInfo.new
|
38
|
+
|
39
|
+
MANDATORY_KEYS[api_version].each do |key, key_class|
|
40
|
+
# 必須のキーが含まれなければエラー
|
41
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
42
|
+
unless items.include?(camel_case_key)
|
43
|
+
raise "Mandatory key #{key} does not exist"
|
44
|
+
end
|
45
|
+
|
46
|
+
# 結果のクラスが合わなければエラー
|
47
|
+
unless items[camel_case_key].is_a?(key_class)
|
48
|
+
raise "Mandatory key #{key} is not class #{key_class}"
|
49
|
+
end
|
50
|
+
|
51
|
+
result.instance_variable_set("@#{key.to_s}", items[camel_case_key])
|
52
|
+
end
|
53
|
+
|
54
|
+
result
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'json'
|
3
|
+
require 'admiral_stats_parser/model/tc_book_info'
|
4
|
+
|
5
|
+
module TcBookInfoParser
|
6
|
+
MANDATORY_KEYS = {
|
7
|
+
1 => {
|
8
|
+
:book_no => Integer,
|
9
|
+
:ship_class => String,
|
10
|
+
:ship_class_index => Integer,
|
11
|
+
:ship_type => String,
|
12
|
+
:ship_name => String,
|
13
|
+
:card_index_img => String,
|
14
|
+
:card_img_list => Array,
|
15
|
+
:variation_num => Integer,
|
16
|
+
:acquire_num => Integer,
|
17
|
+
# :lv => Integer,
|
18
|
+
# :status_img => Array,
|
19
|
+
},
|
20
|
+
2 => {
|
21
|
+
:book_no => Integer,
|
22
|
+
:ship_class => String,
|
23
|
+
:ship_class_index => Integer,
|
24
|
+
:ship_type => String,
|
25
|
+
:ship_name => String,
|
26
|
+
:card_index_img => String,
|
27
|
+
:card_img_list => Array,
|
28
|
+
:variation_num => Integer,
|
29
|
+
:acquire_num => Integer,
|
30
|
+
:lv => Integer,
|
31
|
+
:status_img => Array,
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
def self.parse(json, api_version)
|
36
|
+
items_array = JSON.parse(json)
|
37
|
+
|
38
|
+
unless items_array.is_a?(Array)
|
39
|
+
raise 'json is not an Array'
|
40
|
+
end
|
41
|
+
|
42
|
+
results = []
|
43
|
+
items_array.each do |items|
|
44
|
+
result = TcBookInfo.new
|
45
|
+
|
46
|
+
MANDATORY_KEYS[api_version].each do |key, key_class|
|
47
|
+
# 必須のキーが含まれなければエラー
|
48
|
+
camel_case_key = key.to_s.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
|
49
|
+
unless items.include?(camel_case_key)
|
50
|
+
raise "Mandatory key #{key} does not exist"
|
51
|
+
end
|
52
|
+
|
53
|
+
# 結果のクラスが合わなければエラー
|
54
|
+
unless items[camel_case_key].is_a?(key_class)
|
55
|
+
raise "Mandatory key #{key} is not class #{key_class}"
|
56
|
+
end
|
57
|
+
|
58
|
+
result.instance_variable_set("@#{key.to_s}", items[camel_case_key])
|
59
|
+
end
|
60
|
+
|
61
|
+
results << result
|
62
|
+
end
|
63
|
+
|
64
|
+
results
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'admiral_stats_parser/version'
|
3
|
+
require 'admiral_stats_parser/parser/personal_basic_info_parser'
|
4
|
+
require 'admiral_stats_parser/parser/area_capture_info_parser'
|
5
|
+
require 'admiral_stats_parser/parser/tc_book_info_parser'
|
6
|
+
require 'admiral_stats_parser/parser/equip_book_info_parser'
|
7
|
+
require 'admiral_stats_parser/parser/character_list_info_parser'
|
8
|
+
require 'admiral_stats_parser/parser/equip_list_info_parser'
|
9
|
+
|
10
|
+
module AdmiralStatsParser
|
11
|
+
|
12
|
+
# 基本情報をパースします。
|
13
|
+
def self.parse_personal_basic_info(json, api_version)
|
14
|
+
case api_version
|
15
|
+
when 1, 2
|
16
|
+
PersonalBasicInfoParser.parse(json, api_version)
|
17
|
+
else
|
18
|
+
raise 'unsupported API version'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# 海域情報をパースします。
|
23
|
+
def self.parse_area_capture_info(json, api_version)
|
24
|
+
case api_version
|
25
|
+
when 1, 2
|
26
|
+
AreaCaptureInfoParser.parse(json, api_version)
|
27
|
+
else
|
28
|
+
raise 'unsupported API version'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# 艦娘図鑑をパースします。
|
33
|
+
def self.parse_tc_book_info(json, api_version)
|
34
|
+
case api_version
|
35
|
+
when 1, 2
|
36
|
+
TcBookInfoParser.parse(json, api_version)
|
37
|
+
else
|
38
|
+
raise 'unsupported API version'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# 装備図鑑をパースします。
|
43
|
+
def self.parse_equip_book_info(json, api_version)
|
44
|
+
case api_version
|
45
|
+
when 1, 2
|
46
|
+
EquipBookInfoParser.parse(json)
|
47
|
+
else
|
48
|
+
raise 'unsupported API version'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# 艦娘一覧をパースします。
|
53
|
+
def self.parse_character_list_info(json, api_version)
|
54
|
+
case api_version
|
55
|
+
when 1
|
56
|
+
raise 'API version 1 does not support character list info'
|
57
|
+
when 2
|
58
|
+
CharacterListInfoParser.parse(json)
|
59
|
+
else
|
60
|
+
raise 'unsupported API version'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# 装備一覧をパースします。
|
65
|
+
def self.parse_equip_list_info(json, api_version)
|
66
|
+
case api_version
|
67
|
+
when 1
|
68
|
+
raise 'API version 1 does not support equip list info'
|
69
|
+
when 2
|
70
|
+
EquipListInfoParser.parse(json)
|
71
|
+
else
|
72
|
+
raise 'unsupported API version'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: admiral_stats_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masahiro Yoshizawa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Parser for admiral stats JSON data exported from kancolle-arcade.net
|
56
|
+
email:
|
57
|
+
- muziyoshiz@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- .travis.yml
|
65
|
+
- CODE_OF_CONDUCT.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- admiral_stats_parser.gemspec
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- lib/admiral_stats_parser.rb
|
74
|
+
- lib/admiral_stats_parser/model/area_capture_info.rb
|
75
|
+
- lib/admiral_stats_parser/model/character_list_info.rb
|
76
|
+
- lib/admiral_stats_parser/model/equip_book_info.rb
|
77
|
+
- lib/admiral_stats_parser/model/equip_list_info.rb
|
78
|
+
- lib/admiral_stats_parser/model/personal_basic_info.rb
|
79
|
+
- lib/admiral_stats_parser/model/tc_book_info.rb
|
80
|
+
- lib/admiral_stats_parser/parser/area_capture_info_parser.rb
|
81
|
+
- lib/admiral_stats_parser/parser/character_list_info_parser.rb
|
82
|
+
- lib/admiral_stats_parser/parser/equip_book_info_parser.rb
|
83
|
+
- lib/admiral_stats_parser/parser/equip_list_info_parser.rb
|
84
|
+
- lib/admiral_stats_parser/parser/personal_basic_info_parser.rb
|
85
|
+
- lib/admiral_stats_parser/parser/tc_book_info_parser.rb
|
86
|
+
- lib/admiral_stats_parser/version.rb
|
87
|
+
homepage: https://github.com/muziyoshiz/admiral_stats_parser
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.6.6
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: JSON data parser for kancolle-arcade.net
|
111
|
+
test_files: []
|