sashite-ggn 0.0.1

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.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +3 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE.md +22 -0
  7. data/README.md +566 -0
  8. data/Rakefile +7 -0
  9. data/VERSION.semver +1 -0
  10. data/lib/sashite-ggn.rb +1 -0
  11. data/lib/sashite/ggn.rb +9 -0
  12. data/lib/sashite/ggn/ability.rb +37 -0
  13. data/lib/sashite/ggn/actor.rb +28 -0
  14. data/lib/sashite/ggn/ally.rb +28 -0
  15. data/lib/sashite/ggn/area.rb +25 -0
  16. data/lib/sashite/ggn/attacked.rb +28 -0
  17. data/lib/sashite/ggn/boolean.rb +25 -0
  18. data/lib/sashite/ggn/digit.rb +28 -0
  19. data/lib/sashite/ggn/digit_excluding_zero.rb +25 -0
  20. data/lib/sashite/ggn/direction.rb +27 -0
  21. data/lib/sashite/ggn/gameplay.rb +40 -0
  22. data/lib/sashite/ggn/gameplay_into_base64.rb +28 -0
  23. data/lib/sashite/ggn/integer.rb +28 -0
  24. data/lib/sashite/ggn/last_moved_actor.rb +28 -0
  25. data/lib/sashite/ggn/maximum_magnitude.rb +28 -0
  26. data/lib/sashite/ggn/name.rb +25 -0
  27. data/lib/sashite/ggn/negative_integer.rb +27 -0
  28. data/lib/sashite/ggn/null.rb +23 -0
  29. data/lib/sashite/ggn/object.rb +36 -0
  30. data/lib/sashite/ggn/occupied.rb +37 -0
  31. data/lib/sashite/ggn/pattern.rb +29 -0
  32. data/lib/sashite/ggn/previous_moves_counter.rb +28 -0
  33. data/lib/sashite/ggn/promotable_into_actors.rb +32 -0
  34. data/lib/sashite/ggn/required.rb +27 -0
  35. data/lib/sashite/ggn/self.rb +23 -0
  36. data/lib/sashite/ggn/square.rb +37 -0
  37. data/lib/sashite/ggn/state.rb +34 -0
  38. data/lib/sashite/ggn/subject.rb +37 -0
  39. data/lib/sashite/ggn/unsigned_integer.rb +28 -0
  40. data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +28 -0
  41. data/lib/sashite/ggn/verb.rb +42 -0
  42. data/lib/sashite/ggn/zero.rb +23 -0
  43. data/sashite-ggn.gemspec +21 -0
  44. data/test/_test_helper.rb +2 -0
  45. data/test/test_ggn.rb +546 -0
  46. data/test/test_ggn_ability.rb +51 -0
  47. data/test/test_ggn_actor.rb +591 -0
  48. data/test/test_ggn_ally.rb +51 -0
  49. data/test/test_ggn_area.rb +79 -0
  50. data/test/test_ggn_attacked.rb +51 -0
  51. data/test/test_ggn_boolean.rb +37 -0
  52. data/test/test_ggn_digit.rb +21 -0
  53. data/test/test_ggn_digit_excluding_zero.rb +22 -0
  54. data/test/test_ggn_direction.rb +21 -0
  55. data/test/test_ggn_gameplay.rb +573 -0
  56. data/test/test_ggn_gameplay_into_base64.rb +545 -0
  57. data/test/test_ggn_integer.rb +41 -0
  58. data/test/test_ggn_last_moved_actor.rb +51 -0
  59. data/test/test_ggn_maximum_magnitude.rb +37 -0
  60. data/test/test_ggn_name.rb +51 -0
  61. data/test/test_ggn_negative_integer.rb +21 -0
  62. data/test/test_ggn_null.rb +21 -0
  63. data/test/test_ggn_object.rb +35 -0
  64. data/test/test_ggn_occupied.rb +102 -0
  65. data/test/test_ggn_pattern.rb +82 -0
  66. data/test/test_ggn_previous_moves_counter.rb +41 -0
  67. data/test/test_ggn_promotable_into_actors.rb +598 -0
  68. data/test/test_ggn_required.rb +37 -0
  69. data/test/test_ggn_self.rb +21 -0
  70. data/test/test_ggn_square.rb +27 -0
  71. data/test/test_ggn_state.rb +28 -0
  72. data/test/test_ggn_subject.rb +30 -0
  73. data/test/test_ggn_unsigned_integer.rb +21 -0
  74. data/test/test_ggn_unsigned_integer_excluding_zero.rb +21 -0
  75. data/test/test_ggn_verb.rb +26 -0
  76. data/test/test_ggn_zero.rb +21 -0
  77. metadata +208 -0
@@ -0,0 +1,37 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::Required do
4
+ describe '.new' do
5
+ describe 'false' do
6
+ before do
7
+ @required = Sashite::GGN::Required.new('f')
8
+ end
9
+
10
+ it 'returns the GGN as a JSON' do
11
+ @required.as_json.must_equal false
12
+ end
13
+
14
+ it 'returns the GGN as a string' do
15
+ @required.to_s.must_equal 'f'
16
+ end
17
+ end
18
+
19
+ describe 'true' do
20
+ before do
21
+ @required = Sashite::GGN::Required.new('t')
22
+ end
23
+
24
+ it 'returns the GGN as a JSON' do
25
+ @required.as_json.must_equal true
26
+ end
27
+
28
+ it 'returns the GGN as a string' do
29
+ @required.to_s.must_equal 't'
30
+ end
31
+ end
32
+ end
33
+
34
+ it 'raises an error' do
35
+ -> { Sashite::GGN::Required.new('foobar') }.must_raise ArgumentError
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::Self do
4
+ describe '.instance' do
5
+ before do
6
+ @s = Sashite::GGN::Self.instance
7
+ end
8
+
9
+ it 'returns the GGN as a JSON' do
10
+ @s.as_json.must_equal :self
11
+ end
12
+
13
+ it 'returns the GGN as a string' do
14
+ @s.to_s.must_equal 'self'
15
+ end
16
+ end
17
+
18
+ it 'is false' do
19
+ Sashite::GGN::Self.valid?('foobar').must_equal false
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::Square do
4
+ describe '.new' do
5
+ before do
6
+ @square = Sashite::GGN::Square.new('_@an_enemy_actor+all')
7
+ end
8
+
9
+ it 'returns the GGN as a JSON' do
10
+ @square.as_json.hash.must_equal(
11
+ {
12
+ :"...attacked?" => nil,
13
+ :"...occupied!" => :an_enemy_actor,
14
+ :"area" => :all
15
+ }.hash
16
+ )
17
+ end
18
+
19
+ it 'returns the GGN as a string' do
20
+ @square.to_s.must_equal '_@an_enemy_actor+all'
21
+ end
22
+ end
23
+
24
+ it 'raises an error' do
25
+ -> { Sashite::GGN::Square.new('foo') }.must_raise ArgumentError
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::State do
4
+ describe '.new' do
5
+ describe 'a state' do
6
+ before do
7
+ @state = Sashite::GGN::State.new('t&_')
8
+ end
9
+
10
+ it 'returns the GGN as a JSON' do
11
+ @state.as_json.hash.must_equal(
12
+ {
13
+ :"...last_moved_actor?" => true,
14
+ :"...previous_moves_counter" => nil
15
+ }.hash
16
+ )
17
+ end
18
+
19
+ it 'returns the GGN as a string' do
20
+ @state.to_s.must_equal 't&_'
21
+ end
22
+ end
23
+ end
24
+
25
+ it 'raises an error' do
26
+ -> { Sashite::GGN::State.new('foobar') }.must_raise ArgumentError
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::Subject do
4
+ describe '.new' do
5
+ before do
6
+ @subject = Sashite::GGN::Subject.new('t<self>_&_')
7
+ end
8
+
9
+ it 'returns the GGN as a JSON' do
10
+ @subject.as_json.hash.must_equal(
11
+ {
12
+ :"...ally?" => true,
13
+ :"actor" => :self,
14
+ :"state" => {
15
+ :"...last_moved_actor?" => nil,
16
+ :"...previous_moves_counter" => nil
17
+ }
18
+ }.hash
19
+ )
20
+ end
21
+
22
+ it 'returns the GGN as a string' do
23
+ @subject.to_s.must_equal 't<self>_&_'
24
+ end
25
+ end
26
+
27
+ it 'raises an error' do
28
+ -> { Sashite::GGN::Subject.new('?<self>_&_') }.must_raise ArgumentError
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::UnsignedInteger do
4
+ describe '.new' do
5
+ before do
6
+ @unsigned_integer = Sashite::GGN::UnsignedInteger.new('0')
7
+ end
8
+
9
+ it 'returns the GGN as a JSON' do
10
+ @unsigned_integer.as_json.must_equal 0
11
+ end
12
+
13
+ it 'returns the GGN as a string' do
14
+ @unsigned_integer.to_s.must_equal '0'
15
+ end
16
+ end
17
+
18
+ it 'raises an error' do
19
+ -> { Sashite::GGN::UnsignedInteger.new('-42') }.must_raise ArgumentError
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::UnsignedIntegerExcludingZero do
4
+ describe '.new' do
5
+ before do
6
+ @unsigned_integer_excluding_zero = Sashite::GGN::UnsignedIntegerExcludingZero.new('42')
7
+ end
8
+
9
+ it 'returns the GGN as a JSON' do
10
+ @unsigned_integer_excluding_zero.as_json.must_equal 42
11
+ end
12
+
13
+ it 'returns the GGN as a string' do
14
+ @unsigned_integer_excluding_zero.to_s.must_equal '42'
15
+ end
16
+ end
17
+
18
+ it 'raises an error' do
19
+ -> { Sashite::GGN::UnsignedIntegerExcludingZero.new('0') }.must_raise ArgumentError
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::Verb do
4
+ describe '.new' do
5
+ before do
6
+ @verb = Sashite::GGN::Verb.new('shift[4,2]42/t')
7
+ end
8
+
9
+ it 'returns the GGN as a JSON' do
10
+ @verb.as_json.hash.must_equal(
11
+ {
12
+ name: :shift,
13
+ vector: {direction: [4,2], :"...maximum_magnitude" => 42}
14
+ }.hash
15
+ )
16
+ end
17
+
18
+ it 'returns the GGN as a string' do
19
+ @verb.to_s.must_equal 'shift[4,2]42/t'
20
+ end
21
+ end
22
+
23
+ it 'raises an error' do
24
+ -> { Sashite::GGN::Verb.new('shift[4,2]0/t') }.must_raise ArgumentError
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::GGN::Zero do
4
+ describe '.instance' do
5
+ before do
6
+ @s = Sashite::GGN::Zero.instance
7
+ end
8
+
9
+ it 'returns the GGN as a JSON' do
10
+ @s.as_json.must_equal 0
11
+ end
12
+
13
+ it 'returns the GGN as a string' do
14
+ @s.to_s.must_equal '0'
15
+ end
16
+ end
17
+
18
+ it 'is false' do
19
+ Sashite::GGN::Zero.valid?('foobar').must_equal false
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,208 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sashite-ggn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Cyril Wack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sashite-cgh
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10'
69
+ description: Ruby implementation of General Gameplay Notation.
70
+ email:
71
+ - contact@cyril.io
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".ruby-version"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.md
81
+ - README.md
82
+ - Rakefile
83
+ - VERSION.semver
84
+ - lib/sashite-ggn.rb
85
+ - lib/sashite/ggn.rb
86
+ - lib/sashite/ggn/ability.rb
87
+ - lib/sashite/ggn/actor.rb
88
+ - lib/sashite/ggn/ally.rb
89
+ - lib/sashite/ggn/area.rb
90
+ - lib/sashite/ggn/attacked.rb
91
+ - lib/sashite/ggn/boolean.rb
92
+ - lib/sashite/ggn/digit.rb
93
+ - lib/sashite/ggn/digit_excluding_zero.rb
94
+ - lib/sashite/ggn/direction.rb
95
+ - lib/sashite/ggn/gameplay.rb
96
+ - lib/sashite/ggn/gameplay_into_base64.rb
97
+ - lib/sashite/ggn/integer.rb
98
+ - lib/sashite/ggn/last_moved_actor.rb
99
+ - lib/sashite/ggn/maximum_magnitude.rb
100
+ - lib/sashite/ggn/name.rb
101
+ - lib/sashite/ggn/negative_integer.rb
102
+ - lib/sashite/ggn/null.rb
103
+ - lib/sashite/ggn/object.rb
104
+ - lib/sashite/ggn/occupied.rb
105
+ - lib/sashite/ggn/pattern.rb
106
+ - lib/sashite/ggn/previous_moves_counter.rb
107
+ - lib/sashite/ggn/promotable_into_actors.rb
108
+ - lib/sashite/ggn/required.rb
109
+ - lib/sashite/ggn/self.rb
110
+ - lib/sashite/ggn/square.rb
111
+ - lib/sashite/ggn/state.rb
112
+ - lib/sashite/ggn/subject.rb
113
+ - lib/sashite/ggn/unsigned_integer.rb
114
+ - lib/sashite/ggn/unsigned_integer_excluding_zero.rb
115
+ - lib/sashite/ggn/verb.rb
116
+ - lib/sashite/ggn/zero.rb
117
+ - sashite-ggn.gemspec
118
+ - test/_test_helper.rb
119
+ - test/test_ggn.rb
120
+ - test/test_ggn_ability.rb
121
+ - test/test_ggn_actor.rb
122
+ - test/test_ggn_ally.rb
123
+ - test/test_ggn_area.rb
124
+ - test/test_ggn_attacked.rb
125
+ - test/test_ggn_boolean.rb
126
+ - test/test_ggn_digit.rb
127
+ - test/test_ggn_digit_excluding_zero.rb
128
+ - test/test_ggn_direction.rb
129
+ - test/test_ggn_gameplay.rb
130
+ - test/test_ggn_gameplay_into_base64.rb
131
+ - test/test_ggn_integer.rb
132
+ - test/test_ggn_last_moved_actor.rb
133
+ - test/test_ggn_maximum_magnitude.rb
134
+ - test/test_ggn_name.rb
135
+ - test/test_ggn_negative_integer.rb
136
+ - test/test_ggn_null.rb
137
+ - test/test_ggn_object.rb
138
+ - test/test_ggn_occupied.rb
139
+ - test/test_ggn_pattern.rb
140
+ - test/test_ggn_previous_moves_counter.rb
141
+ - test/test_ggn_promotable_into_actors.rb
142
+ - test/test_ggn_required.rb
143
+ - test/test_ggn_self.rb
144
+ - test/test_ggn_square.rb
145
+ - test/test_ggn_state.rb
146
+ - test/test_ggn_subject.rb
147
+ - test/test_ggn_unsigned_integer.rb
148
+ - test/test_ggn_unsigned_integer_excluding_zero.rb
149
+ - test/test_ggn_verb.rb
150
+ - test/test_ggn_zero.rb
151
+ homepage: https://github.com/sashite/ggn.rb
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubyforge_project:
171
+ rubygems_version: 2.2.2
172
+ signing_key:
173
+ specification_version: 4
174
+ summary: A Ruby GGN parser.
175
+ test_files:
176
+ - test/_test_helper.rb
177
+ - test/test_ggn.rb
178
+ - test/test_ggn_ability.rb
179
+ - test/test_ggn_actor.rb
180
+ - test/test_ggn_ally.rb
181
+ - test/test_ggn_area.rb
182
+ - test/test_ggn_attacked.rb
183
+ - test/test_ggn_boolean.rb
184
+ - test/test_ggn_digit.rb
185
+ - test/test_ggn_digit_excluding_zero.rb
186
+ - test/test_ggn_direction.rb
187
+ - test/test_ggn_gameplay.rb
188
+ - test/test_ggn_gameplay_into_base64.rb
189
+ - test/test_ggn_integer.rb
190
+ - test/test_ggn_last_moved_actor.rb
191
+ - test/test_ggn_maximum_magnitude.rb
192
+ - test/test_ggn_name.rb
193
+ - test/test_ggn_negative_integer.rb
194
+ - test/test_ggn_null.rb
195
+ - test/test_ggn_object.rb
196
+ - test/test_ggn_occupied.rb
197
+ - test/test_ggn_pattern.rb
198
+ - test/test_ggn_previous_moves_counter.rb
199
+ - test/test_ggn_promotable_into_actors.rb
200
+ - test/test_ggn_required.rb
201
+ - test/test_ggn_self.rb
202
+ - test/test_ggn_square.rb
203
+ - test/test_ggn_state.rb
204
+ - test/test_ggn_subject.rb
205
+ - test/test_ggn_unsigned_integer.rb
206
+ - test/test_ggn_unsigned_integer_excluding_zero.rb
207
+ - test/test_ggn_verb.rb
208
+ - test/test_ggn_zero.rb