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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +523 -521
  3. data/VERSION.semver +1 -1
  4. data/lib/sashite/ggn.rb +3 -2
  5. data/lib/sashite/ggn/ability.rb +11 -19
  6. data/lib/sashite/ggn/actor.rb +5 -13
  7. data/lib/sashite/ggn/ally.rb +6 -14
  8. data/lib/sashite/ggn/area.rb +6 -14
  9. data/lib/sashite/ggn/attacked.rb +6 -14
  10. data/lib/sashite/ggn/boolean.rb +6 -14
  11. data/lib/sashite/ggn/digit.rb +6 -14
  12. data/lib/sashite/ggn/digit_excluding_zero.rb +6 -14
  13. data/lib/sashite/ggn/direction.rb +6 -14
  14. data/lib/sashite/ggn/gameplay.rb +8 -28
  15. data/lib/sashite/ggn/gameplay_into_base64.rb +7 -14
  16. data/lib/sashite/ggn/integer.rb +6 -14
  17. data/lib/sashite/ggn/last_moved_actor.rb +6 -14
  18. data/lib/sashite/ggn/maximum_magnitude.rb +6 -14
  19. data/lib/sashite/ggn/name.rb +6 -14
  20. data/lib/sashite/ggn/negative_integer.rb +6 -14
  21. data/lib/sashite/ggn/null.rb +7 -9
  22. data/lib/sashite/ggn/object.rb +11 -19
  23. data/lib/sashite/ggn/occupied.rb +12 -20
  24. data/lib/sashite/ggn/pattern.rb +7 -16
  25. data/lib/sashite/ggn/previous_moves_counter.rb +6 -14
  26. data/lib/sashite/ggn/promotable_into_actors.rb +8 -17
  27. data/lib/sashite/ggn/required.rb +6 -14
  28. data/lib/sashite/ggn/self.rb +7 -9
  29. data/lib/sashite/ggn/square.rb +11 -19
  30. data/lib/sashite/ggn/state.rb +9 -17
  31. data/lib/sashite/ggn/subject.rb +11 -19
  32. data/lib/sashite/ggn/unsigned_integer.rb +6 -14
  33. data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +5 -13
  34. data/lib/sashite/ggn/verb.rb +15 -24
  35. data/lib/sashite/ggn/zero.rb +7 -9
  36. data/sashite-ggn.gemspec +2 -4
  37. data/test/test_ggn.rb +501 -495
  38. data/test/test_ggn_ability.rb +10 -10
  39. data/test/test_ggn_actor.rb +516 -536
  40. data/test/test_ggn_ally.rb +13 -29
  41. data/test/test_ggn_area.rb +9 -67
  42. data/test/test_ggn_attacked.rb +13 -29
  43. data/test/test_ggn_boolean.rb +10 -26
  44. data/test/test_ggn_digit.rb +10 -10
  45. data/test/test_ggn_digit_excluding_zero.rb +10 -11
  46. data/test/test_ggn_direction.rb +10 -10
  47. data/test/test_ggn_gameplay.rb +22 -38
  48. data/test/test_ggn_gameplay_into_base64.rb +511 -501
  49. data/test/test_ggn_integer.rb +19 -21
  50. data/test/test_ggn_last_moved_actor.rb +13 -29
  51. data/test/test_ggn_maximum_magnitude.rb +18 -16
  52. data/test/test_ggn_name.rb +9 -39
  53. data/test/test_ggn_negative_integer.rb +10 -10
  54. data/test/test_ggn_null.rb +10 -10
  55. data/test/test_ggn_object.rb +22 -24
  56. data/test/test_ggn_occupied.rb +40 -64
  57. data/test/test_ggn_pattern.rb +12 -10
  58. data/test/test_ggn_previous_moves_counter.rb +18 -20
  59. data/test/test_ggn_promotable_into_actors.rb +529 -549
  60. data/test/test_ggn_required.rb +10 -26
  61. data/test/test_ggn_self.rb +10 -10
  62. data/test/test_ggn_square.rb +14 -16
  63. data/test/test_ggn_state.rb +15 -19
  64. data/test/test_ggn_subject.rb +17 -19
  65. data/test/test_ggn_unsigned_integer.rb +30 -12
  66. data/test/test_ggn_unsigned_integer_excluding_zero.rb +14 -10
  67. data/test/test_ggn_verb.rb +16 -15
  68. data/test/test_ggn_zero.rb +10 -10
  69. metadata +4 -18
@@ -1,37 +1,21 @@
1
1
  require_relative '_test_helper'
2
2
 
3
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
4
+ subject { Sashite::GGN::Required }
13
5
 
14
- it 'returns the GGN as a string' do
15
- @required.to_s.must_equal 'f'
16
- end
6
+ describe '.load' do
7
+ before do
8
+ @ggn_obj = 't'
17
9
  end
18
10
 
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
11
+ it 'loads a document from the current io stream' do
12
+ subject.load(@ggn_obj).must_equal true
13
+ end
27
14
 
28
- it 'returns the GGN as a string' do
29
- @required.to_s.must_equal 't'
15
+ describe 'errors' do
16
+ it 'raises without a boolean' do
17
+ -> { subject.load 'foobar' }.must_raise ArgumentError
30
18
  end
31
19
  end
32
20
  end
33
-
34
- it 'raises an error' do
35
- -> { Sashite::GGN::Required.new('foobar') }.must_raise ArgumentError
36
- end
37
21
  end
@@ -1,21 +1,21 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Self do
4
- describe '.instance' do
4
+ subject { Sashite::GGN::Self }
5
+
6
+ describe '.load' do
5
7
  before do
6
- @s = Sashite::GGN::Self.instance
8
+ @ggn_obj = 'self'
7
9
  end
8
10
 
9
- it 'returns the GGN as a JSON' do
10
- @s.as_json.must_equal :self
11
+ it 'loads a document from the current io stream' do
12
+ subject.load(@ggn_obj).must_equal :self
11
13
  end
12
14
 
13
- it 'returns the GGN as a string' do
14
- @s.to_s.must_equal 'self'
15
+ describe 'errors' do
16
+ it 'raises without self' do
17
+ -> { subject.load '42' }.must_raise ArgumentError
18
+ end
15
19
  end
16
20
  end
17
-
18
- it 'is false' do
19
- Sashite::GGN::Self.valid?('foobar').must_equal false
20
- end
21
21
  end
@@ -1,27 +1,25 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Square do
4
- describe '.new' do
4
+ subject { Sashite::GGN::Square }
5
+
6
+ describe '.load' do
5
7
  before do
6
- @square = Sashite::GGN::Square.new('_@an_enemy_actor+all')
8
+ @ggn_obj = '_@an_enemy_actor+all'
7
9
  end
8
10
 
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
- )
11
+ it 'loads a document from the current io stream' do
12
+ subject.load(@ggn_obj).hash.must_equal({
13
+ :"...attacked?" => nil,
14
+ :"...occupied!" => :an_enemy_actor,
15
+ :"area" => :all
16
+ }.hash)
17
17
  end
18
18
 
19
- it 'returns the GGN as a string' do
20
- @square.to_s.must_equal '_@an_enemy_actor+all'
19
+ describe 'errors' do
20
+ it 'raises witout a square' do
21
+ -> { subject.load 'foobar' }.must_raise ArgumentError
22
+ end
21
23
  end
22
24
  end
23
-
24
- it 'raises an error' do
25
- -> { Sashite::GGN::Square.new('foo') }.must_raise ArgumentError
26
- end
27
25
  end
@@ -1,28 +1,24 @@
1
1
  require_relative '_test_helper'
2
2
 
3
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
4
+ subject { Sashite::GGN::State }
9
5
 
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
6
+ describe '.load' do
7
+ before do
8
+ @ggn_obj = 't&_'
9
+ end
18
10
 
19
- it 'returns the GGN as a string' do
20
- @state.to_s.must_equal 't&_'
21
- end
11
+ it 'loads a document from the current io stream' do
12
+ subject.load(@ggn_obj).hash.must_equal({
13
+ :"...last_moved_actor?" => true,
14
+ :"...previous_moves_counter" => nil
15
+ }.hash)
22
16
  end
23
- end
24
17
 
25
- it 'raises an error' do
26
- -> { Sashite::GGN::State.new('foobar') }.must_raise ArgumentError
18
+ describe 'errors' do
19
+ it 'raises without a state' do
20
+ -> { subject.load 'foobar' }.must_raise ArgumentError
21
+ end
22
+ end
27
23
  end
28
24
  end
@@ -1,30 +1,28 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Subject do
4
- describe '.new' do
4
+ subject { Sashite::GGN::Subject }
5
+
6
+ describe '.load' do
5
7
  before do
6
- @subject = Sashite::GGN::Subject.new('t<self>_&_')
8
+ @ggn_obj = 't<self>_&_'
7
9
  end
8
10
 
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
- )
11
+ it 'loads a document from the current io stream' do
12
+ subject.load(@ggn_obj).hash.must_equal({
13
+ :"...ally?" => true,
14
+ :"actor" => :self,
15
+ :"state" => {
16
+ :"...last_moved_actor?" => nil,
17
+ :"...previous_moves_counter" => nil
18
+ }
19
+ }.hash)
20
20
  end
21
21
 
22
- it 'returns the GGN as a string' do
23
- @subject.to_s.must_equal 't<self>_&_'
22
+ describe 'errors' do
23
+ it 'raises without a subject' do
24
+ -> { subject.load 'foobar' }.must_raise ArgumentError
25
+ end
24
26
  end
25
27
  end
26
-
27
- it 'raises an error' do
28
- -> { Sashite::GGN::Subject.new('?<self>_&_') }.must_raise ArgumentError
29
- end
30
28
  end
@@ -1,21 +1,39 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::UnsignedInteger do
4
- describe '.new' do
5
- before do
6
- @unsigned_integer = Sashite::GGN::UnsignedInteger.new('0')
7
- end
4
+ subject { Sashite::GGN::UnsignedInteger }
8
5
 
9
- it 'returns the GGN as a JSON' do
10
- @unsigned_integer.as_json.must_equal 0
11
- end
6
+ describe '.load' do
7
+ describe 'a zero' do
8
+ before do
9
+ @ggn_obj = '0'
10
+ end
12
11
 
13
- it 'returns the GGN as a string' do
14
- @unsigned_integer.to_s.must_equal '0'
12
+ it 'loads a document from the current io stream' do
13
+ subject.load(@ggn_obj).must_equal 0
14
+ end
15
+
16
+ describe 'errors' do
17
+ it 'raises with a double zero' do
18
+ -> { subject.load '00' }.must_raise ArgumentError
19
+ end
20
+ end
15
21
  end
16
- end
17
22
 
18
- it 'raises an error' do
19
- -> { Sashite::GGN::UnsignedInteger.new('-42') }.must_raise ArgumentError
23
+ describe 'an unsigned integer excluding zero' do
24
+ before do
25
+ @ggn_obj = '42'
26
+ end
27
+
28
+ it 'loads a document from the current io stream' do
29
+ subject.load(@ggn_obj).must_equal 42
30
+ end
31
+
32
+ describe 'errors' do
33
+ it 'raises with a negative integer' do
34
+ -> { subject.load '-4' }.must_raise ArgumentError
35
+ end
36
+ end
37
+ end
20
38
  end
21
39
  end
@@ -1,21 +1,25 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::UnsignedIntegerExcludingZero do
4
- describe '.new' do
4
+ subject { Sashite::GGN::UnsignedIntegerExcludingZero }
5
+
6
+ describe '.load' do
5
7
  before do
6
- @unsigned_integer_excluding_zero = Sashite::GGN::UnsignedIntegerExcludingZero.new('42')
8
+ @ggn_obj = '42'
7
9
  end
8
10
 
9
- it 'returns the GGN as a JSON' do
10
- @unsigned_integer_excluding_zero.as_json.must_equal 42
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
- it 'returns the GGN as a string' do
14
- @unsigned_integer_excluding_zero.to_s.must_equal '42'
15
- end
16
- end
15
+ describe 'errors' do
16
+ it 'raises with a negative integer' do
17
+ -> { subject.load '-42' }.must_raise ArgumentError
18
+ end
17
19
 
18
- it 'raises an error' do
19
- -> { Sashite::GGN::UnsignedIntegerExcludingZero.new('0') }.must_raise ArgumentError
20
+ it 'raises with a zero' do
21
+ -> { subject.load '0' }.must_raise ArgumentError
22
+ end
23
+ end
20
24
  end
21
25
  end
@@ -1,26 +1,27 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Verb do
4
- describe '.new' do
4
+ subject { Sashite::GGN::Verb }
5
+
6
+ describe '.load' do
5
7
  before do
6
- @verb = Sashite::GGN::Verb.new('shift[4,2]42/t')
8
+ @ggn_obj = 'shift[4,2]42/t'
7
9
  end
8
10
 
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
- )
11
+ it 'loads a document from the current io stream' do
12
+ subject.load(@ggn_obj).hash.must_equal({
13
+ name: :shift,
14
+ vector: {
15
+ direction: [4,2],
16
+ :"...maximum_magnitude" => 42
17
+ }
18
+ }.hash)
16
19
  end
17
20
 
18
- it 'returns the GGN as a string' do
19
- @verb.to_s.must_equal 'shift[4,2]42/t'
21
+ describe 'errors' do
22
+ it 'raises without a verb structure' do
23
+ -> { subject.load 'foobar' }.must_raise ArgumentError
24
+ end
20
25
  end
21
26
  end
22
-
23
- it 'raises an error' do
24
- -> { Sashite::GGN::Verb.new('shift[4,2]0/t') }.must_raise ArgumentError
25
- end
26
27
  end
@@ -1,21 +1,21 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Zero do
4
- describe '.instance' do
4
+ subject { Sashite::GGN::Zero }
5
+
6
+ describe '.load' do
5
7
  before do
6
- @s = Sashite::GGN::Zero.instance
8
+ @ggn_obj = '0'
7
9
  end
8
10
 
9
- it 'returns the GGN as a JSON' do
10
- @s.as_json.must_equal 0
11
+ it 'loads a document from the current io stream' do
12
+ subject.load(@ggn_obj).must_equal 0
11
13
  end
12
14
 
13
- it 'returns the GGN as a string' do
14
- @s.to_s.must_equal '0'
15
+ describe 'errors' do
16
+ it 'raises without zero' 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::Zero.valid?('foobar').must_equal false
20
- end
21
21
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sashite-ggn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Wack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +52,7 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '10'
69
- description: Ruby implementation of General Gameplay Notation.
55
+ description: A Ruby interface for data serialization in GGN format.
70
56
  email:
71
57
  - contact@cyril.io
72
58
  executables: []
@@ -171,7 +157,7 @@ rubyforge_project:
171
157
  rubygems_version: 2.2.2
172
158
  signing_key:
173
159
  specification_version: 4
174
- summary: A Ruby GGN parser.
160
+ summary: General Gameplay Notation.
175
161
  test_files:
176
162
  - test/_test_helper.rb
177
163
  - test/test_ggn.rb