jkf 0.4.3 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +16 -0
- data/.rubocop.yml +46 -990
- data/.rubocop_todo.yml +1 -5
- data/CHANGELOG.md +63 -0
- data/Gemfile +11 -9
- data/Guardfile +3 -3
- data/README.en.md +28 -15
- data/README.md +9 -5
- data/Rakefile +7 -2
- data/bench.rb +12 -0
- data/bin/console +4 -4
- data/jkf.gemspec +14 -12
- data/lib/jkf/converter/base.rb +12 -10
- data/lib/jkf/converter/csa.rb +141 -150
- data/lib/jkf/converter/ki2.rb +93 -91
- data/lib/jkf/converter/kif.rb +105 -99
- data/lib/jkf/converter/kifuable.rb +160 -160
- data/lib/jkf/converter.rb +6 -8
- data/lib/jkf/parser/base.rb +81 -95
- data/lib/jkf/parser/csa.rb +652 -667
- data/lib/jkf/parser/ki2.rb +332 -338
- data/lib/jkf/parser/kif.rb +468 -485
- data/lib/jkf/parser/kifuable.rb +500 -518
- data/lib/jkf/parser.rb +5 -7
- data/lib/jkf/version.rb +1 -2
- data/lib/jkf.rb +6 -6
- data/manifest.scm +143 -0
- data/po/all.pot +176 -0
- data/po/en.po +199 -0
- data/po4a.cfg +11 -0
- metadata +13 -7
- data/.codeclimate.yml +0 -28
- data/.travis.yml +0 -9
data/.rubocop_todo.yml
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2023-06-18 08:39:04 UTC using RuboCop version 1.48.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 30
|
10
|
-
Metrics/AbcSize:
|
11
|
-
Max: 127
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.5.1] - 2023-06-24
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
* Update required Ruby version to 3.0 (security fix only stable
|
15
|
+
version), although the library itself might works with older Ruby
|
16
|
+
versions.
|
17
|
+
|
18
|
+
### Others
|
19
|
+
|
20
|
+
* Refactor parser with StringScanner. This makes parser approx. 5x
|
21
|
+
faster.
|
22
|
+
* Fixed link to json-kifu-format
|
23
|
+
* Remove Inch CI link on readmes
|
24
|
+
* Lint Ruby sources
|
25
|
+
* Add benchmark script
|
26
|
+
|
27
|
+
## [0.5.0] - 2023-06-18
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
|
31
|
+
* Set required Ruby version to 2.7; this will be updated to 3.0 or
|
32
|
+
later in the next release.
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
* Remove `Fixnum` usage with integrated `Integer` for Ruby 3.2 or
|
37
|
+
later.
|
38
|
+
|
39
|
+
### Others
|
40
|
+
|
41
|
+
* Remove Rake version constraint
|
42
|
+
* Support development on Guix
|
43
|
+
* Enable RubyGems MFA required to true (for maintainers)
|
44
|
+
|
45
|
+
Documents:
|
46
|
+
|
47
|
+
* Fixed readme usages
|
48
|
+
* Update English readme; introduce translation management
|
49
|
+
* Update readme links about CI or code coverage services
|
50
|
+
|
51
|
+
CI:
|
52
|
+
|
53
|
+
* Migrate CI from Travis CI to GitHub Actions
|
54
|
+
* Migrate from Code Climate to SimpleCov
|
55
|
+
|
56
|
+
Lint tool:
|
57
|
+
|
58
|
+
* Update RuboCop versin and config
|
59
|
+
* Lint source codes with RuboCop
|
60
|
+
|
61
|
+
and,
|
62
|
+
|
63
|
+
* Add this changelog
|
data/Gemfile
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem
|
5
|
+
gem 'rake'
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem
|
9
|
-
gem
|
8
|
+
gem 'redcarpet', require: false
|
9
|
+
gem 'yard', require: false
|
10
10
|
|
11
|
-
gem
|
12
|
-
gem
|
11
|
+
gem 'guard-rubocop', require: false
|
12
|
+
gem 'rubocop', '~> 1.32.0', require: false
|
13
|
+
gem 'rubocop-rake', '~> 0.6.0', require: false
|
14
|
+
gem 'rubocop-rspec', '~> 2.12', require: false
|
13
15
|
end
|
14
16
|
|
15
17
|
group :test do
|
16
|
-
gem
|
17
|
-
gem
|
18
|
-
gem
|
18
|
+
gem 'guard-rspec', require: false
|
19
|
+
gem 'rspec', '~> 3.0', require: false
|
20
|
+
gem 'simplecov', require: false
|
19
21
|
end
|
data/Guardfile
CHANGED
@@ -3,8 +3,8 @@ scope(groups: %w(specs))
|
|
3
3
|
directories %w(spec lib)
|
4
4
|
|
5
5
|
group :specs, halt_on_fail: true do
|
6
|
-
guard :rspec, cmd:
|
7
|
-
require
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec', failed_mode: :keep do
|
7
|
+
require 'guard/rspec/dsl'
|
8
8
|
dsl = Guard::RSpec::Dsl.new(self)
|
9
9
|
|
10
10
|
# RSpec files
|
@@ -18,7 +18,7 @@ group :specs, halt_on_fail: true do
|
|
18
18
|
dsl.watch_spec_files_for(ruby.lib_files)
|
19
19
|
end
|
20
20
|
|
21
|
-
guard :rubocop, all_on_start: false, cli:
|
21
|
+
guard :rubocop, all_on_start: false, cli: '--rails' do
|
22
22
|
watch(%r{.+\.rb$}) { |m| m[0] }
|
23
23
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
24
24
|
end
|
data/README.en.md
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
# Jkf
|
2
|
-
[![Gem
|
2
|
+
[![Gem
|
3
|
+
Version](https://badge.fury.io/rb/jkf.svg)](https://badge.fury.io/rb/jkf)
|
4
|
+
[![Build
|
5
|
+
Status](https://travis-ci.org/iyuuya/jkf.svg?branch=master)](https://travis-ci.org/iyuuya/jkf)
|
6
|
+
[![CI](https://github.com/iyuuya/jkf/actions/workflows/ci.yml/badge.svg)](https://github.com/iyuuya/jkf/actions/workflows/ci.yml)
|
3
7
|
|
8
|
+
jkf is a Ruby port of [json-kifu-format][jkf].
|
9
|
+
It supports both of the conversion from KIF, KI2, or CSA to jkf, and the one
|
10
|
+
from jkf to KIF, KI2, or CSA.
|
4
11
|
|
5
|
-
jkf
|
6
|
-
|
7
|
-
### Feature
|
8
|
-
|
9
|
-
* KIF, KI2, CSA to JKF
|
10
|
-
* JKF to KIF, KI2, CSA
|
12
|
+
[jkf]:https://github.com/na2hiro/Kifu-for-JS/tree/master/packages/json-kifu-format
|
11
13
|
|
12
14
|
## Installation
|
13
15
|
|
14
|
-
|
16
|
+
If you install this gem to your application (with Bundler), add this to
|
17
|
+
Gemfile.
|
15
18
|
|
16
19
|
```ruby
|
17
20
|
gem 'jkf'
|
18
21
|
```
|
19
22
|
|
20
|
-
|
23
|
+
Then run bundle to install this gem.
|
21
24
|
|
22
25
|
$ bundle
|
23
26
|
|
24
|
-
Or install
|
27
|
+
Or directly install with gem install command.
|
25
28
|
|
26
29
|
$ gem install jkf
|
27
30
|
|
28
31
|
## Usage
|
29
32
|
|
33
|
+
This gem has the Parser and the Converter for each formats: KIF, KI2, and
|
34
|
+
CSA.
|
35
|
+
|
30
36
|
```ruby
|
31
37
|
kif_parser = Jkf::Parser::Kif.new
|
32
38
|
ki2_parser = Jkf::Parser::Ki2.new
|
@@ -39,6 +45,9 @@ ki2_converter = Jkf::Converter::Ki2.new
|
|
39
45
|
csa_converter = Jkf::Converter::Csa.new
|
40
46
|
```
|
41
47
|
|
48
|
+
`parser#parse(str)` to convert into jkf.
|
49
|
+
`#convert(jkf)` to convert into each formats from jkf.
|
50
|
+
|
42
51
|
```ruby
|
43
52
|
jkf = kif_parser.parse(kif_str) #=> Hash
|
44
53
|
jkf = ki2_parser.parse(ki2_str) #=> Hash
|
@@ -46,16 +55,20 @@ jkf = csa_parser.parse(csa_str) #=> Hash
|
|
46
55
|
```
|
47
56
|
|
48
57
|
```ruby
|
49
|
-
kif = kif_converter.
|
50
|
-
ki2 = ki2_converter.
|
51
|
-
csa = csa_converter.
|
58
|
+
kif = kif_converter.convert(jkf) #=> String
|
59
|
+
ki2 = ki2_converter.convert(jkf) #=> String
|
60
|
+
csa = csa_converter.convert(jkf) #=> String
|
52
61
|
```
|
53
62
|
|
54
63
|
## Contributing
|
55
64
|
|
56
|
-
|
65
|
+
Feel free to report bugs or send pull requests at
|
66
|
+
[GitHub](https://github.com/iyuuya/jkf).
|
67
|
+
|
68
|
+
If you work on Guix, run tests by `guix shell`.
|
57
69
|
|
58
70
|
## License
|
59
71
|
|
60
|
-
|
72
|
+
This gem is licensed under the [MIT
|
73
|
+
License](http://opensource.org/licenses/MIT).
|
61
74
|
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Jkf
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/jkf.svg)](https://badge.fury.io/rb/jkf) [![Build Status](https://travis-ci.org/iyuuya/jkf.svg?branch=master)](https://travis-ci.org/iyuuya/jkf) [![
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/jkf.svg)](https://badge.fury.io/rb/jkf) [![Build Status](https://travis-ci.org/iyuuya/jkf.svg?branch=master)](https://travis-ci.org/iyuuya/jkf) [![CI](https://github.com/iyuuya/jkf/actions/workflows/ci.yml/badge.svg)](https://github.com/iyuuya/jkf/actions/workflows/ci.yml)
|
3
3
|
|
4
|
-
jkfはJSON棋譜フォーマット(
|
4
|
+
jkfは[JSON棋譜フォーマット (JKF)][jkf]をRubyに移植したものです。
|
5
5
|
KIF, KI2, CSAをパースしJKFへ変換、JKFからKIF, KI2, CSAへの変換に対応しています。
|
6
6
|
|
7
|
+
[jkf]: https://github.com/na2hiro/Kifu-for-JS/tree/master/packages/json-kifu-format
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
アプリケーションにインストールする場合(bundlerを使用する場合)、Gemfileに以下のように記述してください。
|
@@ -45,9 +47,9 @@ jkf = csa_parser.parse(csa_str) #=> Hash
|
|
45
47
|
```
|
46
48
|
|
47
49
|
```ruby
|
48
|
-
kif = kif_converter.
|
49
|
-
ki2 = ki2_converter.
|
50
|
-
csa = csa_converter.
|
50
|
+
kif = kif_converter.convert(jkf) #=> String
|
51
|
+
ki2 = ki2_converter.convert(jkf) #=> String
|
52
|
+
csa = csa_converter.convert(jkf) #=> String
|
51
53
|
```
|
52
54
|
|
53
55
|
## Contributing
|
@@ -55,6 +57,8 @@ csa = csa_converter.parse(jkf) #=> String
|
|
55
57
|
バグレポートやプルリクエストはGithubでよろしくお願いします。
|
56
58
|
https://github.com/iyuuya/jkf.
|
57
59
|
|
60
|
+
Guixで開発されている場合は`guix shell`で`rake test`によるテスト実行ができます。
|
61
|
+
|
58
62
|
## License
|
59
63
|
|
60
64
|
ライセンスはMITです。
|
data/Rakefile
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task default: :spec
|
7
|
+
|
8
|
+
desc 'translate documents'
|
9
|
+
task :translate do
|
10
|
+
sh 'po4a po4a.cfg'
|
11
|
+
end
|
data/bench.rb
ADDED
data/bin/console
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'jkf'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
if require
|
10
|
+
if require 'pry'
|
11
11
|
Pry.start
|
12
12
|
else
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
15
15
|
end
|
data/jkf.gemspec
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
3
|
+
require 'jkf/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'jkf'
|
8
7
|
spec.version = Jkf::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
8
|
+
spec.authors = ['iyuuya']
|
9
|
+
spec.email = ['i.yuuya@gmail.com']
|
11
10
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
11
|
+
spec.summary = 'jkf/csa/kif/ki2 parser and converter'
|
12
|
+
spec.description = 'converter/parser of records of shogi'
|
13
|
+
spec.homepage = 'https://github.com/iyuuya/jkf'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.required_ruby_version = '>= 3.0'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir =
|
19
|
+
spec.bindir = 'exe'
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
21
23
|
end
|
data/lib/jkf/converter/base.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
module Jkf
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
module Jkf
|
2
|
+
module Converter
|
3
|
+
# Base of Converter
|
4
|
+
class Base
|
5
|
+
# start convert
|
6
|
+
#
|
7
|
+
# @param [String, Hash] jkf
|
8
|
+
# @return [String] kif or ki2 or csa text
|
9
|
+
def convert(jkf)
|
10
|
+
jkf = jkf.is_a?(Hash) ? jkf : JSON.parse(jkf)
|
11
|
+
convert_root(jkf)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|