sashite-ggn 0.0.1 → 0.1.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 +523 -521
- data/VERSION.semver +1 -1
- data/lib/sashite/ggn.rb +3 -2
- data/lib/sashite/ggn/ability.rb +11 -19
- data/lib/sashite/ggn/actor.rb +5 -13
- data/lib/sashite/ggn/ally.rb +6 -14
- data/lib/sashite/ggn/area.rb +6 -14
- data/lib/sashite/ggn/attacked.rb +6 -14
- data/lib/sashite/ggn/boolean.rb +6 -14
- data/lib/sashite/ggn/digit.rb +6 -14
- data/lib/sashite/ggn/digit_excluding_zero.rb +6 -14
- data/lib/sashite/ggn/direction.rb +6 -14
- data/lib/sashite/ggn/gameplay.rb +8 -28
- data/lib/sashite/ggn/gameplay_into_base64.rb +7 -14
- data/lib/sashite/ggn/integer.rb +6 -14
- data/lib/sashite/ggn/last_moved_actor.rb +6 -14
- data/lib/sashite/ggn/maximum_magnitude.rb +6 -14
- data/lib/sashite/ggn/name.rb +6 -14
- data/lib/sashite/ggn/negative_integer.rb +6 -14
- data/lib/sashite/ggn/null.rb +7 -9
- data/lib/sashite/ggn/object.rb +11 -19
- data/lib/sashite/ggn/occupied.rb +12 -20
- data/lib/sashite/ggn/pattern.rb +7 -16
- data/lib/sashite/ggn/previous_moves_counter.rb +6 -14
- data/lib/sashite/ggn/promotable_into_actors.rb +8 -17
- data/lib/sashite/ggn/required.rb +6 -14
- data/lib/sashite/ggn/self.rb +7 -9
- data/lib/sashite/ggn/square.rb +11 -19
- data/lib/sashite/ggn/state.rb +9 -17
- data/lib/sashite/ggn/subject.rb +11 -19
- data/lib/sashite/ggn/unsigned_integer.rb +6 -14
- data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +5 -13
- data/lib/sashite/ggn/verb.rb +15 -24
- data/lib/sashite/ggn/zero.rb +7 -9
- data/sashite-ggn.gemspec +2 -4
- data/test/test_ggn.rb +501 -495
- data/test/test_ggn_ability.rb +10 -10
- data/test/test_ggn_actor.rb +516 -536
- data/test/test_ggn_ally.rb +13 -29
- data/test/test_ggn_area.rb +9 -67
- data/test/test_ggn_attacked.rb +13 -29
- data/test/test_ggn_boolean.rb +10 -26
- data/test/test_ggn_digit.rb +10 -10
- data/test/test_ggn_digit_excluding_zero.rb +10 -11
- data/test/test_ggn_direction.rb +10 -10
- data/test/test_ggn_gameplay.rb +22 -38
- data/test/test_ggn_gameplay_into_base64.rb +511 -501
- data/test/test_ggn_integer.rb +19 -21
- data/test/test_ggn_last_moved_actor.rb +13 -29
- data/test/test_ggn_maximum_magnitude.rb +18 -16
- data/test/test_ggn_name.rb +9 -39
- data/test/test_ggn_negative_integer.rb +10 -10
- data/test/test_ggn_null.rb +10 -10
- data/test/test_ggn_object.rb +22 -24
- data/test/test_ggn_occupied.rb +40 -64
- data/test/test_ggn_pattern.rb +12 -10
- data/test/test_ggn_previous_moves_counter.rb +18 -20
- data/test/test_ggn_promotable_into_actors.rb +529 -549
- data/test/test_ggn_required.rb +10 -26
- data/test/test_ggn_self.rb +10 -10
- data/test/test_ggn_square.rb +14 -16
- data/test/test_ggn_state.rb +15 -19
- data/test/test_ggn_subject.rb +17 -19
- data/test/test_ggn_unsigned_integer.rb +30 -12
- data/test/test_ggn_unsigned_integer_excluding_zero.rb +14 -10
- data/test/test_ggn_verb.rb +16 -15
- data/test/test_ggn_zero.rb +10 -10
- metadata +4 -18
data/test/test_ggn_integer.rb
CHANGED
@@ -1,40 +1,38 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::Integer do
|
4
|
-
|
5
|
-
describe 'negative' do
|
6
|
-
before do
|
7
|
-
@integer = Sashite::GGN::Integer.new('-42')
|
8
|
-
end
|
4
|
+
subject { Sashite::GGN::Integer }
|
9
5
|
|
10
|
-
|
11
|
-
|
6
|
+
describe '.load' do
|
7
|
+
describe 'negative integer' do
|
8
|
+
before do
|
9
|
+
@ggn_obj = '-42'
|
12
10
|
end
|
13
11
|
|
14
|
-
it '
|
15
|
-
@
|
12
|
+
it 'loads a document from the current io stream' do
|
13
|
+
subject.load(@ggn_obj).must_equal -42
|
16
14
|
end
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
describe 'errors' do
|
17
|
+
it 'raises with the opposite of zero' do
|
18
|
+
-> { subject.load '-0' }.must_raise ArgumentError
|
19
|
+
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe 'unsigned' do
|
23
|
+
describe 'unsigned integer' do
|
24
24
|
before do
|
25
|
-
@
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns the GGN as a JSON' do
|
29
|
-
@integer.as_json.must_equal 42
|
25
|
+
@ggn_obj = '42'
|
30
26
|
end
|
31
27
|
|
32
|
-
it '
|
33
|
-
@
|
28
|
+
it 'loads a document from the current io stream' do
|
29
|
+
subject.load(@ggn_obj).must_equal 42
|
34
30
|
end
|
35
31
|
|
36
|
-
|
37
|
-
|
32
|
+
describe 'errors' do
|
33
|
+
it 'raises with an integer beginning by zero' do
|
34
|
+
-> { subject.load '04' }.must_raise ArgumentError
|
35
|
+
end
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
@@ -1,51 +1,35 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::LastMovedActor do
|
4
|
-
|
5
|
-
describe 'false' do
|
6
|
-
before do
|
7
|
-
@last_moved_actor = Sashite::GGN::LastMovedActor.new('f')
|
8
|
-
end
|
4
|
+
subject { Sashite::GGN::LastMovedActor }
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'returns the GGN as a string' do
|
15
|
-
@last_moved_actor.to_s.must_equal 'f'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'true' do
|
6
|
+
describe '.load' do
|
7
|
+
describe 'boolean' do
|
20
8
|
before do
|
21
|
-
@
|
9
|
+
@ggn_obj = 't'
|
22
10
|
end
|
23
11
|
|
24
|
-
it '
|
25
|
-
@
|
12
|
+
it 'loads a document from the current io stream' do
|
13
|
+
subject.load(@ggn_obj).must_equal true
|
26
14
|
end
|
27
15
|
|
28
|
-
it '
|
29
|
-
|
16
|
+
it 'raises an error' do
|
17
|
+
-> { subject.load 'true' }.must_raise ArgumentError
|
30
18
|
end
|
31
19
|
end
|
32
20
|
|
33
21
|
describe 'null' do
|
34
22
|
before do
|
35
|
-
@
|
23
|
+
@ggn_obj = '_'
|
36
24
|
end
|
37
25
|
|
38
|
-
it '
|
39
|
-
@
|
26
|
+
it 'loads a document from the current io stream' do
|
27
|
+
subject.load(@ggn_obj).must_equal nil
|
40
28
|
end
|
41
29
|
|
42
|
-
it '
|
43
|
-
|
30
|
+
it 'raises an error' do
|
31
|
+
-> { subject.load '' }.must_raise ArgumentError
|
44
32
|
end
|
45
33
|
end
|
46
34
|
end
|
47
|
-
|
48
|
-
it 'raises an error' do
|
49
|
-
-> { Sashite::GGN::LastMovedActor.new('foobar') }.must_raise ArgumentError
|
50
|
-
end
|
51
35
|
end
|
@@ -1,37 +1,39 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::MaximumMagnitude do
|
4
|
-
|
4
|
+
subject { Sashite::GGN::MaximumMagnitude }
|
5
|
+
|
6
|
+
describe '.load' do
|
5
7
|
describe 'null' do
|
6
8
|
before do
|
7
|
-
@
|
9
|
+
@ggn_obj = '_'
|
8
10
|
end
|
9
11
|
|
10
|
-
it '
|
11
|
-
@
|
12
|
+
it 'loads a document from the current io stream' do
|
13
|
+
subject.load(@ggn_obj).must_equal nil
|
12
14
|
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
describe 'errors' do
|
17
|
+
it 'raises an error' do
|
18
|
+
-> { subject.load 'foobar' }.must_raise ArgumentError
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
19
|
-
describe 'unsigned integer' do
|
23
|
+
describe 'an unsigned integer' do
|
20
24
|
before do
|
21
|
-
@
|
25
|
+
@ggn_obj = '42'
|
22
26
|
end
|
23
27
|
|
24
|
-
it '
|
25
|
-
@
|
28
|
+
it 'loads a document from the current io stream' do
|
29
|
+
subject.load(@ggn_obj).must_equal 42
|
26
30
|
end
|
27
31
|
|
28
|
-
|
29
|
-
|
32
|
+
describe 'errors' do
|
33
|
+
it 'raises an error' do
|
34
|
+
-> { subject.load '-4' }.must_raise ArgumentError
|
35
|
+
end
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
33
|
-
|
34
|
-
it 'raises an error' do
|
35
|
-
-> { Sashite::GGN::MaximumMagnitude.new('0') }.must_raise ArgumentError
|
36
|
-
end
|
37
39
|
end
|
data/test/test_ggn_name.rb
CHANGED
@@ -1,51 +1,21 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::Name do
|
4
|
-
|
5
|
-
describe 'capture' do
|
6
|
-
before do
|
7
|
-
@name = Sashite::GGN::Name.new('capture')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'returns the GGN as a JSON' do
|
11
|
-
@name.as_json.must_equal :capture
|
12
|
-
end
|
4
|
+
subject { Sashite::GGN::Name }
|
13
5
|
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
describe '.load' do
|
7
|
+
before do
|
8
|
+
@ggn_obj = 'capture'
|
17
9
|
end
|
18
10
|
|
19
|
-
|
20
|
-
|
21
|
-
@name = Sashite::GGN::Name.new('remove')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns the GGN as a JSON' do
|
25
|
-
@name.as_json.must_equal :remove
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'returns the GGN as a string' do
|
29
|
-
@name.to_s.must_equal 'remove'
|
30
|
-
end
|
11
|
+
it 'loads a document from the current io stream' do
|
12
|
+
subject.load(@ggn_obj).must_equal :capture
|
31
13
|
end
|
32
14
|
|
33
|
-
describe '
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'returns the GGN as a JSON' do
|
39
|
-
@name.as_json.must_equal :shift
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'returns the GGN as a string' do
|
43
|
-
@name.to_s.must_equal 'shift'
|
15
|
+
describe 'errors' do
|
16
|
+
it 'raises an error' do
|
17
|
+
-> { subject.load 'foobar' }.must_raise ArgumentError
|
44
18
|
end
|
45
19
|
end
|
46
20
|
end
|
47
|
-
|
48
|
-
it 'raises an error' do
|
49
|
-
-> { Sashite::GGN::Name.new('foobar') }.must_raise ArgumentError
|
50
|
-
end
|
51
21
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::NegativeInteger do
|
4
|
-
|
4
|
+
subject { Sashite::GGN::NegativeInteger }
|
5
|
+
|
6
|
+
describe '.load' do
|
5
7
|
before do
|
6
|
-
@
|
8
|
+
@ggn_obj = '-42'
|
7
9
|
end
|
8
10
|
|
9
|
-
it '
|
10
|
-
@
|
11
|
+
it 'loads a document from the current io stream' do
|
12
|
+
subject.load(@ggn_obj).must_equal -42
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
describe 'errors' do
|
16
|
+
it 'raises with an unsigned integer' do
|
17
|
+
-> { subject.load '4' }.must_raise ArgumentError
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
|
-
|
18
|
-
it 'raises an error' do
|
19
|
-
-> { Sashite::GGN::NegativeInteger.new('42') }.must_raise ArgumentError
|
20
|
-
end
|
21
21
|
end
|
data/test/test_ggn_null.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::Null do
|
4
|
-
|
4
|
+
subject { Sashite::GGN::Null }
|
5
|
+
|
6
|
+
describe '.load' do
|
5
7
|
before do
|
6
|
-
@
|
8
|
+
@ggn_obj = '_'
|
7
9
|
end
|
8
10
|
|
9
|
-
it '
|
10
|
-
@
|
11
|
+
it 'loads a document from the current io stream' do
|
12
|
+
subject.load(@ggn_obj).must_equal nil
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
describe 'errors' do
|
16
|
+
it 'raises without null' do
|
17
|
+
-> { subject.load '4' }.must_raise ArgumentError
|
18
|
+
end
|
15
19
|
end
|
16
20
|
end
|
17
|
-
|
18
|
-
it 'is false' do
|
19
|
-
Sashite::GGN::Null.valid?('foobar').must_equal false
|
20
|
-
end
|
21
21
|
end
|
data/test/test_ggn_object.rb
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::Object do
|
4
|
-
|
4
|
+
subject { Sashite::GGN::Object }
|
5
|
+
|
6
|
+
describe '.load' do
|
5
7
|
before do
|
6
|
-
@
|
8
|
+
@ggn_obj = '_@f+all~_@f+all%self'
|
7
9
|
end
|
8
10
|
|
9
|
-
it '
|
10
|
-
@
|
11
|
-
{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
}.hash
|
24
|
-
)
|
11
|
+
it 'loads a document from the current io stream' do
|
12
|
+
subject.load(@ggn_obj).hash.must_equal({
|
13
|
+
src_square: {
|
14
|
+
:"...attacked?" => nil,
|
15
|
+
:"...occupied!" => false,
|
16
|
+
area: :all
|
17
|
+
},
|
18
|
+
dst_square: {
|
19
|
+
:"...attacked?" => nil,
|
20
|
+
:"...occupied!" => false,
|
21
|
+
area: :all
|
22
|
+
},
|
23
|
+
promotable_into_actors: [:self]
|
24
|
+
}.hash)
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
describe 'errors' do
|
28
|
+
it 'raises without an object' do
|
29
|
+
-> { subject.load 'foo' }.must_raise ArgumentError
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
|
-
|
32
|
-
it 'raises an error' do
|
33
|
-
-> { Sashite::GGN::Object.new('foo') }.must_raise ArgumentError
|
34
|
-
end
|
35
33
|
end
|
data/test/test_ggn_occupied.rb
CHANGED
@@ -1,102 +1,78 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
3
|
describe Sashite::GGN::Occupied do
|
4
|
-
|
5
|
-
describe 'an ally actor' do
|
6
|
-
before do
|
7
|
-
@occupied = Sashite::GGN::Occupied.new('an_ally_actor')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'returns the GGN as a JSON' do
|
11
|
-
@occupied.as_json.must_equal :an_ally_actor
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'returns the GGN as a string' do
|
15
|
-
@occupied.to_s.must_equal 'an_ally_actor'
|
16
|
-
end
|
17
|
-
end
|
4
|
+
subject { Sashite::GGN::Occupied }
|
18
5
|
|
19
|
-
|
6
|
+
describe '.load' do
|
7
|
+
describe 'a relationship' do
|
20
8
|
before do
|
21
|
-
@
|
9
|
+
@ggn_obj = 'an_ally_actor'
|
22
10
|
end
|
23
11
|
|
24
|
-
it '
|
25
|
-
@
|
12
|
+
it 'loads a document from the current io stream' do
|
13
|
+
subject.load(@ggn_obj).must_equal :an_ally_actor
|
26
14
|
end
|
27
15
|
|
28
|
-
|
29
|
-
|
16
|
+
describe 'errors' do
|
17
|
+
it 'raises without a relationship' do
|
18
|
+
-> { subject.load 'foobar' }.must_raise ArgumentError
|
19
|
+
end
|
30
20
|
end
|
31
21
|
end
|
32
22
|
|
33
|
-
describe '
|
23
|
+
describe 'a boolean' do
|
34
24
|
before do
|
35
|
-
@
|
25
|
+
@ggn_obj = 'f'
|
36
26
|
end
|
37
27
|
|
38
|
-
it '
|
39
|
-
@
|
28
|
+
it 'loads a document from the current io stream' do
|
29
|
+
subject.load(@ggn_obj).must_equal false
|
40
30
|
end
|
41
31
|
|
42
|
-
|
43
|
-
|
32
|
+
describe 'errors' do
|
33
|
+
it 'raises without a boolean' do
|
34
|
+
-> { subject.load 'foobar' }.must_raise ArgumentError
|
35
|
+
end
|
44
36
|
end
|
45
37
|
end
|
46
38
|
|
47
|
-
describe '
|
48
|
-
before do
|
49
|
-
@occupied = Sashite::GGN::Occupied.new('t')
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'returns the GGN as a JSON' do
|
53
|
-
@occupied.as_json.must_equal true
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'returns the GGN as a string' do
|
57
|
-
@occupied.to_s.must_equal 't'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe 'false' do
|
39
|
+
describe 'null' do
|
62
40
|
before do
|
63
|
-
@
|
41
|
+
@ggn_obj = '_'
|
64
42
|
end
|
65
43
|
|
66
|
-
it '
|
67
|
-
@
|
44
|
+
it 'loads a document from the current io stream' do
|
45
|
+
subject.load(@ggn_obj).must_equal nil
|
68
46
|
end
|
69
47
|
|
70
|
-
|
71
|
-
|
48
|
+
describe 'errors' do
|
49
|
+
it 'raises without null' do
|
50
|
+
-> { subject.load '' }.must_raise ArgumentError
|
51
|
+
end
|
72
52
|
end
|
73
53
|
end
|
74
54
|
|
75
55
|
describe 'a subject' do
|
76
56
|
before do
|
77
|
-
@
|
57
|
+
@ggn_obj = 'f<self>_&_'
|
78
58
|
end
|
79
59
|
|
80
|
-
it '
|
81
|
-
@
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}.hash
|
90
|
-
)
|
60
|
+
it 'loads a document from the current io stream' do
|
61
|
+
subject.load(@ggn_obj).hash.must_equal({
|
62
|
+
:"...ally?" => false,
|
63
|
+
actor: :self,
|
64
|
+
state: {
|
65
|
+
:"...last_moved_actor?" => nil,
|
66
|
+
:"...previous_moves_counter" => nil
|
67
|
+
}
|
68
|
+
}.hash)
|
91
69
|
end
|
92
70
|
|
93
|
-
|
94
|
-
|
71
|
+
describe 'errors' do
|
72
|
+
it 'raises without a well-formed subject' do
|
73
|
+
-> { subject.load 'f<foo>_&_' }.must_raise ArgumentError
|
74
|
+
end
|
95
75
|
end
|
96
76
|
end
|
97
77
|
end
|
98
|
-
|
99
|
-
it 'raises an error' do
|
100
|
-
-> { Sashite::GGN::Occupied.new('foobar') }.must_raise ArgumentError
|
101
|
-
end
|
102
78
|
end
|