sashite-pan 0.2.0 → 1.0.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 +5 -5
- data/LICENSE.md +1 -1
- data/README.md +49 -33
- data/lib/sashite-pan.rb +6 -1
- data/lib/sashite/pan.rb +10 -23
- data/lib/sashite/pan/dumper.rb +44 -0
- data/lib/sashite/pan/parser.rb +32 -0
- metadata +99 -53
- 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: 5e063831fd8f910bd4ad5fd11d708be1bd0afc801b44d00e56934ac083996f34
|
4
|
+
data.tar.gz: f86d2d6b9fc44f15e9ef9cd5bb09518bea27f6e34644ad74fd11eabce05347aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aa2c4c4387486061b7d5ef452292fd75067775405b068b127efc27aaf703bb2cf9b1d817f662c8b2076ddd9bf9f14ed605421a3c0f9cd14146529574d308a72
|
7
|
+
data.tar.gz: 634cdd1a259a459d93b4c3a2eab9db96b30c220f5c320604c6b00dc729634ce69f697c448c0748d05c9d785802007efd6ac4c9db9a60c4008f6d236e1f404fb2
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# Portable Action Notation
|
2
2
|
|
3
|
-
Ruby
|
4
|
-
|
5
|
-
## Status
|
6
|
-
|
7
|
-
* [](//badge.fury.io/rb/sashite-pan)
|
8
|
-
* [](//travis-ci.org/sashite/pan.rb?branch=master)
|
9
|
-
* [](//gemnasium.com/sashite/pan.rb)
|
3
|
+
A Ruby interface for data serialization in [PAN](https://developer.sashite.com/specs/portable-action-notation) format.
|
10
4
|
|
11
5
|
## Installation
|
12
6
|
|
13
7
|
Add this line to your application's Gemfile:
|
14
8
|
|
15
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'sashite-pan'
|
11
|
+
```
|
16
12
|
|
17
13
|
And then execute:
|
18
14
|
|
@@ -22,42 +18,62 @@ Or install it yourself as:
|
|
22
18
|
|
23
19
|
$ gem install sashite-pan
|
24
20
|
|
25
|
-
##
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Working with PMN can be very simple, for example:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'sashite/pan'
|
27
|
+
```
|
28
|
+
|
29
|
+
### King's Pawn opening at chess
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Sashite::PAN.parse('52,36,♙') # => [[52, 36, '♙', nil]]
|
33
|
+
Sashite::PAN.dump([52, 36, '♙', nil]) # => '52,36,♙'
|
34
|
+
```
|
26
35
|
|
27
|
-
|
36
|
+
### Black castles on king-side
|
28
37
|
|
29
38
|
```ruby
|
30
|
-
Sashite::PAN.
|
39
|
+
Sashite::PAN.parse('60,62,♔;63,61,♖') # => [[60, 62, '♔', nil], [63, 61, '♖', nil]]
|
40
|
+
Sashite::PAN.dump([60, 62, '♔', nil], [63, 61, '♖', nil]) # => '60,62,♔;63,61,♖'
|
31
41
|
```
|
32
42
|
|
33
|
-
|
43
|
+
### Promoting a chess pawn into a knight
|
34
44
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
45
|
+
```ruby
|
46
|
+
Sashite::PAN.parse('12,4,♘') # => [[12, 4, '♘', nil]]
|
47
|
+
Sashite::PAN.dump([12, 4, '♘', nil]) # => '12,4,♘'
|
48
|
+
```
|
39
49
|
|
40
|
-
|
50
|
+
### Capturing a rook and promoting a shogi pawn
|
41
51
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
52
|
+
```ruby
|
53
|
+
Sashite::PAN.parse('33,24,+P,R') # => [[33, 24, '+P', 'R']]
|
54
|
+
Sashite::PAN.dump([33, 24, '+P', 'R']) # => '33,24,+P,R'
|
55
|
+
```
|
46
56
|
|
47
|
-
|
57
|
+
### Dropping a shogi pawn
|
48
58
|
|
49
59
|
```ruby
|
50
|
-
|
60
|
+
Sashite::PAN.parse('*,42,P') # => [[nil, 42, 'P', nil]]
|
61
|
+
Sashite::PAN.dump([nil, 42, 'P', nil]) # => '*,42,P'
|
62
|
+
```
|
51
63
|
|
52
|
-
|
53
|
-
|
54
|
-
|
64
|
+
### Capturing a white chess pawn _en passant_
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
Sashite::PAN.parse('33,32,♟;32,40,♟') # => [[33, 32, '♟', nil], [32, 40, '♟', nil]]
|
68
|
+
Sashite::PAN.dump([33, 32, '♟', nil], [32, 40, '♟', nil]) # => '33,32,♟;32,40,♟'
|
55
69
|
```
|
56
70
|
|
57
|
-
##
|
71
|
+
## License
|
72
|
+
|
73
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
74
|
+
|
75
|
+
## About Sashite
|
76
|
+
|
77
|
+
The `sashite-pan` gem is maintained by [Sashite](https://sashite.com/).
|
58
78
|
|
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
|
79
|
+
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(pan_string)
|
11
|
+
Parser.call(pan_string)
|
28
12
|
end
|
29
13
|
end
|
30
14
|
end
|
15
|
+
|
16
|
+
require_relative 'pan/dumper'
|
17
|
+
require_relative 'pan/parser'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sashite
|
4
|
+
module PAN
|
5
|
+
# Dumper class
|
6
|
+
class Dumper
|
7
|
+
def self.call(*unserialized_actions)
|
8
|
+
unserialized_actions.map { |params| new(*params).call }.join(';')
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :src_square, :dst_square, :piece_name, :piece_hand
|
12
|
+
|
13
|
+
def initialize(src_square, dst_square, piece_name, piece_hand)
|
14
|
+
unless src_square.nil?
|
15
|
+
raise src_square.inspect unless src_square.is_a?(Integer)
|
16
|
+
end
|
17
|
+
|
18
|
+
raise dst_square.inspect unless dst_square.is_a?(Integer)
|
19
|
+
raise piece_name.inspect unless piece_name.is_a?(String)
|
20
|
+
|
21
|
+
unless piece_hand.nil?
|
22
|
+
raise piece_hand.inspect unless piece_hand.is_a?(String)
|
23
|
+
end
|
24
|
+
|
25
|
+
@src_square = (src_square.nil? ? '*' : src_square)
|
26
|
+
@dst_square = dst_square
|
27
|
+
@piece_name = piece_name
|
28
|
+
@piece_hand = piece_hand
|
29
|
+
end
|
30
|
+
|
31
|
+
def call
|
32
|
+
action_items.join(',')
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def action_items
|
38
|
+
return [src_square, dst_square, piece_name] if piece_hand.nil?
|
39
|
+
|
40
|
+
[src_square, dst_square, piece_name, piece_hand]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sashite
|
4
|
+
module PAN
|
5
|
+
# Parser class
|
6
|
+
class Parser
|
7
|
+
def self.call(serialized_actions)
|
8
|
+
serialized_actions.split(';').map do |serialized_action|
|
9
|
+
new(serialized_action).call
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :serialized_action
|
14
|
+
|
15
|
+
def initialize(serialized_action)
|
16
|
+
@serialized_action = serialized_action
|
17
|
+
end
|
18
|
+
|
19
|
+
def call
|
20
|
+
action_args = serialized_action.split(',')
|
21
|
+
|
22
|
+
src_square = action_args.fetch(0)
|
23
|
+
src_square = src_square.eql?('*') ? nil : src_square.to_i
|
24
|
+
dst_square = action_args.fetch(1).to_i
|
25
|
+
piece_name = action_args.fetch(2)
|
26
|
+
piece_hand = action_args.fetch(3, nil)
|
27
|
+
|
28
|
+
[src_square, dst_square, piece_name, piece_hand]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,94 +1,147 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sashite-pan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Cyril
|
7
|
+
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-16 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-performance
|
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-thread_safety
|
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: simplecov
|
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: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
46
116
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
117
|
+
version: '0'
|
48
118
|
type: :development
|
49
119
|
prerelease: false
|
50
120
|
version_requirements: !ruby/object:Gem::Requirement
|
51
121
|
requirements:
|
52
|
-
- - "
|
122
|
+
- - ">="
|
53
123
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description: A
|
56
|
-
|
57
|
-
email:
|
58
|
-
- contact@cyril.io
|
124
|
+
version: '0'
|
125
|
+
description: A Ruby interface for data serialization in PAN (Portable Action Notation)
|
126
|
+
format.
|
127
|
+
email: contact@cyril.email
|
59
128
|
executables: []
|
60
129
|
extensions: []
|
61
130
|
extra_rdoc_files: []
|
62
131
|
files:
|
63
|
-
- ".gitignore"
|
64
|
-
- ".ruby-version"
|
65
|
-
- ".travis.yml"
|
66
|
-
- Gemfile
|
67
132
|
- LICENSE.md
|
68
133
|
- README.md
|
69
|
-
- Rakefile
|
70
|
-
- VERSION.semver
|
71
134
|
- lib/sashite-pan.rb
|
72
135
|
- lib/sashite/pan.rb
|
73
|
-
- lib/sashite/pan/
|
74
|
-
- lib/sashite/pan/
|
75
|
-
|
76
|
-
- lib/sashite/pan/movement/capture.rb
|
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
|
136
|
+
- lib/sashite/pan/dumper.rb
|
137
|
+
- lib/sashite/pan/parser.rb
|
138
|
+
homepage: https://developer.sashite.com/specs/portable-action-notation
|
89
139
|
licenses:
|
90
140
|
- MIT
|
91
|
-
metadata:
|
141
|
+
metadata:
|
142
|
+
bug_tracker_uri: https://github.com/sashite/pan.rb/issues
|
143
|
+
documentation_uri: https://rubydoc.info/gems/sashite-pan/index
|
144
|
+
source_code_uri: https://github.com/sashite/pan.rb
|
92
145
|
post_install_message:
|
93
146
|
rdoc_options: []
|
94
147
|
require_paths:
|
@@ -104,15 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
157
|
- !ruby/object:Gem::Version
|
105
158
|
version: '0'
|
106
159
|
requirements: []
|
107
|
-
|
108
|
-
rubygems_version: 2.2.2
|
160
|
+
rubygems_version: 3.1.2
|
109
161
|
signing_key:
|
110
162
|
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
|
163
|
+
summary: Data serialization in PAN format.
|
164
|
+
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
|