qi 5.1.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b71cc8f8f8249bea5ddb1b585a4fa0d114641ff9
4
- data.tar.gz: 50c20bbcc0cce557118d7c805280b1e006b1976f
2
+ SHA256:
3
+ metadata.gz: ea547ce94942f087213cf6a85465a231347e2cbd1805b5be7ebbe108d5cdd304
4
+ data.tar.gz: '00529deb18f2658355d4bf8dd6955e3bf4469047164b872dea91ff3ea61f1841'
5
5
  SHA512:
6
- metadata.gz: b0ca154a36dfb588f6a29b3e092e62cd21a7feb1d4b5fe46ca4101fb7018afa84d35c6449e3d1071159658a90397a4643e607e39c94fa0d0e7f863cbf2daf784
7
- data.tar.gz: f13fbe0ba4b0a1d80267fc5747e40aa78ab41031709cb7b627ddf39a6c6b7942add34a16e38e2f54975fe4fe95bbee3e8f7141df0545b1c7ba0ced6adcb82efb
6
+ metadata.gz: d46dd80b15e18ba16a3c4ea6c9d8a479e9f2f044e5b776c34c5152e80903c9e4aa806ee603c448334fdc10fcea995a710b33b30488ebf199a1c56e559065e95b
7
+ data.tar.gz: f905c0750db19eda558dae0e8bcab054f180f4f21997f6896426330d64f10404c8cc63b08557a4e9c0d5fd264861fe3e933a6b23be3d418851f31abe1787481d
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Cyril Wack
3
+ Copyright (c) 2015-2020 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,24 +1,19 @@
1
1
  # Qi
2
2
 
3
- [![Build Status](https://travis-ci.org/cyril/qi.rb.svg?branch=master)][travis]
4
- [![Code Climate](https://codeclimate.com/github/cyril/qi.rb/badges/gpa.svg)][codeclimate]
3
+ [![Build Status](https://api.travis-ci.org/sashite/qi.rb.svg?branch=master)][travis]
5
4
  [![Gem Version](https://badge.fury.io/rb/qi.svg)][gem]
6
- [![Inline docs](http://inch-ci.org/github/cyril/qi.rb.svg?branch=master)][inchpages]
7
- [![Documentation](http://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
5
+ [![Inline docs](https://inch-ci.org/github/sashite/qi.rb.svg?branch=master)][inchpages]
6
+ [![Documentation](https://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
8
7
 
9
- > An ordered store of stuff to manage, for Ruby.
10
-
11
- ## Rubies
12
-
13
- * [MRI](https://www.ruby-lang.org/)
14
- * [Rubinius](http://rubini.us/)
15
- * [JRuby](http://jruby.org/)
8
+ > Instantiate [Portable Chess Notation](https://developer.sashite.com/specs/portable-chess-notation)'s positions and apply [Portable Move Notation](https://developer.sashite.com/specs/portable-move-notation)'s moves.
16
9
 
17
10
  ## Installation
18
11
 
19
12
  Add this line to your application's Gemfile:
20
13
 
21
- gem 'qi'
14
+ ```ruby
15
+ gem 'qi'
16
+ ```
22
17
 
23
18
  And then execute:
24
19
 
@@ -30,34 +25,64 @@ Or install it yourself as:
30
25
 
31
26
  ## Example
32
27
 
28
+ Let's replay [The Shortest Possible Game of Shogi](https://userpages.monmouth.com/~colonel/shortshogi.html):
29
+
33
30
  ```ruby
34
31
  require 'qi'
35
32
 
36
- db = Qi::Store.new(8) # => #<Qi::Store:0x007fb79f09b8d0 @size=8, @captured=nil, @position={}>
37
-
38
- result = db.call(2, 3, 'p') # => #<Qi::Store:0x007fb79f091150 @size=8, @captured=nil, @position={3=>"p"}>
39
- result.to_a # => [nil, nil, nil, "p", nil, nil, nil, nil]
40
- result.captured # => nil
33
+ shogi_starting_position = Qi::Position.new(
34
+ 'l', 'n', 's', 'g', 'k', 'g', 's', 'n', 'l',
35
+ nil, 'r', nil, nil, nil, nil, nil, 'b', nil,
36
+ 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p',
37
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
38
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
39
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
40
+ 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P',
41
+ nil, 'B', nil, nil, nil, nil, nil, 'R', nil,
42
+ 'L', 'N', 'S', 'G', 'K', 'G', 'S', 'N', 'L'
43
+ )
44
+
45
+ moves = [
46
+ [ 56, 47, 'P' ],
47
+ [ 3, 11, 'g' ],
48
+ [ 64, 24, '+B', 'P' ],
49
+ [ 5, 14, 'g' ],
50
+ [ 24, 14, '+B', 'G' ],
51
+ [ 4, 3, 'k' ],
52
+ [ nil, 13, 'G' ]
53
+ ]
54
+
55
+ last_position = moves.reduce(shogi_starting_position) do |position, move|
56
+ position.call(move)
57
+ end
58
+
59
+ last_position.topside_in_hand_pieces # => []
60
+
61
+ last_position.squares # => ["l", "n", "s", "k", nil, nil, "s", "n", "l",
62
+ # nil, "r", "g", nil, "G", "+B", nil, "b", nil,
63
+ # "p", "p", "p", "p", "p", "p", nil, "p", "p",
64
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
65
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
66
+ # nil, nil, "P", nil, nil, nil, nil, nil, nil,
67
+ # "P", "P", nil, "P", "P", "P", "P", "P", "P",
68
+ # nil, nil, nil, nil, nil, nil, nil, "R", nil,
69
+ # "L", "N", "S", "G", "K", "G", "S", "N", "L"]
70
+
71
+ last_position.bottomside_in_hand_pieces # => ["P"]
72
+ last_position.turn_to_topside? # => true
41
73
  ```
42
74
 
43
- ## Versioning
44
-
45
- __Qi__ follows [Semantic Versioning 2.0](http://semver.org/).
75
+ ## License
46
76
 
47
- ## Contributing
77
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
78
 
49
- 1. [Fork it](https://github.com/cyril/qi.rb/fork)
50
- 2. Create your feature branch (`git checkout -b my-new-feature`)
51
- 3. Commit your changes (`git commit -am 'Add some feature'`)
52
- 4. Push to the branch (`git push origin my-new-feature`)
53
- 5. Create a new Pull Request
79
+ ## About Sashite
54
80
 
55
- ## License
81
+ The `qi` gem is maintained by [Sashite](https://sashite.com/).
56
82
 
57
- See `LICENSE.md` file.
83
+ With some [lines of code](https://github.com/sashite/), let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!
58
84
 
59
85
  [gem]: https://rubygems.org/gems/qi
60
- [travis]: https://travis-ci.org/cyril/qi.rb
61
- [codeclimate]: https://codeclimate.com/github/cyril/qi.rb
62
- [inchpages]: http://inch-ci.org/github/cyril/qi.rb
63
- [rubydoc]: http://rubydoc.info/gems/qi/frames
86
+ [travis]: https://travis-ci.org/sashite/qi.rb
87
+ [inchpages]: https://inch-ci.org/github/sashite/qi.rb
88
+ [rubydoc]: https://rubydoc.info/gems/qi/frames
data/lib/qi.rb CHANGED
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The Qi module.
1
4
  module Qi
2
5
  end
3
6
 
4
- require_relative File.join 'qi', 'store'
7
+ require_relative 'qi/position'
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Qi
4
+ # The position class.
5
+ #
6
+ # @see https://developer.sashite.com/specs/portable-chess-notation
7
+ class Position
8
+ attr_reader :squares, :bottomside_in_hand_pieces, :topside_in_hand_pieces
9
+
10
+ # Initialize a position.
11
+ #
12
+ # @param is_turn_to_topside [Boolean] The player who must play.
13
+ # @param bottomside_in_hand_pieces [Array] The list of bottom-side's pieces in hand.
14
+ # @param topside_in_hand_pieces [Array] The list of top-side's pieces in hand.
15
+ #
16
+ # @example The Shogi's starting position
17
+ # Position.new(
18
+ # 'l', 'n', 's', 'g', 'k', 'g', 's', 'n', 'l',
19
+ # nil, 'r', nil, nil, nil, nil, nil, 'b', nil,
20
+ # 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p',
21
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
22
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
23
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
24
+ # 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P',
25
+ # nil, 'B', nil, nil, nil, nil, nil, 'R', nil,
26
+ # 'L', 'N', 'S', 'G', 'K', 'G', 'S', 'N', 'L'
27
+ # )
28
+ def initialize(*squares, is_turn_to_topside: false, bottomside_in_hand_pieces: [], topside_in_hand_pieces: [])
29
+ @squares = squares
30
+ @is_turn_to_topside = is_turn_to_topside
31
+ @bottomside_in_hand_pieces = bottomside_in_hand_pieces
32
+ @topside_in_hand_pieces = topside_in_hand_pieces
33
+
34
+ freeze
35
+ end
36
+
37
+ # Apply a move in PMN (Portable Move Notation) format.
38
+ #
39
+ # @see https://developer.sashite.com/specs/portable-move-notation
40
+ # @return [Position] The new position.
41
+ def call(move)
42
+ updated_squares = squares.dup
43
+ updated_bottomside_in_hand_pieces = bottomside_in_hand_pieces.dup
44
+ updated_topside_in_hand_pieces = topside_in_hand_pieces.dup
45
+
46
+ actions = move.each_slice(4)
47
+
48
+ actions.each do |action|
49
+ src_square_id = action.fetch(0)
50
+ dst_square_id = action.fetch(1)
51
+ moved_piece_name = action.fetch(2)
52
+ captured_piece_name = action.fetch(3, nil)
53
+
54
+ if src_square_id.nil?
55
+ if turn_to_topside?
56
+ piece_in_hand_id = updated_topside_in_hand_pieces.index(moved_piece_name)
57
+ updated_topside_in_hand_pieces.delete_at(piece_in_hand_id)
58
+ else
59
+ piece_in_hand_id = updated_bottomside_in_hand_pieces.index(moved_piece_name)
60
+ updated_bottomside_in_hand_pieces.delete_at(piece_in_hand_id)
61
+ end
62
+ else
63
+ updated_squares[src_square_id] = nil
64
+ end
65
+
66
+ updated_squares[dst_square_id] = moved_piece_name
67
+
68
+ unless captured_piece_name.nil?
69
+ if turn_to_topside?
70
+ updated_topside_in_hand_pieces.push(captured_piece_name)
71
+ else
72
+ updated_bottomside_in_hand_pieces.push(captured_piece_name)
73
+ end
74
+ end
75
+ end
76
+
77
+ self.class.new(*updated_squares, is_turn_to_topside: !turn_to_topside?,
78
+ bottomside_in_hand_pieces: updated_bottomside_in_hand_pieces,
79
+ topside_in_hand_pieces: updated_topside_in_hand_pieces)
80
+ end
81
+
82
+ # The player who must play.
83
+ #
84
+ # @return [Boolean] True if it is turn to topside, false otherwise.
85
+ def turn_to_topside?
86
+ @is_turn_to_topside
87
+ end
88
+ end
89
+ end
metadata CHANGED
@@ -1,132 +1,144 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qi
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2020-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: brutal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - "~>"
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: '1.15'
33
+ version: '0'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - "~>"
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: '1.15'
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '12.0'
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '12.0'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: yard
56
+ name: rubocop
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - '='
46
60
  - !ruby/object:Gem::Version
47
- version: '0.9'
61
+ version: 0.86.0
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - '='
53
67
  - !ruby/object:Gem::Version
54
- version: '0.9'
68
+ version: 0.86.0
55
69
  - !ruby/object:Gem::Dependency
56
- name: simplecov
70
+ name: rubocop-performance
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '0.14'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '0.14'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rubocop
84
+ name: rubocop-thread_safety
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - "~>"
101
+ - - ">="
74
102
  - !ruby/object:Gem::Version
75
- version: '0.49'
103
+ version: '0'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - "~>"
108
+ - - ">="
81
109
  - !ruby/object:Gem::Version
82
- version: '0.49'
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
- name: fix
112
+ name: yard
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - "~>"
115
+ - - ">="
88
116
  - !ruby/object:Gem::Version
89
- version: '0.17'
117
+ version: '0'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - "~>"
122
+ - - ">="
95
123
  - !ruby/object:Gem::Version
96
- version: '0.17'
97
- description: An ordered store of stuff to manage, for Ruby.
98
- email:
99
- - contact@cyril.email
124
+ version: '0'
125
+ description: Instantiate PCN's positions and apply PMN's moves.
126
+ email: contact@cyril.email
100
127
  executables: []
101
128
  extensions: []
102
129
  extra_rdoc_files: []
103
130
  files:
104
- - ".gitignore"
105
- - ".travis.yml"
106
- - ".yardopts"
107
- - CODE_OF_CONDUCT.md
108
- - Gemfile
109
131
  - LICENSE.md
110
132
  - README.md
111
- - Rakefile
112
- - VERSION.semver
113
- - bin/console
114
- - bin/setup
115
- - checksum/qi-3.0.0.gem.sha512
116
- - checksum/qi-3.0.1.gem.sha512
117
- - checksum/qi-3.0.2.gem.sha512
118
- - checksum/qi-4.0.0.gem.sha512
119
- - checksum/qi-5.0.0.gem.sha512
120
- - fix/store_fix.rb
121
- - fix/support/coverage.rb
122
133
  - lib/qi.rb
123
- - lib/qi/store.rb
124
- - pkg_checksum
125
- - qi.gemspec
126
- homepage: https://github.com/cyril/qi.rb
134
+ - lib/qi/position.rb
135
+ homepage: https://developer.sashite.com/specs/
127
136
  licenses:
128
137
  - MIT
129
- metadata: {}
138
+ metadata:
139
+ bug_tracker_uri: https://github.com/sashite/qi.rb/issues
140
+ documentation_uri: https://rubydoc.info/gems/qi/index
141
+ source_code_uri: https://github.com/sashite/qi.rb
130
142
  post_install_message:
131
143
  rdoc_options: []
132
144
  require_paths:
@@ -142,9 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
154
  - !ruby/object:Gem::Version
143
155
  version: '0'
144
156
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.6.11
157
+ rubygems_version: 3.1.2
147
158
  signing_key:
148
159
  specification_version: 4
149
- summary: Store to manage ordered stuff.
160
+ summary: Represent positions and play moves.
150
161
  test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.ruby-version
3
- /.yardoc
4
- /Gemfile.lock
5
- /_yardoc/
6
- /coverage/
7
- /doc/
8
- /pkg/
9
- /spec/reports/
10
- /tmp/
@@ -1,15 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- script: 'bundle exec rake test:coverage --trace'
5
- before_install:
6
- - gem install bundler
7
- rvm:
8
- - 1.9.3
9
- - 2.0
10
- - 2.1
11
- - 2.2
12
- - ruby-head
13
- - jruby
14
- - jruby-head
15
- - rbx-2
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- - README.md
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
- require 'rubocop/rake_task'
4
-
5
- RuboCop::RakeTask.new
6
-
7
- Rake::TestTask.new do |t|
8
- t.verbose = true
9
- t.warning = true
10
- t.pattern = File.join('fix', '**', '*_fix.rb')
11
- end
12
-
13
- namespace :test do
14
- task :coverage do
15
- ENV['COVERAGE'] = 'true'
16
- Rake::Task['test'].invoke
17
- end
18
- end
19
-
20
- task(:doc_stats) { ruby '-S yard stats' }
21
- task default: %i[test doc_stats]
@@ -1 +0,0 @@
1
- 5.1.0
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'qi'
5
-
6
- require 'irb'
7
- IRB.start
data/bin/setup DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
@@ -1 +0,0 @@
1
- 7a4d1c15b8214a9eb475ed919ac4fcaf4b3a9aab5936b1522cbb801b243a649f95d23f42584c0fbad7f4a2ab71efaab9e6b030496a2f7471c74f74986e0e620d
@@ -1 +0,0 @@
1
- 03a1a4eb9f239b817fcab338c15c652a47183c0d58a63c505df1f6a7011ef0d9f2c94bb51f25c5ac455536b5f649dcbaa7087c6033ffe35c4acf5265efa0f853
@@ -1 +0,0 @@
1
- bacf809a9ee2de6656c3180bd7200503004cfd3017472501854a6e73cab84fc02f37c1190fabc15d3f1ff7cedbc1a0ff5bae2391f4766b2d27819a57c8713661
@@ -1 +0,0 @@
1
- 957cae1db3b9f904922f3081fb482802ec8dc6867e3fc6a7d5fd8ba9c892246a53da7a7c9950464b40bd7777ed64f70aee727713292b62cc090dd68db724dcf7
@@ -1 +0,0 @@
1
- b4a7910e65556a19a74e0beffa3a00d05b38da150749ff73ea30df62aeaea2e6626a7680304a4bc62ccfd0850b6c948017e8ba4911b06adcd1162fa21b627a72
@@ -1,53 +0,0 @@
1
- require_relative File.join 'support', 'coverage'
2
- require_relative File.join '..', 'lib', 'qi'
3
- require 'fix'
4
-
5
- Fix.describe Qi::Store do
6
- on :new, 8 do
7
- on :to_a do
8
- it { MUST eql [nil, nil, nil, nil, nil, nil, nil, nil] }
9
- end
10
-
11
- on :call, 44, 3, 'p' do
12
- it { MUST raise_exception ArgumentError }
13
- end
14
-
15
- on :call, 2, 444, 'p' do
16
- it { MUST raise_exception ArgumentError }
17
- end
18
-
19
- on :captured do
20
- it { MUST be_nil }
21
- end
22
-
23
- on :call, 2, 3, 'p' do
24
- on :to_a do
25
- it { MUST eql [nil, nil, nil, 'p', nil, nil, nil, nil] }
26
- end
27
-
28
- on :captured do
29
- it { MUST be_nil }
30
- end
31
-
32
- on :call, 2, 4, 'K' do
33
- on :to_a do
34
- it { MUST eql [nil, nil, nil, 'p', 'K', nil, nil, nil] }
35
- end
36
-
37
- on :captured do
38
- it { MUST be_nil }
39
- end
40
-
41
- on :call, 3, 4, 'p' do
42
- on :to_a do
43
- it { MUST eql [nil, nil, nil, nil, 'p', nil, nil, nil] }
44
- end
45
-
46
- on :captured do
47
- it { MUST eql 'K' }
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end
@@ -1,3 +0,0 @@
1
- require 'simplecov'
2
-
3
- SimpleCov.start
@@ -1,41 +0,0 @@
1
- module Qi
2
- class Store
3
- attr_reader :size, :captured, :position
4
-
5
- def initialize(size, captured = nil, position = {})
6
- @size = Integer(size)
7
- @captured = captured
8
- @position = Hash(position).compact
9
- end
10
-
11
- def call(position_id, capture_position_id, content)
12
- position_id = Integer(position_id)
13
- capture_position_id = Integer(capture_position_id)
14
-
15
- [position_id, capture_position_id].each do |id|
16
- next if range.include?(id)
17
-
18
- raise ArgumentError, "#{id} out of range"
19
- end
20
-
21
- self.class.new(
22
- size,
23
- position[capture_position_id],
24
- position.merge(
25
- position_id => nil,
26
- capture_position_id => content
27
- )
28
- )
29
- end
30
-
31
- def to_a
32
- range.map { |i| position[i] }
33
- end
34
-
35
- protected
36
-
37
- def range
38
- 0...size
39
- end
40
- end
41
- end
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'digest/sha2'
4
-
5
- gemname = :qi
6
- ARGV[0] = File.read('VERSION.semver').chomp if ARGV[0].nil?
7
- built_gem_path = "pkg/#{gemname}-#{ARGV[0]}.gem"
8
- checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
9
- checksum_path = "checksum/#{gemname}-#{ARGV[0]}.gem.sha512"
10
-
11
- File.open(checksum_path, 'w') { |f| f.write("#{checksum}\n") }
data/qi.gemspec DELETED
@@ -1,23 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = 'qi'
3
- spec.version = File.read('VERSION.semver').chomp
4
- spec.authors = ['Cyril Kato']
5
- spec.email = ['contact@cyril.email']
6
-
7
- spec.summary = 'Store to manage ordered stuff.'
8
- spec.description = 'An ordered store of stuff to manage, for Ruby.'
9
- spec.homepage = 'https://github.com/cyril/qi.rb'
10
- spec.license = 'MIT'
11
-
12
- spec.files =
13
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
14
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
- spec.require_paths = ['lib']
16
-
17
- spec.add_development_dependency 'bundler', '~> 1.15'
18
- spec.add_development_dependency 'rake', '~> 12.0'
19
- spec.add_development_dependency 'yard', '~> 0.9'
20
- spec.add_development_dependency 'simplecov', '~> 0.14'
21
- spec.add_development_dependency 'rubocop', '~> 0.49'
22
- spec.add_development_dependency 'fix', '~> 0.17'
23
- end