sashite-pan 0.1.0 → 0.2.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 +4 -4
- data/README.md +23 -0
- data/VERSION.semver +1 -1
- data/lib/sashite/pan.rb +4 -8
- data/lib/sashite/pan/{capture.rb → movement.rb} +6 -2
- data/lib/sashite/pan/movement/capture.rb +8 -0
- data/lib/sashite/pan/movement/shift.rb +8 -0
- data/lib/sashite/pan/set_actor.rb +27 -0
- data/lib/sashite/pan/set_actor/drop.rb +8 -0
- data/lib/sashite/pan/set_actor/promote.rb +8 -0
- data/test/test_capture.rb +4 -0
- data/test/test_drop.rb +6 -2
- data/test/test_promote.rb +6 -2
- data/test/test_shift.rb +4 -0
- metadata +7 -10
- data/lib/sashite/pan/drop.rb +0 -23
- data/lib/sashite/pan/promote.rb +0 -23
- data/lib/sashite/pan/remove.rb +0 -24
- data/lib/sashite/pan/shift.rb +0 -24
- data/test/test_movement.rb +0 -9
- data/test/test_remove.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0df5e40949504b396898aafaa9995e22ceffcc4
|
4
|
+
data.tar.gz: 21ea803ef8d8bedffe43c49f957ba953a4a906fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c31d786fe117f64ba500d4be7768cfee0019dfd7a65b7c7412f73ba685d07be1ba823b44d82bdf16224255935ede441805eed99b450a83ed5921db7753d08809
|
7
|
+
data.tar.gz: 7e74e5ddb41667b0cbfe3b54fe58fbdd556e9619012b1f3c6c988a55da1f6f96840273e0e2eabbef02c0c4e936a21eef58e8e1025dbabae8b4dca40031e69f88
|
data/README.md
CHANGED
@@ -22,6 +22,28 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
$ gem install sashite-pan
|
24
24
|
|
25
|
+
## API
|
26
|
+
|
27
|
+
Module method:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Sashite::PAN.load verb, arg1, arg2
|
31
|
+
```
|
32
|
+
|
33
|
+
Set actor's instance methods:
|
34
|
+
|
35
|
+
* `verb`
|
36
|
+
* `actor`
|
37
|
+
* `square`
|
38
|
+
* `to_a`
|
39
|
+
|
40
|
+
Movement's instance methods:
|
41
|
+
|
42
|
+
* `verb`
|
43
|
+
* `src_square`
|
44
|
+
* `dst_square`
|
45
|
+
* `to_a`
|
46
|
+
|
25
47
|
## Example
|
26
48
|
|
27
49
|
```ruby
|
@@ -29,6 +51,7 @@ require 'sashite-pan'
|
|
29
51
|
|
30
52
|
action = Sashite::PAN.load :shift, 42, 43
|
31
53
|
action.src_square # => 42
|
54
|
+
action.to_a # => [ :shift, 42, 43 ]
|
32
55
|
```
|
33
56
|
|
34
57
|
## Contributing
|
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/sashite/pan.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require_relative 'pan/capture'
|
2
|
-
require_relative 'pan/drop'
|
3
1
|
require_relative 'pan/error/not_implemented_verb_error'
|
4
2
|
require_relative 'pan/error/same_square_error'
|
5
|
-
require_relative 'pan/
|
6
|
-
require_relative 'pan/
|
7
|
-
require_relative 'pan/
|
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'
|
8
7
|
|
9
8
|
module Sashite
|
10
9
|
module PAN
|
@@ -20,9 +19,6 @@ module Sashite
|
|
20
19
|
when :promote
|
21
20
|
Promote.new arg1, arg2
|
22
21
|
|
23
|
-
when :remove
|
24
|
-
Remove.new arg1, arg2
|
25
|
-
|
26
22
|
when :shift
|
27
23
|
Shift.new arg1, arg2
|
28
24
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Sashite
|
2
2
|
module PAN
|
3
|
-
class
|
3
|
+
class Movement
|
4
4
|
attr_reader :src_square, :dst_square
|
5
5
|
|
6
6
|
def initialize src_square, dst_square
|
@@ -14,11 +14,15 @@ module Sashite
|
|
14
14
|
|
15
15
|
def to_a
|
16
16
|
[
|
17
|
-
|
17
|
+
verb,
|
18
18
|
@src_square,
|
19
19
|
@dst_square
|
20
20
|
]
|
21
21
|
end
|
22
|
+
|
23
|
+
def verb
|
24
|
+
self.class.name.split('::').last.downcase.to_sym
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -0,0 +1,27 @@
|
|
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/test/test_capture.rb
CHANGED
@@ -29,6 +29,10 @@ describe Sashite::PAN do
|
|
29
29
|
@action.to_a.must_equal Sashite::PAN::Capture.new(42, 43).to_a
|
30
30
|
end
|
31
31
|
|
32
|
+
it 'returns the verb of the action' do
|
33
|
+
@action.verb.must_equal :capture
|
34
|
+
end
|
35
|
+
|
32
36
|
it 'returns the src_square of the action' do
|
33
37
|
@action.src_square.must_equal 42
|
34
38
|
end
|
data/test/test_drop.rb
CHANGED
@@ -25,12 +25,16 @@ describe Sashite::PAN do
|
|
25
25
|
@action.to_a.must_equal Sashite::PAN::Drop.new(42, :foobar).to_a
|
26
26
|
end
|
27
27
|
|
28
|
+
it 'returns the verb of the action' do
|
29
|
+
@action.verb.must_equal :drop
|
30
|
+
end
|
31
|
+
|
28
32
|
it 'returns the actor of the action' do
|
29
33
|
@action.actor.must_equal :foobar
|
30
34
|
end
|
31
35
|
|
32
|
-
it 'returns the
|
33
|
-
@action.
|
36
|
+
it 'returns the square of the action' do
|
37
|
+
@action.square.must_equal 42
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
data/test/test_promote.rb
CHANGED
@@ -25,8 +25,12 @@ describe Sashite::PAN do
|
|
25
25
|
@action.to_a.must_equal Sashite::PAN::Promote.new(42, :foobar).to_a
|
26
26
|
end
|
27
27
|
|
28
|
-
it 'returns the
|
29
|
-
@action.
|
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
|
30
34
|
end
|
31
35
|
|
32
36
|
it 'returns the actor of the action' do
|
data/test/test_shift.rb
CHANGED
@@ -29,6 +29,10 @@ describe Sashite::PAN do
|
|
29
29
|
@action.to_a.must_equal Sashite::PAN::Shift.new(42, 43).to_a
|
30
30
|
end
|
31
31
|
|
32
|
+
it 'returns the verb of the action' do
|
33
|
+
@action.verb.must_equal :shift
|
34
|
+
end
|
35
|
+
|
32
36
|
it 'returns the src_square of the action' do
|
33
37
|
@action.src_square.must_equal 42
|
34
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sashite-pan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
@@ -70,21 +70,20 @@ files:
|
|
70
70
|
- VERSION.semver
|
71
71
|
- lib/sashite-pan.rb
|
72
72
|
- lib/sashite/pan.rb
|
73
|
-
- lib/sashite/pan/capture.rb
|
74
|
-
- lib/sashite/pan/drop.rb
|
75
73
|
- lib/sashite/pan/error/not_implemented_verb_error.rb
|
76
74
|
- lib/sashite/pan/error/same_square_error.rb
|
77
|
-
- lib/sashite/pan/
|
78
|
-
- lib/sashite/pan/
|
79
|
-
- lib/sashite/pan/shift.rb
|
75
|
+
- lib/sashite/pan/movement.rb
|
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
|
80
81
|
- sashite-pan.gemspec
|
81
82
|
- test/_test_helper.rb
|
82
83
|
- test/test_capture.rb
|
83
84
|
- test/test_drop.rb
|
84
|
-
- test/test_movement.rb
|
85
85
|
- test/test_pan.rb
|
86
86
|
- test/test_promote.rb
|
87
|
-
- test/test_remove.rb
|
88
87
|
- test/test_shift.rb
|
89
88
|
homepage: https://github.com/sashite/pan.rb
|
90
89
|
licenses:
|
@@ -114,8 +113,6 @@ test_files:
|
|
114
113
|
- test/_test_helper.rb
|
115
114
|
- test/test_capture.rb
|
116
115
|
- test/test_drop.rb
|
117
|
-
- test/test_movement.rb
|
118
116
|
- test/test_pan.rb
|
119
117
|
- test/test_promote.rb
|
120
|
-
- test/test_remove.rb
|
121
118
|
- test/test_shift.rb
|
data/lib/sashite/pan/drop.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Sashite
|
2
|
-
module PAN
|
3
|
-
class Drop
|
4
|
-
attr_reader :actor, :dst_square
|
5
|
-
|
6
|
-
def initialize dst_square, actor
|
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
|
-
@dst_square,
|
18
|
-
@actor
|
19
|
-
]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/sashite/pan/promote.rb
DELETED
@@ -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
|
data/lib/sashite/pan/remove.rb
DELETED
@@ -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
|
data/lib/sashite/pan/shift.rb
DELETED
@@ -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
|
data/test/test_movement.rb
DELETED
data/test/test_remove.rb
DELETED
@@ -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
|