sashite-pan 0.0.1 → 1.1.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
- SHA1:
3
- metadata.gz: e7418ca5f0d9461164075f8a7362d0c70439fcbe
4
- data.tar.gz: 697a969bab18dc6cc1346db2e18492afc48da862
2
+ SHA256:
3
+ metadata.gz: 4294266795d470a55b2b4d52b1b07e006791ace8a41491473057f839112a8f7d
4
+ data.tar.gz: 30063832b6dba93e56ef2c4450581a3a4f24c1e13592b55576b7a391cbfd23fa
5
5
  SHA512:
6
- metadata.gz: 4b6f11ef92ded4ef26958029c6066e8b6ff76b032139f8d82c0e2b23a2112e39e2aafbe2b14bdde1cd47cea3745f8348deb35de207d2e53f0557f2bd23839fa3
7
- data.tar.gz: 4664588f59115312c34f7d37b4d77be1cedb9ba2a9c2639877e061c59781a99ddfd66a16d02b07046d7ed6e6d6e5004246632a61afb78c58c2f132a4fcc3c2b1
6
+ metadata.gz: 44ce213800f73cfd3094eb4f0d7f52090dae9a229c533827e2c2840cde605fefd2b515c8839277f85c3e4ee67b4d73245f026aa1810111e55cf739e4689c9ee1
7
+ data.tar.gz: 8b97bf4eaec6b839ebfb551bce73341033bcfa3702d6b6c01945355aab3d1857d661e48c5a4ea3783fac8540f4537189e0eb4dfb029812373314a473066275c0
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Cyril Wack
1
+ Copyright (c) 2014-2020 Cyril Kato
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,18 +1,14 @@
1
- # Sashite::PAN
1
+ # Portable Action Notation
2
2
 
3
- Ruby implementation of [PAN](http://sashite.wiki/Portable_Action_Notation) parser and emitter.
4
-
5
- ## Status
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)
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
- gem 'sashite-pan'
9
+ ```ruby
10
+ gem 'sashite-pan'
11
+ ```
16
12
 
17
13
  And then execute:
18
14
 
@@ -22,17 +18,61 @@ Or install it yourself as:
22
18
 
23
19
  $ gem install sashite-pan
24
20
 
25
- ## Example
21
+ ## Usage
22
+
23
+ Working with PAN can be very simple, for example:
24
+
25
+ ```ruby
26
+ require 'sashite/pan'
27
+
28
+ # Emit a PAN string
29
+
30
+ actions = [
31
+ [52, 36, '♙', nil]
32
+ ]
33
+
34
+ Sashite::PAN.dump(*actions) # => '52,36,♙'
35
+
36
+ # Parse a PAN string
37
+
38
+ Sashite::PAN.parse('52,36,♙') # => [[52, 36, '♙', nil]]
39
+ ```
40
+
41
+ ## Examples
42
+
43
+ ```ruby
44
+ # Black castles on king-side
45
+
46
+ Sashite::PAN.dump([60, 62, '♔', nil], [63, 61, '♖', nil]) # => '60,62,♔;63,61,♖'
47
+ Sashite::PAN.parse('60,62,♔;63,61,♖') # => [[60, 62, '♔', nil], [63, 61, '♖', nil]]
48
+
49
+ # Promoting a chess pawn into a knight
50
+
51
+ Sashite::PAN.dump([12, 4, '♘', nil]) # => '12,4,♘'
52
+ Sashite::PAN.parse('12,4,♘') # => [[12, 4, '♘', nil]]
53
+
54
+ # Capturing a rook and promoting a shogi pawn
55
+
56
+ Sashite::PAN.dump([33, 24, '+P', 'R']) # => '33,24,+P,R'
57
+ Sashite::PAN.parse('33,24,+P,R') # => [[33, 24, '+P', 'R']]
58
+
59
+ # Dropping a shogi pawn
60
+
61
+ Sashite::PAN.dump([nil, 42, 'P', nil]) # => '*,42,P'
62
+ Sashite::PAN.parse('*,42,P') # => [[nil, 42, 'P', nil]]
63
+
64
+ # Capturing a white chess pawn en passant
65
+
66
+ Sashite::PAN.dump([33, 32, '♟', nil], [32, 40, '♟', nil]) # => '33,32,♟;32,40,♟'
67
+ Sashite::PAN.parse('33,32,♟;32,40,♟') # => [[33, 32, '♟', nil], [32, 40, '♟', nil]]
68
+ ```
69
+
70
+ ## License
26
71
 
27
- require 'sashite-pan'
72
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
28
73
 
29
- action = Sashite::PAN.load :shift, 42, 43
30
- action.src_square # => 42
74
+ ## About Sashite
31
75
 
32
- ## Contributing
76
+ The `sashite-pan` gem is maintained by [Sashite](https://sashite.com/).
33
77
 
34
- 1. Fork it
35
- 2. Create your feature branch (`git checkout -b my-new-feature`)
36
- 3. Commit your changes (`git commit -am 'Add some feature'`)
37
- 4. Push to the branch (`git push origin my-new-feature`)
38
- 5. Create new Pull Request
78
+ 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!
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Sashite namespace
4
+ module Sashite; end
5
+
6
+ require_relative 'sashite/pan'
@@ -1,34 +1,17 @@
1
- require_relative 'pan/capture'
2
- require_relative 'pan/drop'
3
- require_relative 'pan/error/not_implemented_verb_error'
4
- require_relative 'pan/error/same_square_error'
5
- require_relative 'pan/promote'
6
- require_relative 'pan/remove'
7
- require_relative 'pan/shift'
1
+ # frozen_string_literal: true
8
2
 
9
3
  module Sashite
4
+ # The PAN (Portable Action Notation) module
10
5
  module PAN
11
- def self.load verb, arg1, arg2
12
- case verb
13
-
14
- when :capture
15
- Capture.new arg1, arg2
16
-
17
- when :drop
18
- Drop.new arg1, arg2
19
-
20
- when :promote
21
- Promote.new arg1, arg2
22
-
23
- when :remove
24
- Remove.new arg1, arg2
25
-
26
- when :shift
27
- Shift.new arg1, arg2
6
+ def self.dump(*actions)
7
+ Dumper.call(*actions)
8
+ end
28
9
 
29
- else
30
- raise NotImplementedVerbError
31
- end
10
+ def self.parse(pan_string)
11
+ Parser.call(pan_string)
32
12
  end
33
13
  end
34
14
  end
15
+
16
+ require_relative 'pan/dumper'
17
+ require_relative 'pan/parser'
@@ -0,0 +1,10 @@
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
+ end
9
+ end
10
+ end
@@ -0,0 +1,44 @@
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 }.join(';')
11
+ end
12
+
13
+ def initialize(src_square, dst_square, piece_name, piece_hand)
14
+ unless src_square.nil?
15
+ raise TypeError, src_square.inspect unless src_square.is_a?(Integer)
16
+ end
17
+
18
+ raise TypeError, dst_square.inspect unless dst_square.is_a?(Integer)
19
+ raise TypeError, piece_name.inspect unless piece_name.is_a?(String)
20
+
21
+ unless piece_hand.nil?
22
+ raise TypeError, 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,34 @@
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(pan_string)
10
+ pan_string.split(';').map do |serialized_action|
11
+ new(serialized_action).call
12
+ end
13
+ end
14
+
15
+ def initialize(serialized_action)
16
+ action_args = serialized_action.split(',')
17
+ src_square = action_args.fetch(0)
18
+ @src_square = src_square.eql?('*') ? nil : src_square.to_i
19
+ @dst_square = action_args.fetch(1).to_i
20
+ @piece_name = action_args.fetch(2)
21
+ @piece_hand = action_args.fetch(3, nil)
22
+ end
23
+
24
+ def call
25
+ [
26
+ src_square,
27
+ dst_square,
28
+ piece_name,
29
+ piece_hand
30
+ ]
31
+ end
32
+ end
33
+ end
34
+ end
metadata CHANGED
@@ -1,94 +1,148 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sashite-pan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Cyril Wack
7
+ - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-29 00:00:00.000000000 Z
11
+ date: 2020-06-19 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: '1.6'
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: '1.6'
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: minitest
42
+ name: byebug
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '5'
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: '5'
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: '10'
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: '10'
55
- description: A Portable Action Notation (PAN) parser and emitter, optimized for programmer
56
- happiness.
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
134
+ - lib/sashite-pan.rb
71
135
  - lib/sashite/pan.rb
72
- - lib/sashite/pan/capture.rb
73
- - lib/sashite/pan/drop.rb
74
- - lib/sashite/pan/error/not_implemented_verb_error.rb
75
- - lib/sashite/pan/error/same_square_error.rb
76
- - lib/sashite/pan/promote.rb
77
- - lib/sashite/pan/remove.rb
78
- - lib/sashite/pan/shift.rb
79
- - sashite-pan.gemspec
80
- - test/_test_helper.rb
81
- - test/test_capture.rb
82
- - test/test_drop.rb
83
- - test/test_movement.rb.rb
84
- - test/test_pan.rb
85
- - test/test_promote.rb
86
- - test/test_remove.rb
87
- - test/test_shift.rb
88
- homepage: https://github.com/sashite/pan.rb
136
+ - lib/sashite/pan/action.rb
137
+ - lib/sashite/pan/dumper.rb
138
+ - lib/sashite/pan/parser.rb
139
+ homepage: https://developer.sashite.com/specs/portable-action-notation
89
140
  licenses:
90
141
  - MIT
91
- metadata: {}
142
+ metadata:
143
+ bug_tracker_uri: https://github.com/sashite/pan.rb/issues
144
+ documentation_uri: https://rubydoc.info/gems/sashite-pan/index
145
+ source_code_uri: https://github.com/sashite/pan.rb
92
146
  post_install_message:
93
147
  rdoc_options: []
94
148
  require_paths:
@@ -104,17 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
158
  - !ruby/object:Gem::Version
105
159
  version: '0'
106
160
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.2.2
161
+ rubygems_version: 3.1.2
109
162
  signing_key:
110
163
  specification_version: 4
111
- summary: Portable Action Notation (PAN) parser and emitter.
112
- test_files:
113
- - test/_test_helper.rb
114
- - test/test_capture.rb
115
- - test/test_drop.rb
116
- - test/test_movement.rb.rb
117
- - test/test_pan.rb
118
- - test/test_promote.rb
119
- - test/test_remove.rb
120
- - test/test_shift.rb
164
+ summary: Data serialization in PAN format.
165
+ 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
@@ -1 +0,0 @@
1
- 2.1.2
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.2
data/Gemfile DELETED
@@ -1,2 +0,0 @@
1
- source 'https://rubygems.org'
2
- gemspec
data/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- end
6
-
7
- task(default: :test)
@@ -1 +0,0 @@
1
- 0.0.1
@@ -1,24 +0,0 @@
1
- module Sashite
2
- module PAN
3
- class Capture
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
- self.class.name.split('::').last.downcase.to_sym,
18
- @src_square,
19
- @dst_square
20
- ]
21
- end
22
- end
23
- end
24
- end
@@ -1,23 +0,0 @@
1
- module Sashite
2
- module PAN
3
- class Drop
4
- attr_reader :actor, :dst_square
5
-
6
- def initialize actor, dst_square
7
- raise TypeError unless actor.is_a? Symbol
8
- raise TypeError unless dst_square.is_a? Fixnum
9
-
10
- @actor = actor
11
- @dst_square = dst_square
12
- end
13
-
14
- def to_a
15
- [
16
- self.class.name.split('::').last.downcase.to_sym,
17
- @actor,
18
- @dst_square
19
- ]
20
- end
21
- end
22
- end
23
- end
@@ -1,6 +0,0 @@
1
- module Sashite
2
- module PAN
3
- class NotImplementedVerbError < ::StandardError
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Sashite
2
- module PAN
3
- class SameSquareError < ::StandardError
4
- end
5
- end
6
- end
@@ -1,23 +0,0 @@
1
- module Sashite
2
- module PAN
3
- class Promote
4
- attr_reader :src_square, :actor
5
-
6
- def initialize src_square, actor
7
- raise TypeError unless src_square.is_a? Fixnum
8
- raise TypeError unless actor.is_a? Symbol
9
-
10
- @src_square = src_square
11
- @actor = actor
12
- end
13
-
14
- def to_a
15
- [
16
- self.class.name.split('::').last.downcase.to_sym,
17
- @src_square,
18
- @actor
19
- ]
20
- end
21
- end
22
- end
23
- end
@@ -1,24 +0,0 @@
1
- module Sashite
2
- module PAN
3
- class Remove
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
- self.class.name.split('::').last.downcase.to_sym,
18
- @src_square,
19
- @dst_square
20
- ]
21
- end
22
- end
23
- end
24
- end
@@ -1,24 +0,0 @@
1
- module Sashite
2
- module PAN
3
- class Shift
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
- self.class.name.split('::').last.downcase.to_sym,
18
- @src_square,
19
- @dst_square
20
- ]
21
- end
22
- end
23
- end
24
- end
@@ -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
@@ -1,2 +0,0 @@
1
- require 'sashite/pan'
2
- require 'minitest/autorun'
@@ -1,41 +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 src_square of the action' do
33
- @action.src_square.must_equal 42
34
- end
35
-
36
- it 'returns the dst_square of the action' do
37
- @action.dst_square.must_equal 43
38
- end
39
- end
40
- end
41
- end
@@ -1,37 +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, 'foobar', 42 }.must_raise TypeError
8
- end
9
-
10
- it 'raises a type error from the destination square' do
11
- -> { Sashite::PAN.load :drop, :foobar, '42' }.must_raise TypeError
12
- end
13
- end
14
-
15
- describe 'instances' do
16
- before do
17
- @action = Sashite::PAN.load :drop, :foobar, 42
18
- end
19
-
20
- it 'returns the action' do
21
- @action.to_a.must_equal [ :drop, :foobar, 42 ]
22
- end
23
-
24
- it 'returns the action (once again)' do
25
- @action.to_a.must_equal Sashite::PAN::Drop.new(:foobar, 42).to_a
26
- end
27
-
28
- it 'returns the actor of the action' do
29
- @action.actor.must_equal :foobar
30
- end
31
-
32
- it 'returns the dst_square of the action' do
33
- @action.dst_square.must_equal 42
34
- end
35
- end
36
- end
37
- end
@@ -1,9 +0,0 @@
1
- require_relative '_test_helper'
2
-
3
- describe Sashite::PAN do
4
- describe 'errors' do
5
- it 'raises a not implemented method error' do
6
- -> { Sashite::PAN.load :foobar, 42, 43 }.must_raise Sashite::PAN::NotImplementedVerbError
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- require_relative '_test_helper'
2
-
3
- describe Sashite::PAN do
4
- describe 'errors' do
5
- it 'raises a not implemented method error' do
6
- -> { Sashite::PAN.load :foobar, 42, 43 }.must_raise Sashite::PAN::NotImplementedVerbError
7
- end
8
- end
9
- end
@@ -1,37 +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 src_square of the action' do
29
- @action.src_square.must_equal 42
30
- end
31
-
32
- it 'returns the actor of the action' do
33
- @action.actor.must_equal :foobar
34
- end
35
- end
36
- end
37
- end
@@ -1,41 +0,0 @@
1
- require_relative '_test_helper'
2
-
3
- describe Sashite::PAN do
4
- describe 'remove' do
5
- describe 'errors' do
6
- it 'raises a same square error' do
7
- -> { Sashite::PAN::Remove.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::Remove.new '42', 43 }.must_raise TypeError
12
- end
13
-
14
- it 'raises a type error from the destination square' do
15
- -> { Sashite::PAN::Remove.new 42, '43' }.must_raise TypeError
16
- end
17
- end
18
-
19
- describe 'instances' do
20
- before do
21
- @action = Sashite::PAN.load :remove, 42, 43
22
- end
23
-
24
- it 'returns the action' do
25
- @action.to_a.must_equal [ :remove, 42, 43 ]
26
- end
27
-
28
- it 'returns the action (once again)' do
29
- @action.to_a.must_equal Sashite::PAN::Remove.new(42, 43).to_a
30
- end
31
-
32
- it 'returns the src_square of the action' do
33
- @action.src_square.must_equal 42
34
- end
35
-
36
- it 'returns the dst_square of the action' do
37
- @action.dst_square.must_equal 43
38
- end
39
- end
40
- end
41
- end
@@ -1,41 +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 src_square of the action' do
33
- @action.src_square.must_equal 42
34
- end
35
-
36
- it 'returns the dst_square of the action' do
37
- @action.dst_square.must_equal 43
38
- end
39
- end
40
- end
41
- end