jkf 0.5.3 → 0.5.4

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
  SHA256:
3
- metadata.gz: 9aa24be83e28547743c1bc4c5c12e3b336fe4f448d8cd8f729620c9878a1de42
4
- data.tar.gz: bc7e2b1eba4f7f9c970d266cba6f4887444dde261169a0e8d52eb02642802e0b
3
+ metadata.gz: e28e629f7c141b7493f9a9e978f6339b8e5730b9fc1539ce7617fe3847e96da6
4
+ data.tar.gz: 16766fef773477ba942d1832e1d40b94328b4006177e8871c15874133688d059
5
5
  SHA512:
6
- metadata.gz: 86861a9621a3dc7fa5e7c61fbeeb53c5791bc28fc37b53f3b7bbea44e4f85b0489d4c7b9da2e669432861ac007cf25803dc99c14cbd9b667969df43ef4871a97
7
- data.tar.gz: 5d2ea1626f6a644760b2ae533fdd5497bd3c5c6e14f73e1001146315008ffd6e5424f5acfe9b0654f8793743baf20a96ca228b8cb42f4b16b8c98b5998868627
6
+ metadata.gz: 9540ce1699ffa3ca96b1e56ed58fd1b9495b084e61d2c548896f689f46ad50d169cf56f775b9091ab7b968d0541b29f2f6f4934bf48e62d2bcba70a274c688b6
7
+ data.tar.gz: 2fd77c3f1183380b7819d7946c1b4cd6b897b089e5714fa7ca8f50da9205cce3c4493b1fecca359b84b9213c123a8a49a198869544c45350afb5588b6205673e
data/.dir-locals.el ADDED
@@ -0,0 +1,4 @@
1
+ ;;; Directory Local Variables -*- no-byte-compile: t -*-
2
+ ;;; For more information see (info "(emacs) Directory Variables")
3
+
4
+ ((nil . ((grep-find-ignored-directories . ("coverage")))))
@@ -0,0 +1,31 @@
1
+ # https://guides.rubygems.org/trusted-publishing/releasing-gems/
2
+ name: Release
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+ workflow_dispatch:
8
+ jobs:
9
+ push:
10
+ name: Push gem to RubyGems.org
11
+ runs-on: ubuntu-latest
12
+
13
+ permissions:
14
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
15
+ contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
16
+
17
+ environment: release
18
+
19
+ steps:
20
+ # Set up
21
+ - uses: actions/checkout@v6
22
+ with:
23
+ persist-credentials: false
24
+ - name: Set up Ruby
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ bundler-cache: true
28
+ ruby-version: ruby
29
+
30
+ # Release
31
+ - uses: rubygems/release-gem@v1
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## 0.5.4 - 2026-05-02
11
+
12
+ Revert project links.
13
+ Enable Trusted Publishing.
14
+
10
15
  ## 0.5.3 - 2025-07-21
11
16
 
12
17
  Update project links.
data/README.md CHANGED
@@ -55,7 +55,7 @@ csa = csa_converter.convert(jkf) #=> String
55
55
 
56
56
  バグレポートやプルリクエストは[リポジトリ][repo]でよろしくお願いします。
57
57
 
58
- [repo]: https://sourceforge.net/p/ruby-jkf/code/
58
+ [repo]: https://github.com/gemmaro/jkf
59
59
 
60
60
  Guixで開発されている場合は`guix shell`で`rake test`によるテスト実行ができます。
61
61
 
@@ -70,7 +70,7 @@ POTファイルの生成には`rdoc --format pot`とします。
70
70
 
71
71
  このプロジェクトは[GitHubのiyuuya/jkf](https://github.com/iyuuya/jkf)を元にしています。
72
72
  そこから[GitHubのgemmaro/jkf](https://github.com/gemmaro/jkf)にフォークされました。
73
- 現在の開発は[SourceForgeのjkf](https://sourceforge.net/projects/ruby-jkf/)に移っています。
73
+ 現在の開発はこのGitHubリポジトリに移っています(一時期[SourceForge](https://sourceforge.net/projects/ruby-jkf/)を試していましたがTrusted PublishingのためにGitHubに戻します)。
74
74
 
75
75
  ## 利用許諾
76
76
 
data/jkf.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = 'Shogi formats parser and converter'
12
12
  spec.description = 'The jkf gem provides parsers and converters (generaters) for several shogi formats, including json-kifu-format, KIF, KI2, and CSA.'
13
- spec.homepage = 'https://sourceforge.net/projects/ruby-jkf/'
13
+ spec.homepage = 'https://github.com/gemmaro/jkf'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.required_ruby_version = '>= 3.0'
@@ -8,34 +8,34 @@ module Jkf
8
8
 
9
9
  def convert_root(jkf)
10
10
  result = version
11
- result += convert_information(jkf['header']) if jkf['header']
12
- result += convert_initial(jkf['initial']) if jkf['initial']
13
- result += convert_moves(jkf['moves']) if jkf['moves']
11
+ result << convert_information(jkf['header']) if jkf['header']
12
+ result << convert_initial(jkf['initial']) if jkf['initial']
13
+ result << convert_moves(jkf['moves']) if jkf['moves']
14
14
  result
15
15
  end
16
16
 
17
17
  def convert_information(header)
18
18
  result = ''
19
- result += 'N+' + (header.delete('先手') || header.delete('下手') || '') + "\n" if header['先手'] || header['下手']
20
- result += 'N-' + (header.delete('後手') || header.delete('上手') || '') + "\n" if header['後手'] || header['上手']
21
- header.each { |(k, v)| result += "$#{csa_header_key(k)}:#{v}\n" }
19
+ result << 'N+' + (header.delete('先手') || header.delete('下手') || '') + "\n" if header['先手'] || header['下手']
20
+ result << 'N-' + (header.delete('後手') || header.delete('上手') || '') + "\n" if header['後手'] || header['上手']
21
+ header.each { |(k, v)| result << "$#{csa_header_key(k)}:#{v}\n" }
22
22
  result
23
23
  end
24
24
 
25
25
  def convert_initial(initial)
26
26
  result = ''
27
27
  data = initial['data'] || {}
28
- result += if initial['preset'] == 'OTHER'
28
+ result << if initial['preset'] == 'OTHER'
29
29
  convert_board(data['board'])
30
30
  else
31
31
  convert_preset(initial['preset'])
32
32
  end
33
33
  # 持駒
34
34
  if data['hands']
35
- result += convert_hands(data['hands'], 0)
36
- result += convert_hands(data['hands'], 1)
35
+ result << convert_hands(data['hands'], 0)
36
+ result << convert_hands(data['hands'], 1)
37
37
  end
38
- result += csa_color(data['color']) + "\n" if data['color']
38
+ result << csa_color(data['color']) + "\n" if data['color']
39
39
  result
40
40
  end
41
41
 
@@ -44,9 +44,9 @@ module Jkf
44
44
  sum = 0
45
45
  hands[color].each_value { |n| sum += n }
46
46
  if sum > 0
47
- result += "P#{csa_color(color)}"
48
- hands[color].to_a.reverse_each { |(k, v)| v.times { result += "00#{k}" } }
49
- result += "\n"
47
+ result << "P#{csa_color(color)}"
48
+ hands[color].to_a.reverse_each { |(k, v)| v.times { result << "00#{k}" } }
49
+ result << "\n"
50
50
  end
51
51
  result
52
52
  end
@@ -57,14 +57,14 @@ module Jkf
57
57
  moves.each do |move|
58
58
  next if move == {}
59
59
 
60
- result += convert_move(move['move'], before_pos) if move['move']
61
- result += convert_special(move['special'], move['color']) if move['special']
60
+ result << convert_move(move['move'], before_pos) if move['move']
61
+ result << convert_special(move['special'], move['color']) if move['special']
62
62
  if move['time']
63
- result += ',' + convert_time(move['time'])
63
+ result << ',' + convert_time(move['time'])
64
64
  elsif move['move'] || move['special']
65
- result += "\n"
65
+ result << "\n"
66
66
  end
67
- result += convert_comments(move['comments']) if move['comments']
67
+ result << convert_comments(move['comments']) if move['comments']
68
68
  before_pos = move['move']['to'] if move['move'] && move['move']['to']
69
69
  end
70
70
  result
@@ -72,8 +72,8 @@ module Jkf
72
72
 
73
73
  def convert_move(move, before_pos)
74
74
  result = csa_color(move['color'])
75
- result += move['from'] ? pos2str(move['from']) : '00'
76
- result += if move['to']
75
+ result << (move['from'] ? pos2str(move['from']) : '00')
76
+ result << if move['to']
77
77
  pos2str(move['to']) + move['piece']
78
78
  else
79
79
  pos2str(before_pos) + move['piece']
@@ -83,8 +83,8 @@ module Jkf
83
83
 
84
84
  def convert_special(special, color = nil)
85
85
  result = '%'
86
- result += csa_color(color) if color
87
- result + special
86
+ result << csa_color(color) if color
87
+ result << special
88
88
  end
89
89
 
90
90
  def convert_time(time)
@@ -99,22 +99,22 @@ module Jkf
99
99
  def convert_board(board)
100
100
  result = ''
101
101
  9.times do |y|
102
- result += "P#{y + 1}"
102
+ result << "P#{y + 1}"
103
103
  9.times do |x|
104
104
  piece = board[8 - x][y]
105
- result += if piece == {}
105
+ result << if piece == {}
106
106
  ' * '
107
107
  else
108
108
  csa_color(piece['color']) + piece['kind']
109
109
  end
110
110
  end
111
- result += "\n"
111
+ result << "\n"
112
112
  end
113
113
  result
114
114
  end
115
115
 
116
116
  def convert_preset(preset)
117
- 'PI' + PRESET_NAME_TO_CSA_MAPPING[preset]
117
+ 'PI' << PRESET_NAME_TO_CSA_MAPPING[preset]
118
118
  end
119
119
 
120
120
  PRESET_NAME_TO_CSA_MAPPING = {
@@ -11,13 +11,13 @@ module Jkf
11
11
  setup_players!(jkf)
12
12
 
13
13
  result = ''
14
- result += convert_header(jkf['header']) if jkf['header']
15
- result += convert_initial(jkf['initial']) if jkf['initial']
16
- result += @header2.join + "\n"
17
- result += convert_moves(jkf['moves']) if jkf['moves']
14
+ result << convert_header(jkf['header']) if jkf['header']
15
+ result << convert_initial(jkf['initial']) if jkf['initial']
16
+ result << @header2.join + "\n"
17
+ result << convert_moves(jkf['moves']) if jkf['moves']
18
18
  unless @forks.empty?
19
- result += "\n"
20
- result += @forks.join("\n")
19
+ result << "\n"
20
+ result << @forks.join("\n")
21
21
  end
22
22
 
23
23
  result
@@ -53,22 +53,22 @@ module Jkf
53
53
  moves.each_with_index do |move, i|
54
54
  if move['special']
55
55
  # first_board+speical分を引く(-2)
56
- result += convert_special_and_split(move, i + idx - 2)
56
+ result << convert_special_and_split(move, i + idx - 2)
57
57
  else
58
- result += before_split
58
+ result << before_split
59
59
  if move['move']
60
60
  j += 1
61
61
  result_move, before_split = convert_move_and_split(move, j)
62
- result += result_move
62
+ result << result_move
63
63
  end
64
64
 
65
65
  if move['comments']
66
66
  unless result.end_with?("\n") || result.empty?
67
- result += "\n"
67
+ result << "\n"
68
68
  before_split = ''
69
69
  j = 0
70
70
  end
71
- result += convert_comments(move['comments'])
71
+ result << convert_comments(move['comments'])
72
72
  end
73
73
 
74
74
  @forks.unshift convert_forks(move['forks'], i + idx) if move['forks']
@@ -93,8 +93,8 @@ module Jkf
93
93
 
94
94
  def convert_move(move)
95
95
  result = move['color'] == 0 ? '▲' : '△'
96
- result += convert_piece_with_pos(move)
97
- result += csa2relative(move['relative']) if move['relative']
96
+ result << convert_piece_with_pos(move)
97
+ result << csa2relative(move['relative']) if move['relative']
98
98
  result
99
99
  end
100
100
 
@@ -11,14 +11,14 @@ module Jkf
11
11
  setup_players!(jkf)
12
12
 
13
13
  result = ''
14
- result += convert_header(jkf['header'], jkf) if jkf['header']
15
- result += convert_initial(jkf['initial']) if jkf['initial']
16
- result += @header2.join
17
- result += "手数----指手---------消費時間--\n"
18
- result += convert_moves(jkf['moves'])
14
+ result << convert_header(jkf['header'], jkf) if jkf['header']
15
+ result << convert_initial(jkf['initial']) if jkf['initial']
16
+ result << @header2.join
17
+ result << "手数----指手---------消費時間--\n"
18
+ result << convert_moves(jkf['moves'])
19
19
  unless @forks.empty?
20
- result += "\n"
21
- result += @forks.join("\n")
20
+ result << "\n"
21
+ result << @forks.join("\n")
22
22
  end
23
23
 
24
24
  result
@@ -46,10 +46,10 @@ module Jkf
46
46
  result = ''
47
47
  moves.each_with_index do |move, i|
48
48
  if move['special']
49
- result += convert_special_line(move, i + idx)
49
+ result << convert_special_line(move, i + idx)
50
50
  else
51
- result += convert_move_line(move, i + idx) if move['move']
52
- result += convert_comments(move['comments']) if move['comments']
51
+ result << convert_move_line(move, i + idx) if move['move']
52
+ result << convert_comments(move['comments']) if move['comments']
53
53
  @forks.unshift convert_forks(move['forks'], i + idx) if move['forks']
54
54
  end
55
55
  end
@@ -58,25 +58,25 @@ module Jkf
58
58
 
59
59
  def convert_move_line(move, index)
60
60
  result = format('%4d ', index)
61
- result += convert_move(move['move'])
62
- result += convert_time(move['time']) if move['time']
63
- result += '+' if move['forks']
64
- result + "\n"
61
+ result << convert_move(move['move'])
62
+ result << convert_time(move['time']) if move['time']
63
+ result << '+' if move['forks']
64
+ result << "\n"
65
65
  end
66
66
 
67
67
  def convert_special_line(move, index)
68
68
  result = format('%4d ', index)
69
- result += ljust(special2kan(move['special']), 13)
70
- result += convert_time(move['time']) if move['time']
71
- result += '+' if move['forks']
72
- result += "\n"
69
+ result << ljust(special2kan(move['special']), 13)
70
+ result << convert_time(move['time']) if move['time']
71
+ result << '+' if move['forks']
72
+ result << "\n"
73
73
  # first_board+speical分を引く(-2)
74
- result + convert_special(move['special'], index - 2)
74
+ result << convert_special(move['special'], index - 2)
75
75
  end
76
76
 
77
77
  def convert_move(move)
78
78
  result = convert_piece_with_pos(move)
79
- result += if move['from']
79
+ result << if move['from']
80
80
  "(#{pos2str(move['from'])})"
81
81
  else
82
82
  '打'
@@ -10,16 +10,16 @@ module Jkf
10
10
 
11
11
  data = initial['data']
12
12
  if data
13
- result += convert_teban(data, 1)
13
+ result << convert_teban(data, 1)
14
14
  if (hands = data['hands'])
15
- result += convert_hands(hands, 1) if hands[1]
16
- footer += convert_hands(hands, 0) if hands[0]
15
+ result << convert_hands(hands, 1) if hands[1]
16
+ footer << convert_hands(hands, 0) if hands[0]
17
17
  end
18
- footer += convert_teban(data, 0)
18
+ footer << convert_teban(data, 0)
19
19
 
20
- result += convert_board(data['board']) if data['board']
20
+ result << convert_board(data['board']) if data['board']
21
21
  end
22
- result + footer
22
+ result << footer
23
23
  end
24
24
 
25
25
  def convert_handicap(preset)
@@ -39,12 +39,12 @@ module Jkf
39
39
  9.times do |y|
40
40
  line = '|'
41
41
  9.times do |x|
42
- line += convert_board_piece(board[8 - x][y])
42
+ line << convert_board_piece(board[8 - x][y])
43
43
  end
44
- line += "|#{n2kan(y + 1)}\n"
45
- result += line
44
+ line << "|#{n2kan(y + 1)}\n"
45
+ result << line
46
46
  end
47
- result + "+---------------------------+\n"
47
+ result << "+---------------------------+\n"
48
48
  end
49
49
 
50
50
  def convert_comments(comments)
@@ -56,9 +56,9 @@ module Jkf
56
56
  if num > 0
57
57
  str = csa2kind(piece)
58
58
  if num > 1
59
- str += n2kan(num / 10) if num / 10 > 0
59
+ str << n2kan(num / 10) if num / 10 > 0
60
60
  num %= 10
61
- str += n2kan(num)
61
+ str << n2kan(num)
62
62
  end
63
63
  str
64
64
  end
@@ -71,8 +71,8 @@ module Jkf
71
71
  if piece == {}
72
72
  result = ' ・'
73
73
  else
74
- result += piece['color'] == 0 ? ' ' : 'v'
75
- result += csa2kind(piece['kind'])
74
+ result << (piece['color'] == 0 ? ' ' : 'v')
75
+ result << csa2kind(piece['kind'])
76
76
  end
77
77
 
78
78
  result
@@ -83,13 +83,13 @@ module Jkf
83
83
 
84
84
  if special == 'TORYO' || special.include?('ILLEGAL')
85
85
  turn = @players[index % 2]
86
- result += "で#{turn}手の"
87
- result += { 'TORYO' => '勝ち',
86
+ result << "で#{turn}手の"
87
+ result << { 'TORYO' => '勝ち',
88
88
  'ILLEGAL_ACTION' => '反則勝ち',
89
89
  'ILLEGAL_MOVE' => '反則負け' }[special]
90
90
  else
91
91
  turn = @players[(index + 1) % 2]
92
- result += case special
92
+ result << case special
93
93
  when 'TIME_UP' then "で時間切れにより#{turn}手の勝ち"
94
94
  when 'CHUDAN' then 'で中断'
95
95
  when 'JISHOGI' then 'で持将棋'
@@ -99,7 +99,7 @@ module Jkf
99
99
  end
100
100
  end
101
101
 
102
- result + "\n"
102
+ result << "\n"
103
103
  end
104
104
 
105
105
  def convert_piece_with_pos(move)
@@ -108,8 +108,8 @@ module Jkf
108
108
  elsif move['same']
109
109
  '同 '
110
110
  end
111
- result += csa2kind(move['piece'])
112
- result += '成' if move['promote']
111
+ result << csa2kind(move['piece'])
112
+ result << '成' if move['promote']
113
113
  result
114
114
  end
115
115
 
@@ -117,7 +117,7 @@ module Jkf
117
117
  result = "\n"
118
118
  result = format("変化:%4d手\n", index) # ki2の場合\nなし
119
119
  forks.each do |moves|
120
- result += convert_moves(moves, index)
120
+ result << convert_moves(moves, index)
121
121
  end
122
122
  result
123
123
  end
data/lib/jkf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jkf
2
- VERSION = '0.5.3'
2
+ VERSION = '0.5.4'
3
3
  end
data/manifest.scm CHANGED
@@ -9,6 +9,44 @@
9
9
  (guix git-download)
10
10
  (guix profiles))
11
11
 
12
+ (define-public ruby-typeprof
13
+ (package
14
+ (name "ruby-typeprof")
15
+ (version "0.31.0")
16
+ (source (origin
17
+ (method git-fetch) ;for Rakefile
18
+ (uri (git-reference
19
+ (url "https://github.com/ruby/typeprof")
20
+ (commit (string-append "v" version))))
21
+ (file-name (git-file-name name version))
22
+ (sha256
23
+ (base32
24
+ "0919djm8vsissm2f3blm87k7p11lcw4nqb9rcq7adzflx4g3qar9"))))
25
+ (build-system ruby-build-system)
26
+ (arguments (list #:tests? #f
27
+ #:phases #~(modify-phases %standard-phases
28
+ (add-before 'build 'remove-files-field
29
+ (lambda _
30
+ (substitute* "typeprof.gemspec"
31
+ (("spec[.]files(.|\n)+^[ ]+end") ""))))
32
+ (add-before 'build 'delete-tests
33
+ (lambda _
34
+ (delete-file-recursively "test"))))))
35
+ (propagated-inputs (list ruby-prism))
36
+ (synopsis
37
+ "TypeProf performs a type analysis of non-annotated Ruby code. It
38
+ abstractly executes input Ruby code in a level of types instead of
39
+ values, gathers what types are passed to and returned by methods, and
40
+ prints the analysis result in RBS format, a standard type description
41
+ format for Ruby 3.0.")
42
+ (description
43
+ "@code{TypeProf} performs a type analysis of non-annotated Ruby code. It
44
+ abstractly executes input Ruby code in a level of types instead of values,
45
+ gathers what types are passed to and returned by methods, and prints the
46
+ analysis result in RBS format, a standard type description format for Ruby 3.0.")
47
+ (home-page "https://github.com/ruby/typeprof")
48
+ (license license:expat)))
49
+
12
50
  (packages->manifest (list ruby-rake
13
51
  ruby-yard
14
52
  ruby-rspec
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jkf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - iyuuya
8
8
  - gemmaro
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-07-21 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
@@ -34,7 +33,9 @@ executables: []
34
33
  extensions: []
35
34
  extra_rdoc_files: []
36
35
  files:
36
+ - ".dir-locals.el"
37
37
  - ".envrc"
38
+ - ".github/workflows/release.yaml"
38
39
  - ".gitignore"
39
40
  - ".rspec"
40
41
  - ".yardopts"
@@ -65,13 +66,12 @@ files:
65
66
  - po/en.po
66
67
  - po/en.rdoc.po
67
68
  - po4a.cfg
68
- homepage: https://sourceforge.net/projects/ruby-jkf/
69
+ homepage: https://github.com/gemmaro/jkf
69
70
  licenses:
70
71
  - MIT
71
72
  metadata:
72
73
  rubygems_mfa_required: 'true'
73
74
  documentation_uri: https://www.rubydoc.info/gems/jkf
74
- post_install_message:
75
75
  rdoc_options: []
76
76
  require_paths:
77
77
  - lib
@@ -86,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.5.22
90
- signing_key:
89
+ rubygems_version: 4.0.6
91
90
  specification_version: 4
92
91
  summary: Shogi formats parser and converter
93
92
  test_files: []