portable_move_notation 0.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6205e5d1aa0950be8c8934677202eddb3b340eae622041921cd11bd0f3cfa41
4
- data.tar.gz: 3e418aa570709a18c755883a008f44bb95831cf62f300137460ab72544169994
3
+ metadata.gz: 7a008ac268dce4d3013e9c3ec9af1d12d9129099e979e89e62cd6329f4468651
4
+ data.tar.gz: f11d4a3de00b8ef92881424094db881693fc6e119786b84e61e6eda3f20c2ee7
5
5
  SHA512:
6
- metadata.gz: 0e5aafa8e00194014d5ae5a2d29b655f117c5eb61f8f2ce9e899357ec4823a475a313ed1a0f2f86d3b75cf0798aacfc937667a5becff36d09db93c65bc01871b
7
- data.tar.gz: fb2fda7806d5fb67f72483d3ff3d9fd93b5ae427bba818a1401df46cc73954c715d1a7108e2a63116c77241cc5c131528e7eb5084d56da1827a5d2fe86b2cee1
6
+ metadata.gz: 5d15617090fdcef46ee3c92ca313febf5b3e9c4f1ecd2ca15a136692fac78f27f0d985f5431d761d4cd479237f3d6daaf8c42cf626847af90d394209f0395c43
7
+ data.tar.gz: 924ebd086e03da2287d97fb613500bf49b4a3d2797dda5d0495ba67d518e887edbf131a3338bab28943bd0ba4a4a6bd772b71ff2f2d079d27ed6aba115701f11
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Cyril Kato
3
+ Copyright (c) 2019-2020 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Portable Move Notation
2
2
 
3
- A Ruby interface for data serialization in PMN format.
3
+ A Ruby interface for data serialization in [PMN](https://developer.sashite.com/specs/portable-move-notation) format.
4
4
 
5
5
  ## Installation
6
6
 
@@ -25,66 +25,56 @@ Working with PMN can be very simple, for example:
25
25
  ```ruby
26
26
  require 'portable_move_notation'
27
27
 
28
- # Parse a PMN string
29
-
30
- PortableMoveNotation.load('52,36,W:P.12,28,w:p.53,37,W:P') # => [[[52, 36, "W:P", nil]], [[12, 28, "w:p", nil]], [[53, 37, "W:P", nil]]]
31
-
32
- # Emit some PMN
28
+ # Emit a PMN string
33
29
 
34
30
  some_moves = [
35
- [[52, 36, 'W:P', nil]],
36
- [[12, 28, 'w:p', nil]],
37
- [[53, 37, 'W:P', nil]]
31
+ [52, 36, '', nil],
32
+ [12, 28, '', nil],
33
+ [53, 37, '', nil]
38
34
  ]
39
35
 
40
- PortableMoveNotation.dump(*some_moves) # => '52,36,W:P.12,28,w:p.53,37,W:P'
41
- ```
42
-
43
- ### Other examples
36
+ PortableMoveNotation.dump(*some_moves) # => "52,36,♙.12,28,♟.53,37,♙"
44
37
 
45
- #### Castling on kingside
38
+ # Parse a PMN string
46
39
 
47
- ```ruby
48
- PortableMoveNotation.dump(*[[[60, 62, "W:-K", nil], [63, 61, "W:R", nil]]]) # => "60,62,W:-K;63,61,W:R"
49
- PortableMoveNotation.load('60,62,W:-K;63,61,W:R') # => [[[60, 62, "W:-K", nil], [63, 61, "W:R", nil]]]
40
+ PortableMoveNotation.parse('52,36,♙.12,28,♟.53,37,♙') # => [[52, 36, "♙", nil], [12, 28, "♟", nil], [53, 37, "♙", nil]]
50
41
  ```
51
42
 
52
- #### Promoting a chess pawn into a knight
43
+ ## Examples
53
44
 
54
45
  ```ruby
55
- PortableMoveNotation.dump(*[[[12, 4, "W:P", "W:N"]]]) # => "12,4,W:P,W:N"
56
- PortableMoveNotation.load('12,4,W:P,W:N') # => [[[12, 4, "W:P", "W:N"]]]
57
- ```
46
+ # Black castles on king-side
58
47
 
59
- #### Promoting a shogi pawn
48
+ PortableMoveNotation.dump([60, 62, '♔', nil, 63, 61, '♖', nil]) # => "60,62,♔;63,61,♖"
49
+ PortableMoveNotation.parse('60,62,♔;63,61,♖') # => [[60, 62, "♔", nil, 63, 61, "♖", nil]]
60
50
 
61
- ```ruby
62
- PortableMoveNotation.dump(*[[[33, 24, "S:P", "S:+P"]]]) # => "33,24,S:P,S:+P"
63
- PortableMoveNotation.load('33,24,S:P,S:+P') # => [[[33, 24, "S:P", "S:+P"]]]
64
- ```
51
+ # Promoting a chess pawn into a knight
65
52
 
66
- #### Dropping a shogi pawn
53
+ PortableMoveNotation.dump([12, 4, '♘', nil]) # => "12,4,♘"
54
+ PortableMoveNotation.parse('12,4,♘') # => [[12, 4, "♘", nil]]
67
55
 
68
- ```ruby
69
- PortableMoveNotation.dump(*[[[nil, 42, "S:P", nil]]]) # => "*,42,S:P"
70
- PortableMoveNotation.load('*,42,S:P') # => [[[nil, 42, "S:P", nil]]]
71
- ```
56
+ # Capturing a rook and promoting a shogi pawn
72
57
 
73
- #### Capturing a white chess pawn en passant
58
+ PortableMoveNotation.dump([33, 24, '+P', 'R']) # => "33,24,+P,R"
59
+ PortableMoveNotation.parse('33,24,+P,R') # => [[33, 24, "+P", "R"]]
74
60
 
75
- ```ruby
76
- PortableMoveNotation.dump(*[[[48, 32, "W:P", nil]], [[33, 32, "w:p", nil], [32, 40, "w:p", nil]]]) # => "48,32,W:P.33,32,w:p;32,40,w:p"
77
- PortableMoveNotation.load('48,32,W:P.33,32,w:p;32,40,w:p') # => [[[48, 32, "W:P", nil]], [[33, 32, "w:p", nil], [32, 40, "w:p", nil]]]
78
- ```
61
+ # Dropping a shogi pawn
62
+
63
+ PortableMoveNotation.dump([nil, 42, 'P', nil]) # => "*,42,P"
64
+ PortableMoveNotation.parse('*,42,P') # => [[nil, 42, "P", nil]]
79
65
 
80
- ## Contributing
66
+ # Capturing a white chess pawn en passant
81
67
 
82
- Bug reports and pull requests are welcome on GitHub at https://github.com/sashite/portable_move_notation.rb. 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.
68
+ PortableMoveNotation.dump([48, 32, '♙', nil], [33, 32, '♟', nil, 32, 40, '♟', nil]) # => "48,32,♙.33,32,♟;32,40,♟"
69
+ PortableMoveNotation.parse('48,32,♙.33,32,♟;32,40,♟') # => [[48, 32, "♙", nil], [33, 32, "♟", nil, 32, 40, "♟", nil]]
70
+ ```
83
71
 
84
72
  ## License
85
73
 
86
74
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
87
75
 
88
- ## Code of Conduct
76
+ ## About Sashite
77
+
78
+ The `portable_move_notation` gem is maintained by [Sashite](https://sashite.com/).
89
79
 
90
- Everyone interacting in the PortableMoveNotation project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/sashite/portable_move_notation.rb/blob/master/CODE_OF_CONDUCT.md).
80
+ With some [lines of code](https://github.com/sashite/), let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!
@@ -3,13 +3,13 @@
3
3
  # Portable Move Notation module
4
4
  module PortableMoveNotation
5
5
  def self.dump(*moves)
6
- Dump.call(*moves)
6
+ Dumper.call(*moves)
7
7
  end
8
8
 
9
- def self.load(pmn_string)
10
- Load.call(pmn_string)
9
+ def self.parse(string)
10
+ Parser.call(string)
11
11
  end
12
12
  end
13
13
 
14
- require_relative 'portable_move_notation/dump'
15
- require_relative 'portable_move_notation/load'
14
+ require_relative 'portable_move_notation/dumper'
15
+ require_relative 'portable_move_notation/parser'
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'move'
4
+
5
+ module PortableMoveNotation
6
+ # Dumper class
7
+ class Dumper < Move
8
+ def self.call(*moves)
9
+ moves.map { |move| ::Sashite::PAN::Dumper.call(*move.each_slice(4)) }
10
+ .join(separator)
11
+ end
12
+ end
13
+ end
14
+
15
+ require 'sashite/pan/dumper'
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PortableMoveNotation
4
+ # Move class
5
+ class Move
6
+ private_class_method def self.separator
7
+ '.'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'move'
4
+
5
+ module PortableMoveNotation
6
+ # Parser class
7
+ class Parser < Move
8
+ def self.call(string)
9
+ string.split(separator)
10
+ .map { |serialized_move| new(serialized_move).call }
11
+ end
12
+
13
+ attr_reader :serialized_actions
14
+
15
+ def initialize(serialized_move)
16
+ @serialized_actions = serialized_move.split(';')
17
+ end
18
+
19
+ def call
20
+ serialized_actions.flat_map { |string| action_items(*string.split(',')) }
21
+ end
22
+
23
+ private
24
+
25
+ def action_items(*args)
26
+ src_square = args.fetch(0)
27
+ src_square = src_square.eql?(drop_char) ? nil : Integer(src_square)
28
+ dst_square = Integer(args.fetch(1))
29
+ piece_name = args.fetch(2)
30
+ piece_hand = args.fetch(3, nil)
31
+
32
+ [src_square, dst_square, piece_name, piece_hand]
33
+ end
34
+
35
+ def drop_char
36
+ '*'
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portable_move_notation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-05 00:00:00.000000000 Z
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sashite-pan
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: awesome_print
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -28,16 +42,16 @@ dependencies:
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '2.0'
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '2.0'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: byebug
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -56,105 +70,92 @@ dependencies:
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '12.3'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '12.3'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rubocop
84
+ name: rubocop-performance
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '0.72'
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '0.72'
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: rubocop-performance
98
+ name: rubocop-thread_safety
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '1.4'
103
+ version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '1.4'
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '0.17'
117
+ version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '0.17'
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: yard
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - "~>"
129
+ - - ">="
116
130
  - !ruby/object:Gem::Version
117
- version: '0.9'
131
+ version: '0'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - "~>"
136
+ - - ">="
123
137
  - !ruby/object:Gem::Version
124
- version: '0.9'
125
- description: A Ruby interface for data serialization in PMN format.
126
- email:
127
- - contact@cyril.email
138
+ version: '0'
139
+ description: A Ruby interface for data serialization in PMN (Portable Move Notation)
140
+ format.
141
+ email: contact@cyril.email
128
142
  executables: []
129
143
  extensions: []
130
144
  extra_rdoc_files: []
131
145
  files:
132
- - ".DS_Store"
133
- - ".gitignore"
134
- - ".rspec"
135
- - ".rubocop.yml"
136
- - ".rubocop_todo.yml"
137
- - ".ruby-version"
138
- - ".travis.yml"
139
- - CODE_OF_CONDUCT.md
140
- - Gemfile
141
- - Gemfile.lock
142
- - LICENSE.txt
146
+ - LICENSE.md
143
147
  - README.md
144
- - Rakefile
145
- - VERSION.semver
146
- - bin/console
147
- - bin/setup
148
148
  - lib/portable_move_notation.rb
149
- - lib/portable_move_notation/action/dump.rb
150
- - lib/portable_move_notation/action/load.rb
151
- - lib/portable_move_notation/dump.rb
152
- - lib/portable_move_notation/load.rb
153
- - portable_move_notation.gemspec
154
- homepage: https://github.com/sashite/portable_move_notation.rb
149
+ - lib/portable_move_notation/dumper.rb
150
+ - lib/portable_move_notation/move.rb
151
+ - lib/portable_move_notation/parser.rb
152
+ homepage: https://developer.sashite.com/specs/portable-move-notation
155
153
  licenses:
156
154
  - MIT
157
- metadata: {}
155
+ metadata:
156
+ bug_tracker_uri: https://github.com/sashite/pmn.rb/issues
157
+ documentation_uri: https://rubydoc.info/gems/portable_move_notation/index
158
+ source_code_uri: https://github.com/sashite/pmn.rb
158
159
  post_install_message:
159
160
  rdoc_options: []
160
161
  require_paths:
@@ -170,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
171
  - !ruby/object:Gem::Version
171
172
  version: '0'
172
173
  requirements: []
173
- rubygems_version: 3.0.3
174
+ rubygems_version: 3.1.2
174
175
  signing_key:
175
176
  specification_version: 4
176
177
  summary: Data serialization in PMN format.
data/.DS_Store DELETED
Binary file
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
@@ -1 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
@@ -1,41 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2019-08-05 16:17:14 +0200 using RuboCop version 0.74.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 1
10
- Metrics/AbcSize:
11
- Max: 18
12
-
13
- # Offense count: 1
14
- Metrics/CyclomaticComplexity:
15
- Max: 8
16
-
17
- # Offense count: 1
18
- # Configuration parameters: CountComments, ExcludedMethods.
19
- Metrics/MethodLength:
20
- Max: 12
21
-
22
- # Offense count: 1
23
- Metrics/PerceivedComplexity:
24
- Max: 8
25
-
26
- # Offense count: 4
27
- Style/Documentation:
28
- Exclude:
29
- - 'spec/**/*'
30
- - 'test/**/*'
31
- - 'lib/portable_move_notation/action/dump.rb'
32
- - 'lib/portable_move_notation/action/load.rb'
33
- - 'lib/portable_move_notation/dump.rb'
34
- - 'lib/portable_move_notation/load.rb'
35
-
36
- # Offense count: 12
37
- # Cop supports --auto-correct.
38
- # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
39
- # URISchemes: http, https
40
- Metrics/LineLength:
41
- Max: 490
@@ -1 +0,0 @@
1
- 2.6.3
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.1
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at contact@cyril.email. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- ruby '2.6.3'
6
-
7
- gemspec
@@ -1,56 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- portable_move_notation (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.0)
10
- awesome_print (1.8.0)
11
- byebug (11.0.1)
12
- docile (1.3.2)
13
- jaro_winkler (1.5.3)
14
- json (2.2.0)
15
- parallel (1.17.0)
16
- parser (2.6.3.0)
17
- ast (~> 2.4.0)
18
- rainbow (3.0.0)
19
- rake (12.3.3)
20
- rubocop (0.74.0)
21
- jaro_winkler (~> 1.5.1)
22
- parallel (~> 1.10)
23
- parser (>= 2.6)
24
- rainbow (>= 2.2.2, < 4.0)
25
- ruby-progressbar (~> 1.7)
26
- unicode-display_width (>= 1.4.0, < 1.7)
27
- rubocop-performance (1.4.1)
28
- rubocop (>= 0.71.0)
29
- ruby-progressbar (1.10.1)
30
- simplecov (0.17.0)
31
- docile (~> 1.1)
32
- json (>= 1.8, < 3)
33
- simplecov-html (~> 0.10.0)
34
- simplecov-html (0.10.2)
35
- unicode-display_width (1.6.0)
36
- yard (0.9.20)
37
-
38
- PLATFORMS
39
- ruby
40
-
41
- DEPENDENCIES
42
- awesome_print
43
- bundler (~> 2.0)
44
- byebug
45
- portable_move_notation!
46
- rake (~> 12.3)
47
- rubocop (~> 0.72)
48
- rubocop-performance (~> 1.4)
49
- simplecov (~> 0.17)
50
- yard (~> 0.9)
51
-
52
- RUBY VERSION
53
- ruby 2.6.3p62
54
-
55
- BUNDLED WITH
56
- 2.0.1
data/Rakefile DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rake/testtask'
5
- require 'rubocop/rake_task'
6
-
7
- require 'byebug'
8
-
9
- RuboCop::RakeTask.new do |task|
10
- task.requires << 'rubocop-performance'
11
- end
12
-
13
- Rake::TestTask.new do |t|
14
- t.pattern = 'test/**/*.rb'
15
- t.verbose = true
16
- t.warning = true
17
- end
18
-
19
- namespace :test do
20
- task :coverage do
21
- ENV['COVERAGE'] = 'true'
22
- Rake::Task['test'].invoke
23
- end
24
- end
25
-
26
- task(:doc_stats) { ruby '-S yard stats' }
27
- task default: %i[test doc_stats rubocop]
28
-
29
- Dir.glob(File.join('tasks', '**', '*.rake')).each { |r| import(r) }
@@ -1 +0,0 @@
1
- 0.1.0
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'portable_move_notation'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require 'pry'
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -euo pipefail
4
- IFS=$'\n\t'
5
- set -vx
6
-
7
- bundle install
8
-
9
- # Do any other automated setup that you need to do here
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PortableMoveNotation
4
- module Action
5
- class Dump
6
- def self.call(*unserialized_actions)
7
- unserialized_actions.map { |params| new(*params).call }.join(';')
8
- end
9
-
10
- attr_reader :src_square, :dst_square, :piece_name, :piece_hand
11
-
12
- def initialize(src_square, dst_square, piece_name, piece_hand)
13
- unless src_square.nil?
14
- raise src_square.inspect unless src_square.is_a?(Integer)
15
- end
16
-
17
- raise dst_square.inspect unless dst_square.is_a?(Integer)
18
- raise piece_name.inspect unless piece_name.is_a?(String)
19
-
20
- unless piece_hand.nil?
21
- raise piece_hand.inspect unless piece_hand.is_a?(String)
22
- end
23
-
24
- @src_square = (src_square.nil? ? '*' : src_square)
25
- @dst_square = dst_square
26
- @piece_name = piece_name
27
- @piece_hand = piece_hand
28
- end
29
-
30
- def call
31
- arr = if piece_hand.nil?
32
- [src_square, dst_square, piece_name]
33
- else
34
- [src_square, dst_square, piece_name, piece_hand]
35
- end
36
-
37
- arr.join(',')
38
- end
39
- end
40
- end
41
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PortableMoveNotation
4
- module Action
5
- class Load
6
- def self.call(serialized_actions)
7
- serialized_actions.split(';').map do |serialized_action|
8
- new(serialized_action).call
9
- end
10
- end
11
-
12
- attr_reader :serialized_action
13
-
14
- def initialize(serialized_action)
15
- @serialized_action = serialized_action
16
- end
17
-
18
- def call
19
- action_args = serialized_action.split(',')
20
-
21
- src_square = action_args.fetch(0)
22
- src_square = src_square.eql?('*') ? nil : src_square.to_i
23
- dst_square = action_args.fetch(1).to_i
24
- piece_name = action_args.fetch(2)
25
- piece_hand = action_args.fetch(3, nil)
26
-
27
- [src_square, dst_square, piece_name, piece_hand]
28
- end
29
- end
30
- end
31
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PortableMoveNotation
4
- class Dump
5
- def self.call(*unserialized_moves)
6
- unserialized_moves.map { |actions| Action::Dump.call(*actions) }.join('.')
7
- end
8
- end
9
- end
10
-
11
- require_relative 'action/dump'
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module PortableMoveNotation
4
- class Load
5
- def self.call(serialized_moves)
6
- serialized_moves.split('.').map do |serialized_actions|
7
- Action::Load.call(serialized_actions)
8
- end
9
- end
10
- end
11
- end
12
-
13
- require_relative 'action/load'
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'portable_move_notation'
5
- spec.version = File.read('VERSION.semver')
6
- spec.authors = ['Cyril Kato']
7
- spec.email = ['contact@cyril.email']
8
- spec.description = 'A Ruby interface for data serialization in PMN format.'
9
- spec.summary = 'Data serialization in PMN format.'
10
- spec.homepage = 'https://github.com/sashite/portable_move_notation.rb'
11
- spec.license = 'MIT'
12
-
13
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
14
- f.match(%r{^(test)/})
15
- end
16
- spec.bindir = 'exe'
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
- spec.require_paths = ['lib']
19
-
20
- spec.add_development_dependency 'awesome_print'
21
- spec.add_development_dependency 'bundler', '~> 2.0'
22
- spec.add_development_dependency 'byebug'
23
- spec.add_development_dependency 'rake', '~> 12.3'
24
- spec.add_development_dependency 'rubocop', '~> 0.72'
25
- spec.add_development_dependency 'rubocop-performance', '~> 1.4'
26
- spec.add_development_dependency 'simplecov', '~> 0.17'
27
- spec.add_development_dependency 'yard', '~> 0.9'
28
- end