sashite-ggn 0.1.0 → 0.3.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 (84) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.md +17 -18
  3. data/README.md +356 -506
  4. data/lib/sashite/ggn/piece/source/destination/engine/transition.rb +90 -0
  5. data/lib/sashite/ggn/piece/source/destination/engine.rb +407 -0
  6. data/lib/sashite/ggn/piece/source/destination.rb +65 -0
  7. data/lib/sashite/ggn/piece/source.rb +71 -0
  8. data/lib/sashite/ggn/piece.rb +77 -0
  9. data/lib/sashite/ggn/schema.rb +152 -0
  10. data/lib/sashite/ggn/validation_error.rb +31 -0
  11. data/lib/sashite/ggn.rb +317 -5
  12. data/lib/sashite-ggn.rb +112 -1
  13. metadata +31 -151
  14. data/.gitignore +0 -22
  15. data/.ruby-version +0 -1
  16. data/.travis.yml +0 -3
  17. data/Gemfile +0 -2
  18. data/Rakefile +0 -7
  19. data/VERSION.semver +0 -1
  20. data/lib/sashite/ggn/ability.rb +0 -29
  21. data/lib/sashite/ggn/actor.rb +0 -20
  22. data/lib/sashite/ggn/ally.rb +0 -20
  23. data/lib/sashite/ggn/area.rb +0 -17
  24. data/lib/sashite/ggn/attacked.rb +0 -20
  25. data/lib/sashite/ggn/boolean.rb +0 -17
  26. data/lib/sashite/ggn/digit.rb +0 -20
  27. data/lib/sashite/ggn/digit_excluding_zero.rb +0 -17
  28. data/lib/sashite/ggn/direction.rb +0 -19
  29. data/lib/sashite/ggn/gameplay.rb +0 -20
  30. data/lib/sashite/ggn/gameplay_into_base64.rb +0 -21
  31. data/lib/sashite/ggn/integer.rb +0 -20
  32. data/lib/sashite/ggn/last_moved_actor.rb +0 -20
  33. data/lib/sashite/ggn/maximum_magnitude.rb +0 -20
  34. data/lib/sashite/ggn/name.rb +0 -17
  35. data/lib/sashite/ggn/negative_integer.rb +0 -19
  36. data/lib/sashite/ggn/null.rb +0 -21
  37. data/lib/sashite/ggn/object.rb +0 -28
  38. data/lib/sashite/ggn/occupied.rb +0 -29
  39. data/lib/sashite/ggn/pattern.rb +0 -20
  40. data/lib/sashite/ggn/previous_moves_counter.rb +0 -20
  41. data/lib/sashite/ggn/promotable_into_actors.rb +0 -23
  42. data/lib/sashite/ggn/required.rb +0 -19
  43. data/lib/sashite/ggn/self.rb +0 -21
  44. data/lib/sashite/ggn/square.rb +0 -29
  45. data/lib/sashite/ggn/state.rb +0 -26
  46. data/lib/sashite/ggn/subject.rb +0 -29
  47. data/lib/sashite/ggn/unsigned_integer.rb +0 -20
  48. data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +0 -20
  49. data/lib/sashite/ggn/verb.rb +0 -33
  50. data/lib/sashite/ggn/zero.rb +0 -21
  51. data/sashite-ggn.gemspec +0 -19
  52. data/test/_test_helper.rb +0 -2
  53. data/test/test_ggn.rb +0 -552
  54. data/test/test_ggn_ability.rb +0 -51
  55. data/test/test_ggn_actor.rb +0 -571
  56. data/test/test_ggn_ally.rb +0 -35
  57. data/test/test_ggn_area.rb +0 -21
  58. data/test/test_ggn_attacked.rb +0 -35
  59. data/test/test_ggn_boolean.rb +0 -21
  60. data/test/test_ggn_digit.rb +0 -21
  61. data/test/test_ggn_digit_excluding_zero.rb +0 -21
  62. data/test/test_ggn_direction.rb +0 -21
  63. data/test/test_ggn_gameplay.rb +0 -557
  64. data/test/test_ggn_gameplay_into_base64.rb +0 -555
  65. data/test/test_ggn_integer.rb +0 -39
  66. data/test/test_ggn_last_moved_actor.rb +0 -35
  67. data/test/test_ggn_maximum_magnitude.rb +0 -39
  68. data/test/test_ggn_name.rb +0 -21
  69. data/test/test_ggn_negative_integer.rb +0 -21
  70. data/test/test_ggn_null.rb +0 -21
  71. data/test/test_ggn_object.rb +0 -33
  72. data/test/test_ggn_occupied.rb +0 -78
  73. data/test/test_ggn_pattern.rb +0 -84
  74. data/test/test_ggn_previous_moves_counter.rb +0 -39
  75. data/test/test_ggn_promotable_into_actors.rb +0 -578
  76. data/test/test_ggn_required.rb +0 -21
  77. data/test/test_ggn_self.rb +0 -21
  78. data/test/test_ggn_square.rb +0 -25
  79. data/test/test_ggn_state.rb +0 -24
  80. data/test/test_ggn_subject.rb +0 -28
  81. data/test/test_ggn_unsigned_integer.rb +0 -39
  82. data/test/test_ggn_unsigned_integer_excluding_zero.rb +0 -25
  83. data/test/test_ggn_verb.rb +0 -27
  84. data/test/test_ggn_zero.rb +0 -21
@@ -1,17 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Name
4
- PATTERN = /(capture|remove|shift)/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io
11
- raise ArgumentError unless valid? io
12
-
13
- io.to_sym
14
- end
15
- end
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- require_relative 'unsigned_integer_excluding_zero'
2
-
3
- module Sashite
4
- module GGN
5
- module NegativeInteger
6
- PATTERN = /-#{UnsignedIntegerExcludingZero::PATTERN}/
7
-
8
- def self.valid? io
9
- !!io.match("^#{PATTERN}$")
10
- end
11
-
12
- def self.load io
13
- raise ArgumentError unless valid? io
14
-
15
- io.to_i
16
- end
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Null
4
- PATTERN = /_/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io = nil
11
- raise ArgumentError if io && !valid?(io)
12
-
13
- nil
14
- end
15
-
16
- def self.dump
17
- '_'
18
- end
19
- end
20
- end
21
- end
@@ -1,28 +0,0 @@
1
- require_relative 'square'
2
- require_relative 'promotable_into_actors'
3
-
4
- module Sashite
5
- module GGN
6
- module Object
7
- PATTERN = /#{Square::PATTERN}~#{Square::PATTERN}%#{PromotableIntoActors::PATTERN}/
8
-
9
- def self.valid? io
10
- !!io.match("^#{PATTERN}$")
11
- end
12
-
13
- def self.load io
14
- raise ArgumentError unless valid? io
15
-
16
- src_square = Square.load io.split('~').fetch 0
17
- dst_square = Square.load io.split('~').fetch(1).split('%').fetch 0
18
- promotable_into_actors = PromotableIntoActors.load io.split('%').fetch 1
19
-
20
- {
21
- src_square: src_square,
22
- dst_square: dst_square,
23
- promotable_into_actors: promotable_into_actors
24
- }
25
- end
26
- end
27
- end
28
- end
@@ -1,29 +0,0 @@
1
- require_relative 'boolean'
2
- require_relative 'null'
3
- require_relative 'subject'
4
-
5
- module Sashite
6
- module GGN
7
- module Occupied
8
- PATTERN = /(#{Null::PATTERN}|#{Boolean::PATTERN}|#{Subject::PATTERN}|an_ally_actor|an_enemy_actor)/
9
-
10
- def self.valid? io
11
- !!io.match("^#{PATTERN}$")
12
- end
13
-
14
- def self.load io
15
- raise ArgumentError unless valid? io
16
-
17
- if Null.valid? io
18
- Null.load
19
- elsif Boolean.valid? io
20
- Boolean.load io
21
- elsif Subject.valid? io
22
- Subject.load io
23
- else
24
- io.to_sym
25
- end
26
- end
27
- end
28
- end
29
- end
@@ -1,20 +0,0 @@
1
- require_relative 'ability'
2
-
3
- module Sashite
4
- module GGN
5
- module Pattern
6
- PATTERN = /#{Ability::PATTERN}(; #{Ability::PATTERN})*/
7
-
8
- def self.valid? io
9
- io.match("^#{PATTERN}$") &&
10
- io.split('; ').uniq.join('; ') == io
11
- end
12
-
13
- def self.load io
14
- raise ArgumentError unless valid? io
15
-
16
- io.split('; ').map { |ability| Ability.load ability }
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require_relative 'null'
2
- require_relative 'unsigned_integer'
3
-
4
- module Sashite
5
- module GGN
6
- module PreviousMovesCounter
7
- PATTERN = /(#{Null::PATTERN}|#{UnsignedInteger::PATTERN})/
8
-
9
- def self.valid? io
10
- !!io.match("^#{PATTERN}$")
11
- end
12
-
13
- def self.load io
14
- raise ArgumentError unless valid? io
15
-
16
- Null.valid?(io) ? Null.load : UnsignedInteger.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,23 +0,0 @@
1
- require_relative 'actor'
2
- require_relative 'gameplay_into_base64'
3
-
4
- module Sashite
5
- module GGN
6
- module PromotableIntoActors
7
- PATTERN = /(#{GameplayIntoBase64::PATTERN},)*#{Actor::PATTERN}/
8
-
9
- def self.valid? io
10
- io.match("^#{PATTERN}$") &&
11
- io.split(',').uniq.join(',') == io
12
- end
13
-
14
- def self.load io
15
- raise ArgumentError unless valid? io
16
-
17
- io.split(',').map do |value|
18
- Actor.valid?(value) ? Actor.load(value) : GameplayIntoBase64.load(value)
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,19 +0,0 @@
1
- require_relative 'boolean'
2
-
3
- module Sashite
4
- module GGN
5
- module Required
6
- PATTERN = /#{Boolean::PATTERN}/
7
-
8
- def self.valid? io
9
- !!io.match("^#{PATTERN}$")
10
- end
11
-
12
- def self.load io
13
- raise ArgumentError unless valid? io
14
-
15
- Boolean.load io
16
- end
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Self
4
- PATTERN = /self/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io = nil
11
- raise ArgumentError if io && !valid?(io)
12
-
13
- :self
14
- end
15
-
16
- def self.dump
17
- 'self'
18
- end
19
- end
20
- end
21
- end
@@ -1,29 +0,0 @@
1
- require_relative 'attacked'
2
- require_relative 'occupied'
3
- require_relative 'area'
4
-
5
- module Sashite
6
- module GGN
7
- module Square
8
- PATTERN = /#{Attacked::PATTERN}@#{Occupied::PATTERN}\+#{Area::PATTERN}/
9
-
10
- def self.valid? io
11
- !!io.match("^#{PATTERN}$")
12
- end
13
-
14
- def self.load io
15
- raise ArgumentError unless valid? io
16
-
17
- attacked = Attacked.load io.split('@').fetch(0)
18
- occupied = Occupied.load io.split('@').fetch(1).split('+').fetch(0)
19
- area = Area.load io.split('+').fetch(1)
20
-
21
- {
22
- :"...attacked?" => attacked,
23
- :"...occupied!" => occupied,
24
- :"area" => area
25
- }
26
- end
27
- end
28
- end
29
- end
@@ -1,26 +0,0 @@
1
- require_relative 'last_moved_actor'
2
- require_relative 'previous_moves_counter'
3
-
4
- module Sashite
5
- module GGN
6
- module State
7
- PATTERN = /#{LastMovedActor::PATTERN}&#{PreviousMovesCounter::PATTERN}/
8
-
9
- def self.valid? io
10
- !!io.match("^#{PATTERN}$")
11
- end
12
-
13
- def self.load io
14
- raise ArgumentError unless valid? io
15
-
16
- last_moved_actor = LastMovedActor.load io.split('&').fetch(0)
17
- previous_moves_counter = PreviousMovesCounter.load io.split('&').fetch(1)
18
-
19
- {
20
- :"...last_moved_actor?" => last_moved_actor,
21
- :"...previous_moves_counter" => previous_moves_counter
22
- }
23
- end
24
- end
25
- end
26
- end
@@ -1,29 +0,0 @@
1
- require_relative 'ally'
2
- require_relative 'actor'
3
- require_relative 'state'
4
-
5
- module Sashite
6
- module GGN
7
- module Subject
8
- PATTERN = /#{Ally::PATTERN}<#{Actor::PATTERN}>#{State::PATTERN}/
9
-
10
- def self.valid? io
11
- !!io.match("^#{PATTERN}$")
12
- end
13
-
14
- def self.load io
15
- raise ArgumentError unless valid? io
16
-
17
- ally = Ally.load io.split('<').fetch(0)
18
- actor = Actor.load io.split('<').fetch(1).split('>').fetch(0)
19
- state = State.load io.split('>').fetch(1)
20
-
21
- {
22
- :"...ally?" => ally,
23
- actor: actor,
24
- state: state
25
- }
26
- end
27
- end
28
- end
29
- end
@@ -1,20 +0,0 @@
1
- require_relative 'unsigned_integer_excluding_zero'
2
- require_relative 'zero'
3
-
4
- module Sashite
5
- module GGN
6
- module UnsignedInteger
7
- PATTERN = /(#{Zero::PATTERN}|#{UnsignedIntegerExcludingZero::PATTERN})/
8
-
9
- def self.valid? io
10
- !!io.match("^#{PATTERN}$")
11
- end
12
-
13
- def self.load io
14
- raise ArgumentError unless valid? io
15
-
16
- Zero.valid?(io) ? Zero.load : UnsignedIntegerExcludingZero.load(io)
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require_relative 'digit'
2
- require_relative 'digit_excluding_zero'
3
-
4
- module Sashite
5
- module GGN
6
- class UnsignedIntegerExcludingZero
7
- PATTERN = /#{DigitExcludingZero::PATTERN}#{Digit::PATTERN}*/
8
-
9
- def self.valid? io
10
- !!io.match("^#{PATTERN}$")
11
- end
12
-
13
- def self.load io
14
- raise ArgumentError unless valid? io
15
-
16
- io.to_i
17
- end
18
- end
19
- end
20
- end
@@ -1,33 +0,0 @@
1
- require_relative 'direction'
2
- require_relative 'maximum_magnitude'
3
- require_relative 'name'
4
- require_relative 'required'
5
-
6
- module Sashite
7
- module GGN
8
- module Verb
9
- PATTERN = /#{Name::PATTERN}\[#{Direction::PATTERN}\]#{MaximumMagnitude::PATTERN}\/#{Required::PATTERN}/
10
-
11
- def self.valid? io
12
- !!io.match("^#{PATTERN}$")
13
- end
14
-
15
- def self.load io
16
- raise ArgumentError unless valid? io
17
-
18
- name = Name.load io.split('[').fetch 0
19
- direction = Direction.load io.split('[').fetch(1).split(']').fetch 0
20
- maximum_magnitude = MaximumMagnitude.load io.split(']').fetch(1).split('/').fetch 0
21
- required = Required.load io.split('/').fetch 1
22
-
23
- {
24
- name: name,
25
- vector: {
26
- :"...maximum_magnitude" => maximum_magnitude,
27
- direction: direction
28
- }
29
- }
30
- end
31
- end
32
- end
33
- end
@@ -1,21 +0,0 @@
1
- module Sashite
2
- module GGN
3
- module Zero
4
- PATTERN = /0/
5
-
6
- def self.valid? io
7
- !!io.match("^#{PATTERN}$")
8
- end
9
-
10
- def self.load io = nil
11
- raise ArgumentError if io && !valid?(io)
12
-
13
- 0
14
- end
15
-
16
- def self.dump
17
- '0'
18
- end
19
- end
20
- end
21
- end
data/sashite-ggn.gemspec DELETED
@@ -1,19 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = 'sashite-ggn'
3
- spec.version = File.read('VERSION.semver')
4
- spec.authors = ['Cyril Wack']
5
- spec.email = ['contact@cyril.io']
6
- spec.summary = %q{General Gameplay Notation.}
7
- spec.description = %q{A Ruby interface for data serialization in GGN format.}
8
- spec.homepage = 'https://github.com/sashite/ggn.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
data/test/_test_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'sashite/ggn'
2
- require 'minitest/autorun'