sashite-pan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e7418ca5f0d9461164075f8a7362d0c70439fcbe
4
+ data.tar.gz: 697a969bab18dc6cc1346db2e18492afc48da862
5
+ SHA512:
6
+ metadata.gz: 4b6f11ef92ded4ef26958029c6066e8b6ff76b032139f8d82c0e2b23a2112e39e2aafbe2b14bdde1cd47cea3745f8348deb35de207d2e53f0557f2bd23839fa3
7
+ data.tar.gz: 4664588f59115312c34f7d37b4d77be1cedb9ba2a9c2639877e061c59781a99ddfd66a16d02b07046d7ed6e6d6e5004246632a61afb78c58c2f132a4fcc3c2b1
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.2
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Cyril Wack
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Sashite::PAN
2
+
3
+ Ruby implementation of [PAN](http://sashite.wiki/Portable_Action_Notation) parser and emitter.
4
+
5
+ ## Status
6
+
7
+ * [![Gem Version](https://badge.fury.io/rb/sashite-pan.svg)](//badge.fury.io/rb/sashite-pan)
8
+ * [![Build Status](https://secure.travis-ci.org/sashite/pan.rb.svg?branch=master)](//travis-ci.org/sashite/pan.rb?branch=master)
9
+ * [![Dependency Status](https://gemnasium.com/sashite/pan.rb.svg)](//gemnasium.com/sashite/pan.rb)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'sashite-pan'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install sashite-pan
24
+
25
+ ## Example
26
+
27
+ require 'sashite-pan'
28
+
29
+ action = Sashite::PAN.load :shift, 42, 43
30
+ action.src_square # => 42
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ end
6
+
7
+ task(default: :test)
data/VERSION.semver ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,24 @@
1
+ module Sashite
2
+ module PAN
3
+ class Capture
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
@@ -0,0 +1,23 @@
1
+ module Sashite
2
+ module PAN
3
+ class Drop
4
+ attr_reader :actor, :dst_square
5
+
6
+ def initialize actor, dst_square
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
+ @actor,
18
+ @dst_square
19
+ ]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ module Sashite
2
+ module PAN
3
+ class NotImplementedVerbError < ::StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Sashite
2
+ module PAN
3
+ class SameSquareError < ::StandardError
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,23 @@
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
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,24 @@
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
@@ -0,0 +1,34 @@
1
+ require_relative 'pan/capture'
2
+ require_relative 'pan/drop'
3
+ require_relative 'pan/error/not_implemented_verb_error'
4
+ require_relative 'pan/error/same_square_error'
5
+ require_relative 'pan/promote'
6
+ require_relative 'pan/remove'
7
+ require_relative 'pan/shift'
8
+
9
+ module Sashite
10
+ module PAN
11
+ def self.load verb, arg1, arg2
12
+ case verb
13
+
14
+ when :capture
15
+ Capture.new arg1, arg2
16
+
17
+ when :drop
18
+ Drop.new arg1, arg2
19
+
20
+ when :promote
21
+ Promote.new arg1, arg2
22
+
23
+ when :remove
24
+ Remove.new arg1, arg2
25
+
26
+ when :shift
27
+ Shift.new arg1, arg2
28
+
29
+ else
30
+ raise NotImplementedVerbError
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'sashite-pan'
3
+ spec.version = File.read('VERSION.semver')
4
+ spec.authors = ['Cyril Wack']
5
+ spec.email = ['contact@cyril.io']
6
+ spec.summary = %q{Portable Action Notation (PAN) parser and emitter.}
7
+ spec.description = %q{A Portable Action Notation (PAN) parser and emitter, optimized for programmer happiness.}
8
+ spec.homepage = 'https://github.com/sashite/pan.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
@@ -0,0 +1,2 @@
1
+ require 'sashite/pan'
2
+ require 'minitest/autorun'
@@ -0,0 +1,41 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::PAN do
4
+ describe 'capture' do
5
+ describe 'errors' do
6
+ it 'raises a same square error' do
7
+ -> { Sashite::PAN::Capture.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::Capture.new '42', 43 }.must_raise TypeError
12
+ end
13
+
14
+ it 'raises a type error from the destination square' do
15
+ -> { Sashite::PAN::Capture.new 42, '43' }.must_raise TypeError
16
+ end
17
+ end
18
+
19
+ describe 'instances' do
20
+ before do
21
+ @action = Sashite::PAN.load :capture, 42, 43
22
+ end
23
+
24
+ it 'returns the action' do
25
+ @action.to_a.must_equal [ :capture, 42, 43 ]
26
+ end
27
+
28
+ it 'returns the action (once again)' do
29
+ @action.to_a.must_equal Sashite::PAN::Capture.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
data/test/test_drop.rb ADDED
@@ -0,0 +1,37 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::PAN do
4
+ describe 'drops' do
5
+ describe 'errors' do
6
+ it 'raises a type error from the actor' do
7
+ -> { Sashite::PAN.load :drop, 'foobar', 42 }.must_raise TypeError
8
+ end
9
+
10
+ it 'raises a type error from the destination square' do
11
+ -> { Sashite::PAN.load :drop, :foobar, '42' }.must_raise TypeError
12
+ end
13
+ end
14
+
15
+ describe 'instances' do
16
+ before do
17
+ @action = Sashite::PAN.load :drop, :foobar, 42
18
+ end
19
+
20
+ it 'returns the action' do
21
+ @action.to_a.must_equal [ :drop, :foobar, 42 ]
22
+ end
23
+
24
+ it 'returns the action (once again)' do
25
+ @action.to_a.must_equal Sashite::PAN::Drop.new(:foobar, 42).to_a
26
+ end
27
+
28
+ it 'returns the actor of the action' do
29
+ @action.actor.must_equal :foobar
30
+ end
31
+
32
+ it 'returns the dst_square of the action' do
33
+ @action.dst_square.must_equal 42
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::PAN do
4
+ describe 'errors' do
5
+ it 'raises a not implemented method error' do
6
+ -> { Sashite::PAN.load :foobar, 42, 43 }.must_raise Sashite::PAN::NotImplementedVerbError
7
+ end
8
+ end
9
+ end
data/test/test_pan.rb ADDED
@@ -0,0 +1,9 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::PAN do
4
+ describe 'errors' do
5
+ it 'raises a not implemented method error' do
6
+ -> { Sashite::PAN.load :foobar, 42, 43 }.must_raise Sashite::PAN::NotImplementedVerbError
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::PAN do
4
+ describe 'promotion' do
5
+ describe 'errors' do
6
+ it 'raises a type error from the source square' do
7
+ -> { Sashite::PAN.load :promote, '42', :foobar }.must_raise TypeError
8
+ end
9
+
10
+ it 'raises a type error from the actor' do
11
+ -> { Sashite::PAN.load :promote, 42, 'foobar' }.must_raise TypeError
12
+ end
13
+ end
14
+
15
+ describe 'instances' do
16
+ before do
17
+ @action = Sashite::PAN.load :promote, 42, :foobar
18
+ end
19
+
20
+ it 'returns the action' do
21
+ @action.to_a.must_equal [ :promote, 42, :foobar ]
22
+ end
23
+
24
+ it 'returns the action (once again)' do
25
+ @action.to_a.must_equal Sashite::PAN::Promote.new(42, :foobar).to_a
26
+ end
27
+
28
+ it 'returns the src_square of the action' do
29
+ @action.src_square.must_equal 42
30
+ end
31
+
32
+ it 'returns the actor of the action' do
33
+ @action.actor.must_equal :foobar
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,41 @@
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
@@ -0,0 +1,41 @@
1
+ require_relative '_test_helper'
2
+
3
+ describe Sashite::PAN do
4
+ describe 'shift' do
5
+ describe 'errors' do
6
+ it 'raises a same square error' do
7
+ -> { Sashite::PAN::Shift.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::Shift.new '42', 43 }.must_raise TypeError
12
+ end
13
+
14
+ it 'raises a type error from the destination square' do
15
+ -> { Sashite::PAN::Shift.new 42, '43' }.must_raise TypeError
16
+ end
17
+ end
18
+
19
+ describe 'instances' do
20
+ before do
21
+ @action = Sashite::PAN.load :shift, 42, 43
22
+ end
23
+
24
+ it 'returns the action' do
25
+ @action.to_a.must_equal [ :shift, 42, 43 ]
26
+ end
27
+
28
+ it 'returns the action (once again)' do
29
+ @action.to_a.must_equal Sashite::PAN::Shift.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
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sashite-pan
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-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10'
55
+ description: A Portable Action Notation (PAN) parser and emitter, optimized for programmer
56
+ happiness.
57
+ email:
58
+ - contact@cyril.io
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".ruby-version"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.md
68
+ - README.md
69
+ - Rakefile
70
+ - VERSION.semver
71
+ - lib/sashite/pan.rb
72
+ - lib/sashite/pan/capture.rb
73
+ - lib/sashite/pan/drop.rb
74
+ - lib/sashite/pan/error/not_implemented_verb_error.rb
75
+ - lib/sashite/pan/error/same_square_error.rb
76
+ - lib/sashite/pan/promote.rb
77
+ - lib/sashite/pan/remove.rb
78
+ - lib/sashite/pan/shift.rb
79
+ - sashite-pan.gemspec
80
+ - test/_test_helper.rb
81
+ - test/test_capture.rb
82
+ - test/test_drop.rb
83
+ - test/test_movement.rb.rb
84
+ - test/test_pan.rb
85
+ - test/test_promote.rb
86
+ - test/test_remove.rb
87
+ - test/test_shift.rb
88
+ homepage: https://github.com/sashite/pan.rb
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.2.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Portable Action Notation (PAN) parser and emitter.
112
+ test_files:
113
+ - test/_test_helper.rb
114
+ - test/test_capture.rb
115
+ - test/test_drop.rb
116
+ - test/test_movement.rb.rb
117
+ - test/test_pan.rb
118
+ - test/test_promote.rb
119
+ - test/test_remove.rb
120
+ - test/test_shift.rb