sashite-pan 0.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.md +1 -1
- data/README.md +73 -34
- data/lib/sashite-pan.rb +6 -1
- data/lib/sashite/pan.rb +10 -23
- data/lib/sashite/pan/action.rb +24 -0
- data/lib/sashite/pan/dumper.rb +36 -0
- data/lib/sashite/pan/parser.rb +30 -0
- metadata +132 -57
- data/.gitignore +0 -22
- data/.ruby-version +0 -1
- data/.travis.yml +0 -3
- data/Gemfile +0 -2
- data/Rakefile +0 -7
- data/VERSION.semver +0 -1
- data/lib/sashite/pan/error/not_implemented_verb_error.rb +0 -6
- data/lib/sashite/pan/error/same_square_error.rb +0 -6
- data/lib/sashite/pan/movement.rb +0 -28
- data/lib/sashite/pan/movement/capture.rb +0 -8
- data/lib/sashite/pan/movement/shift.rb +0 -8
- data/lib/sashite/pan/set_actor.rb +0 -27
- data/lib/sashite/pan/set_actor/drop.rb +0 -8
- data/lib/sashite/pan/set_actor/promote.rb +0 -8
- data/sashite-pan.gemspec +0 -19
- data/test/_test_helper.rb +0 -2
- data/test/test_capture.rb +0 -45
- data/test/test_drop.rb +0 -41
- data/test/test_pan.rb +0 -9
- data/test/test_promote.rb +0 -41
- data/test/test_shift.rb +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 12680869115791fc6fe8332162cbeaa71174b8ba5c5d74ebb531a805355dae1b
|
4
|
+
data.tar.gz: 1147d462de504b726ec26337bf8bfa69b28a8d3e195dbf6b2922b9b3ccaa9cf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bcb5c10788c3ba49269612062c6eea16251f372a176efd8c390fbe2e7967562bb4c83a27f7f70dd4f5af4af8f3a9ee33695f5d2a1394d105dff00e65043b45d
|
7
|
+
data.tar.gz: 0afbe377cfe6b68a5748f74221ef4e6084c55e0439ae6d7234e6864d5403e65a3b2d19f1c5f6579869a795c994c1ccc3f8b1ef0c8bc5ed2df8734318817c0c9a
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,63 +1,102 @@
|
|
1
|
-
#
|
1
|
+
# Portable Action Notation
|
2
2
|
|
3
|
-
|
3
|
+
[![Version](https://img.shields.io/github/v/tag/sashite/pan.rb?label=Version&logo=github)](https://github.com/sashite/pan.rb/releases)
|
4
|
+
[![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/sashite/pan.rb/main)
|
5
|
+
[![CI](https://github.com/sashite/pan.rb/workflows/CI/badge.svg?branch=main)](https://github.com/sashite/pan.rb/actions?query=workflow%3Aci+branch%3Amain)
|
6
|
+
[![RuboCop](https://github.com/sashite/pan.rb/workflows/RuboCop/badge.svg?branch=main)](https://github.com/sashite/pan.rb/actions?query=workflow%3Arubocop+branch%3Amain)
|
7
|
+
[![License](https://img.shields.io/github/license/sashite/pan.rb?label=License&logo=github)](https://github.com/sashite/pan.rb/raw/main/LICENSE.md)
|
4
8
|
|
5
|
-
|
6
|
-
|
7
|
-
* [![Gem Version](https://badge.fury.io/rb/sashite-pan.svg)](//badge.fury.io/rb/sashite-pan)
|
8
|
-
* [![Build Status](https://secure.travis-ci.org/sashite/pan.rb.svg?branch=master)](//travis-ci.org/sashite/pan.rb?branch=master)
|
9
|
-
* [![Dependency Status](https://gemnasium.com/sashite/pan.rb.svg)](//gemnasium.com/sashite/pan.rb)
|
9
|
+
A Ruby interface for data serialization in [PAN](https://developer.sashite.com/specs/portable-action-notation) format.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
|
-
|
15
|
+
```ruby
|
16
|
+
gem "sashite-pan"
|
17
|
+
```
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
19
|
-
|
21
|
+
```sh
|
22
|
+
bundle
|
23
|
+
```
|
20
24
|
|
21
25
|
Or install it yourself as:
|
22
26
|
|
23
|
-
|
27
|
+
```sh
|
28
|
+
gem install sashite-pan
|
29
|
+
```
|
24
30
|
|
25
|
-
##
|
31
|
+
## Usage
|
26
32
|
|
27
|
-
|
33
|
+
Working with PAN can be very simple, for example:
|
28
34
|
|
29
35
|
```ruby
|
30
|
-
|
31
|
-
```
|
36
|
+
require "sashite/pan"
|
32
37
|
|
33
|
-
|
38
|
+
# Emit a PAN string
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
* `to_a`
|
40
|
+
actions = [
|
41
|
+
[52, 36, "♙"]
|
42
|
+
]
|
39
43
|
|
40
|
-
|
44
|
+
Sashite::PAN.dump(*actions) # => "52,36,♙"
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
# Parse a PAN string
|
47
|
+
|
48
|
+
Sashite::PAN.parse("52,36,♙") # => [[52, 36, "♙", nil]]
|
49
|
+
```
|
46
50
|
|
47
51
|
## Example
|
48
52
|
|
53
|
+
### Promoting a chess pawn into a knight
|
54
|
+
|
49
55
|
```ruby
|
50
|
-
|
56
|
+
Sashite::PAN.dump([12, 4, "♘"]) # => "12,4,♘"
|
57
|
+
Sashite::PAN.parse("12,4,♘") # => [[12, 4, "♘", nil]]
|
58
|
+
```
|
51
59
|
|
52
|
-
|
53
|
-
|
54
|
-
|
60
|
+
### Capturing a rook and promoting a shogi pawn
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
Sashite::PAN.dump([33, 24, "+P", "R"]) # => "33,24,+P,R"
|
64
|
+
Sashite::PAN.parse("33,24,+P,R") # => [[33, 24, "+P", "R"]]
|
55
65
|
```
|
56
66
|
|
57
|
-
|
67
|
+
### Dropping a shogi pawn
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
Sashite::PAN.dump([nil, 42, "P"]) # => "*,42,P"
|
71
|
+
Sashite::PAN.parse("*,42,P") # => [[nil, 42, "P", nil]]
|
72
|
+
```
|
73
|
+
|
74
|
+
***
|
75
|
+
|
76
|
+
In the context of a game with several possible actions per turn, like in
|
77
|
+
Western chess, more than one action could be consider like a move, and joined
|
78
|
+
thanks to the [`portable_move_notation`](https://rubygems.org/gems/portable_move_notation) gem.
|
79
|
+
|
80
|
+
### Black castles on king-side
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
Sashite::PAN.dump([60, 62, "♔"], [63, 61, "♖"]) # => "60,62,♔;63,61,♖"
|
84
|
+
Sashite::PAN.parse("60,62,♔;63,61,♖") # => [[60, 62, "♔", nil], [63, 61, "♖", nil]]
|
85
|
+
```
|
86
|
+
|
87
|
+
### Capturing a white chess pawn en passant
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
Sashite::PAN.dump([33, 32, "♟"], [32, 40, "♟"]) # => "33,32,♟;32,40,♟"
|
91
|
+
Sashite::PAN.parse("33,32,♟;32,40,♟") # => [[33, 32, "♟", nil], [32, 40, "♟", nil]]
|
92
|
+
```
|
93
|
+
|
94
|
+
## License
|
95
|
+
|
96
|
+
The code is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
97
|
+
|
98
|
+
## About Sashite
|
99
|
+
|
100
|
+
This [gem](https://rubygems.org/gems/sashite-pan) is maintained by [Sashite](https://sashite.com/).
|
58
101
|
|
59
|
-
|
60
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
-
5. Create new Pull Request
|
102
|
+
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!
|
data/lib/sashite-pan.rb
CHANGED
data/lib/sashite/pan.rb
CHANGED
@@ -1,30 +1,17 @@
|
|
1
|
-
|
2
|
-
require_relative 'pan/error/same_square_error'
|
3
|
-
require_relative 'pan/movement/capture'
|
4
|
-
require_relative 'pan/movement/shift'
|
5
|
-
require_relative 'pan/set_actor/drop'
|
6
|
-
require_relative 'pan/set_actor/promote'
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
3
|
module Sashite
|
4
|
+
# The PAN (Portable Action Notation) module
|
9
5
|
module PAN
|
10
|
-
def self.
|
11
|
-
|
12
|
-
|
13
|
-
when :capture
|
14
|
-
Capture.new arg1, arg2
|
15
|
-
|
16
|
-
when :drop
|
17
|
-
Drop.new arg1, arg2
|
18
|
-
|
19
|
-
when :promote
|
20
|
-
Promote.new arg1, arg2
|
21
|
-
|
22
|
-
when :shift
|
23
|
-
Shift.new arg1, arg2
|
6
|
+
def self.dump(*actions)
|
7
|
+
Dumper.call(*actions)
|
8
|
+
end
|
24
9
|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
10
|
+
def self.parse(string)
|
11
|
+
Parser.call(string)
|
28
12
|
end
|
29
13
|
end
|
30
14
|
end
|
15
|
+
|
16
|
+
require_relative "pan/dumper"
|
17
|
+
require_relative "pan/parser"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sashite
|
4
|
+
module PAN
|
5
|
+
# Action class
|
6
|
+
class Action
|
7
|
+
attr_reader :src_square, :dst_square, :piece_name, :piece_hand
|
8
|
+
|
9
|
+
private_class_method def self.separator
|
10
|
+
";"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def separator
|
16
|
+
","
|
17
|
+
end
|
18
|
+
|
19
|
+
def drop_char
|
20
|
+
"*"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "action"
|
4
|
+
|
5
|
+
module Sashite
|
6
|
+
module PAN
|
7
|
+
# Dumper class
|
8
|
+
class Dumper < Action
|
9
|
+
def self.call(*actions)
|
10
|
+
actions.map { |action_items| new(*action_items).call }
|
11
|
+
.join(separator)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(src_square, dst_square, piece_name, piece_hand = nil)
|
15
|
+
super()
|
16
|
+
|
17
|
+
@src_square = src_square.nil? ? drop_char : Integer(src_square)
|
18
|
+
@dst_square = Integer(dst_square)
|
19
|
+
@piece_name = piece_name.to_s
|
20
|
+
@piece_hand = piece_hand&.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def call
|
24
|
+
action_items.join(separator)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def action_items
|
30
|
+
return [src_square, dst_square, piece_name] if piece_hand.nil?
|
31
|
+
|
32
|
+
[src_square, dst_square, piece_name, piece_hand]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "action"
|
4
|
+
|
5
|
+
module Sashite
|
6
|
+
module PAN
|
7
|
+
# Parser class
|
8
|
+
class Parser < Action
|
9
|
+
def self.call(serialized_move)
|
10
|
+
serialized_move.split(separator)
|
11
|
+
.map { |serialized_action| new(serialized_action).call }
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(serialized_action)
|
15
|
+
super()
|
16
|
+
|
17
|
+
action_args = serialized_action.split(separator)
|
18
|
+
src_square = action_args.fetch(0)
|
19
|
+
@src_square = src_square.eql?(drop_char) ? nil : Integer(src_square)
|
20
|
+
@dst_square = Integer(action_args.fetch(1))
|
21
|
+
@piece_name = action_args.fetch(2)
|
22
|
+
@piece_hand = action_args.fetch(3, nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
def call
|
26
|
+
[src_square, dst_square, piece_name, piece_hand]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,95 +1,177 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sashite-pan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Cyril
|
8
|
-
autorequire:
|
7
|
+
- Cyril Kato
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: awesome_print
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: byebug
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
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: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-md
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-thread_safety
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: yard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
46
144
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
145
|
+
version: '0'
|
48
146
|
type: :development
|
49
147
|
prerelease: false
|
50
148
|
version_requirements: !ruby/object:Gem::Requirement
|
51
149
|
requirements:
|
52
|
-
- - "
|
150
|
+
- - ">="
|
53
151
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description: A
|
56
|
-
|
57
|
-
email:
|
58
|
-
- contact@cyril.io
|
152
|
+
version: '0'
|
153
|
+
description: A Ruby interface for data serialization in PAN (Portable Action Notation)
|
154
|
+
format.
|
155
|
+
email: contact@cyril.email
|
59
156
|
executables: []
|
60
157
|
extensions: []
|
61
158
|
extra_rdoc_files: []
|
62
159
|
files:
|
63
|
-
- ".gitignore"
|
64
|
-
- ".ruby-version"
|
65
|
-
- ".travis.yml"
|
66
|
-
- Gemfile
|
67
160
|
- LICENSE.md
|
68
161
|
- README.md
|
69
|
-
- Rakefile
|
70
|
-
- VERSION.semver
|
71
162
|
- lib/sashite-pan.rb
|
72
163
|
- lib/sashite/pan.rb
|
73
|
-
- lib/sashite/pan/
|
74
|
-
- lib/sashite/pan/
|
75
|
-
- lib/sashite/pan/
|
76
|
-
|
77
|
-
- lib/sashite/pan/movement/shift.rb
|
78
|
-
- lib/sashite/pan/set_actor.rb
|
79
|
-
- lib/sashite/pan/set_actor/drop.rb
|
80
|
-
- lib/sashite/pan/set_actor/promote.rb
|
81
|
-
- sashite-pan.gemspec
|
82
|
-
- test/_test_helper.rb
|
83
|
-
- test/test_capture.rb
|
84
|
-
- test/test_drop.rb
|
85
|
-
- test/test_pan.rb
|
86
|
-
- test/test_promote.rb
|
87
|
-
- test/test_shift.rb
|
88
|
-
homepage: https://github.com/sashite/pan.rb
|
164
|
+
- lib/sashite/pan/action.rb
|
165
|
+
- lib/sashite/pan/dumper.rb
|
166
|
+
- lib/sashite/pan/parser.rb
|
167
|
+
homepage: https://developer.sashite.com/specs/portable-action-notation
|
89
168
|
licenses:
|
90
169
|
- MIT
|
91
|
-
metadata:
|
92
|
-
|
170
|
+
metadata:
|
171
|
+
bug_tracker_uri: https://github.com/sashite/pan.rb/issues
|
172
|
+
documentation_uri: https://rubydoc.info/gems/sashite-pan/index
|
173
|
+
source_code_uri: https://github.com/sashite/pan.rb
|
174
|
+
post_install_message:
|
93
175
|
rdoc_options: []
|
94
176
|
require_paths:
|
95
177
|
- lib
|
@@ -97,22 +179,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
179
|
requirements:
|
98
180
|
- - ">="
|
99
181
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
182
|
+
version: 2.7.0
|
101
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
184
|
requirements:
|
103
185
|
- - ">="
|
104
186
|
- !ruby/object:Gem::Version
|
105
187
|
version: '0'
|
106
188
|
requirements: []
|
107
|
-
|
108
|
-
|
109
|
-
signing_key:
|
189
|
+
rubygems_version: 3.2.15
|
190
|
+
signing_key:
|
110
191
|
specification_version: 4
|
111
|
-
summary:
|
112
|
-
test_files:
|
113
|
-
- test/_test_helper.rb
|
114
|
-
- test/test_capture.rb
|
115
|
-
- test/test_drop.rb
|
116
|
-
- test/test_pan.rb
|
117
|
-
- test/test_promote.rb
|
118
|
-
- test/test_shift.rb
|
192
|
+
summary: Data serialization in PAN format.
|
193
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.1.2
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/VERSION.semver
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|
data/lib/sashite/pan/movement.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Sashite
|
2
|
-
module PAN
|
3
|
-
class Movement
|
4
|
-
attr_reader :src_square, :dst_square
|
5
|
-
|
6
|
-
def initialize src_square, dst_square
|
7
|
-
raise TypeError unless src_square.is_a? Fixnum
|
8
|
-
raise TypeError unless dst_square.is_a? Fixnum
|
9
|
-
raise SameSquareError if src_square == dst_square
|
10
|
-
|
11
|
-
@src_square = src_square
|
12
|
-
@dst_square = dst_square
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_a
|
16
|
-
[
|
17
|
-
verb,
|
18
|
-
@src_square,
|
19
|
-
@dst_square
|
20
|
-
]
|
21
|
-
end
|
22
|
-
|
23
|
-
def verb
|
24
|
-
self.class.name.split('::').last.downcase.to_sym
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Sashite
|
2
|
-
module PAN
|
3
|
-
class SetActor
|
4
|
-
attr_reader :actor, :square
|
5
|
-
|
6
|
-
def initialize square, actor
|
7
|
-
raise TypeError unless actor.is_a? Symbol
|
8
|
-
raise TypeError unless square.is_a? Fixnum
|
9
|
-
|
10
|
-
@actor = actor
|
11
|
-
@square = square
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_a
|
15
|
-
[
|
16
|
-
verb,
|
17
|
-
@square,
|
18
|
-
@actor
|
19
|
-
]
|
20
|
-
end
|
21
|
-
|
22
|
-
def verb
|
23
|
-
self.class.name.split('::').last.downcase.to_sym
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/sashite-pan.gemspec
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |spec|
|
2
|
-
spec.name = 'sashite-pan'
|
3
|
-
spec.version = File.read('VERSION.semver')
|
4
|
-
spec.authors = ['Cyril Wack']
|
5
|
-
spec.email = ['contact@cyril.io']
|
6
|
-
spec.summary = %q{Portable Action Notation (PAN) parser and emitter.}
|
7
|
-
spec.description = %q{A Portable Action Notation (PAN) parser and emitter, optimized for programmer happiness.}
|
8
|
-
spec.homepage = 'https://github.com/sashite/pan.rb'
|
9
|
-
spec.license = 'MIT'
|
10
|
-
|
11
|
-
spec.files = `git ls-files -z`.split("\x0")
|
12
|
-
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
13
|
-
spec.test_files = spec.files.grep(%r{^test/})
|
14
|
-
spec.require_paths = ['lib']
|
15
|
-
|
16
|
-
spec.add_development_dependency 'bundler', '~> 1.6'
|
17
|
-
spec.add_development_dependency 'minitest', '~> 5'
|
18
|
-
spec.add_development_dependency 'rake', '~> 10'
|
19
|
-
end
|
data/test/_test_helper.rb
DELETED
data/test/test_capture.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require_relative '_test_helper'
|
2
|
-
|
3
|
-
describe Sashite::PAN do
|
4
|
-
describe 'capture' do
|
5
|
-
describe 'errors' do
|
6
|
-
it 'raises a same square error' do
|
7
|
-
-> { Sashite::PAN::Capture.new 42, 42 }.must_raise Sashite::PAN::SameSquareError
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'raises a type error from the source square' do
|
11
|
-
-> { Sashite::PAN::Capture.new '42', 43 }.must_raise TypeError
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'raises a type error from the destination square' do
|
15
|
-
-> { Sashite::PAN::Capture.new 42, '43' }.must_raise TypeError
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'instances' do
|
20
|
-
before do
|
21
|
-
@action = Sashite::PAN.load :capture, 42, 43
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns the action' do
|
25
|
-
@action.to_a.must_equal [ :capture, 42, 43 ]
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns the action (once again)' do
|
29
|
-
@action.to_a.must_equal Sashite::PAN::Capture.new(42, 43).to_a
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns the verb of the action' do
|
33
|
-
@action.verb.must_equal :capture
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'returns the src_square of the action' do
|
37
|
-
@action.src_square.must_equal 42
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'returns the dst_square of the action' do
|
41
|
-
@action.dst_square.must_equal 43
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/test/test_drop.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require_relative '_test_helper'
|
2
|
-
|
3
|
-
describe Sashite::PAN do
|
4
|
-
describe 'drops' do
|
5
|
-
describe 'errors' do
|
6
|
-
it 'raises a type error from the actor' do
|
7
|
-
-> { Sashite::PAN.load :drop, 42, 'foobar' }.must_raise TypeError
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'raises a type error from the destination square' do
|
11
|
-
-> { Sashite::PAN.load :drop, '42', :foobar }.must_raise TypeError
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'instances' do
|
16
|
-
before do
|
17
|
-
@action = Sashite::PAN.load :drop, 42, :foobar
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns the action' do
|
21
|
-
@action.to_a.must_equal [ :drop, 42, :foobar ]
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns the action (once again)' do
|
25
|
-
@action.to_a.must_equal Sashite::PAN::Drop.new(42, :foobar).to_a
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns the verb of the action' do
|
29
|
-
@action.verb.must_equal :drop
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns the actor of the action' do
|
33
|
-
@action.actor.must_equal :foobar
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'returns the square of the action' do
|
37
|
-
@action.square.must_equal 42
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/test/test_pan.rb
DELETED
data/test/test_promote.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require_relative '_test_helper'
|
2
|
-
|
3
|
-
describe Sashite::PAN do
|
4
|
-
describe 'promotion' do
|
5
|
-
describe 'errors' do
|
6
|
-
it 'raises a type error from the source square' do
|
7
|
-
-> { Sashite::PAN.load :promote, '42', :foobar }.must_raise TypeError
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'raises a type error from the actor' do
|
11
|
-
-> { Sashite::PAN.load :promote, 42, 'foobar' }.must_raise TypeError
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'instances' do
|
16
|
-
before do
|
17
|
-
@action = Sashite::PAN.load :promote, 42, :foobar
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns the action' do
|
21
|
-
@action.to_a.must_equal [ :promote, 42, :foobar ]
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns the action (once again)' do
|
25
|
-
@action.to_a.must_equal Sashite::PAN::Promote.new(42, :foobar).to_a
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns the verb of the action' do
|
29
|
-
@action.verb.must_equal :promote
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns the square of the action' do
|
33
|
-
@action.square.must_equal 42
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'returns the actor of the action' do
|
37
|
-
@action.actor.must_equal :foobar
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/test/test_shift.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require_relative '_test_helper'
|
2
|
-
|
3
|
-
describe Sashite::PAN do
|
4
|
-
describe 'shift' do
|
5
|
-
describe 'errors' do
|
6
|
-
it 'raises a same square error' do
|
7
|
-
-> { Sashite::PAN::Shift.new 42, 42 }.must_raise Sashite::PAN::SameSquareError
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'raises a type error from the source square' do
|
11
|
-
-> { Sashite::PAN::Shift.new '42', 43 }.must_raise TypeError
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'raises a type error from the destination square' do
|
15
|
-
-> { Sashite::PAN::Shift.new 42, '43' }.must_raise TypeError
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'instances' do
|
20
|
-
before do
|
21
|
-
@action = Sashite::PAN.load :shift, 42, 43
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns the action' do
|
25
|
-
@action.to_a.must_equal [ :shift, 42, 43 ]
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns the action (once again)' do
|
29
|
-
@action.to_a.must_equal Sashite::PAN::Shift.new(42, 43).to_a
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'returns the verb of the action' do
|
33
|
-
@action.verb.must_equal :shift
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'returns the src_square of the action' do
|
37
|
-
@action.src_square.must_equal 42
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'returns the dst_square of the action' do
|
41
|
-
@action.dst_square.must_equal 43
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|