qi 4.0.0 → 5.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
2
  SHA1:
3
- metadata.gz: db34cbc61e929eb607b58f1682028288ad54d300
4
- data.tar.gz: 19997a2b81da2b4446068f94a3a641e4e9dc3e21
3
+ metadata.gz: c19af7d11b3ccf284b27da37e26488f9be22d4ed
4
+ data.tar.gz: c7f9a5f9991da7cd645f5daf0c896f09056652eb
5
5
  SHA512:
6
- metadata.gz: e7c53440130286c9518f74938bf5848bb5834d190eb7a7bcdedc2a098d3b96cb99e4832406ca1b3e81b57bee9614744259bf4b568f6f82cf16f3190482f56d5c
7
- data.tar.gz: ea38865a74444eb17142be9f4c9580da94ec2a07e1f7ef005c3c39f1158b3c00732b2b8def2b690a99746030e33268e6755683fba00abc3b051500ba2df61277
6
+ metadata.gz: 9663fc03fdb5efd6f3e747dfb23e2c340fb90912d05b9cf83449c10c0b3b0ec7bcf3e258ff0eda3d5a9fefd217bc6863bdc93f50917e259ca58c13e8e1c01fe3
7
+ data.tar.gz: dcf383cac108d85104c0bb4287ad5a1986f509e9e30989396d8ad7bddbbb3d13933f96d95a7f71cdf09c50a1f7a73797a70f9a9ae755b98d6ad66a7e281436f7
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Qi
2
2
 
3
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]
4
5
  [![Gem Version](https://badge.fury.io/rb/qi.svg)][gem]
5
6
  [![Inline docs](http://inch-ci.org/github/cyril/qi.rb.svg?branch=master)][inchpages]
6
7
  [![Documentation](http://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
@@ -57,5 +58,6 @@ See `LICENSE.md` file.
57
58
 
58
59
  [gem]: https://rubygems.org/gems/qi
59
60
  [travis]: https://travis-ci.org/cyril/qi.rb
60
- [inchpages]: http://inch-ci.org/github/cyril/qi.rb/
61
+ [codeclimate]: https://codeclimate.com/github/cyril/qi.rb
62
+ [inchpages]: http://inch-ci.org/github/cyril/qi.rb
61
63
  [rubydoc]: http://rubydoc.info/gems/qi/frames
data/Rakefile CHANGED
@@ -18,4 +18,4 @@ namespace :test do
18
18
  end
19
19
 
20
20
  task(:doc_stats) { ruby '-S yard stats' }
21
- task default: [:test, :doc_stats, :rubocop]
21
+ task default: %i[test doc_stats rubocop]
@@ -1 +1 @@
1
- 4.0.0
1
+ 5.0.0
@@ -0,0 +1 @@
1
+ 957cae1db3b9f904922f3081fb482802ec8dc6867e3fc6a7d5fd8ba9c892246a53da7a7c9950464b40bd7777ed64f70aee727713292b62cc090dd68db724dcf7
@@ -4,38 +4,38 @@ require 'fix'
4
4
 
5
5
  Fix.describe Qi::Store do
6
6
  on :new, 8 do
7
- on :cells do
7
+ on :to_a do
8
8
  it { MUST eql [nil, nil, nil, nil, nil, nil, nil, nil] }
9
9
  end
10
10
 
11
- on :deleted_content do
11
+ on :captured do
12
12
  it { MUST be_nil }
13
13
  end
14
14
 
15
15
  on :call, 2, 3, 'p' do
16
- on :cells do
16
+ on :to_a do
17
17
  it { MUST eql [nil, nil, nil, 'p', nil, nil, nil, nil] }
18
18
  end
19
19
 
20
- on :deleted_content do
20
+ on :captured do
21
21
  it { MUST be_nil }
22
22
  end
23
23
 
24
24
  on :call, 2, 4, 'K' do
25
- on :cells do
25
+ on :to_a do
26
26
  it { MUST eql [nil, nil, nil, 'p', 'K', nil, nil, nil] }
27
27
  end
28
28
 
29
- on :deleted_content do
29
+ on :captured do
30
30
  it { MUST be_nil }
31
31
  end
32
32
 
33
33
  on :call, 3, 4, 'p' do
34
- on :cells do
34
+ on :to_a do
35
35
  it { MUST eql [nil, nil, nil, nil, 'p', nil, nil, nil] }
36
36
  end
37
37
 
38
- on :deleted_content do
38
+ on :captured do
39
39
  it { MUST eql 'K' }
40
40
  end
41
41
  end
data/lib/qi.rb CHANGED
@@ -1,4 +1,3 @@
1
- # Namespace for the library.
2
1
  module Qi
3
2
  end
4
3
 
@@ -1,50 +1,28 @@
1
1
  module Qi
2
- # Main class.
3
2
  class Store
4
- # @example Instanciate a store with 88 cells.
5
- # new(88)
6
- #
7
- # @param size [Fixnum] The number of cell.
8
- # @param deleted_content [Object, nil] Deleted content.
9
- # @param options [Hash] A content per cell.
10
- def initialize(size, deleted_content = nil, options = {})
11
- @cells = Array.new(size)
12
- @deleted_content = deleted_content
3
+ attr_reader :size, :captured, :position
13
4
 
14
- options.each do |cell, piece|
15
- @cells[cell] = piece
16
- end
17
- end
18
-
19
- # @!attribute [r] cells
20
- #
21
- # @return [Array] The cells in the store.
22
- attr_reader :cells
23
-
24
- # @!attribute [r] deleted_content
25
- #
26
- # @return [Object, nil] Deleted content.
27
- attr_reader :deleted_content
5
+ def initialize(size, captured = nil, position = {})
6
+ @size = Integer(size)
7
+ @captured = captured
8
+ @position = Hash(position.compact)
28
9
 
29
- # @param src_cell [Fixnum] Source cell.
30
- # @param dst_cell [Fixnum] Destination cell.
31
- # @param content [Object] Content.
32
- #
33
- # @return [Store] The new store.
34
- def call(src_cell, dst_cell, content)
35
- h = contents
36
- h.delete(src_cell)
37
- deleted_content = h.delete(dst_cell)
38
- h[dst_cell] = content
39
-
40
- self.class.new(cells.length, deleted_content, h)
10
+ freeze
41
11
  end
42
12
 
43
- private
13
+ def call(position_id, capture_position_id, content)
14
+ self.class.new(
15
+ size,
16
+ position[capture_position_id],
17
+ position.merge(
18
+ Integer(position_id) => nil,
19
+ Integer(capture_position_id) => content
20
+ )
21
+ )
22
+ end
44
23
 
45
- # @return [Hash] The contents in the store.
46
- def contents
47
- Hash[[*cells.map.with_index]].invert
24
+ def to_a
25
+ (0...size).map { |i| position[i] }
48
26
  end
49
27
  end
50
28
  end
data/qi.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'qi'
3
3
  spec.version = File.read('VERSION.semver').chomp
4
- spec.authors = ['Cyril Wack']
4
+ spec.authors = ['Cyril Kato']
5
5
  spec.email = ['contact@cyril.email']
6
6
 
7
7
  spec.summary = 'Store to manage ordered stuff.'
@@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
14
14
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
15
  spec.require_paths = ['lib']
16
16
 
17
- spec.add_development_dependency 'bundler', '~> 1.10'
18
- spec.add_development_dependency 'rake', '~> 10.4'
19
- spec.add_development_dependency 'yard', '~> 0.8'
20
- spec.add_development_dependency 'simplecov', '~> 0.10'
21
- spec.add_development_dependency 'rubocop', '~> 0.34'
22
- spec.add_development_dependency 'fix', '~> 0.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
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qi
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Cyril Wack
7
+ - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-07 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,84 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '1.15'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '1.15'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.4'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.4'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: yard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.8'
47
+ version: '0.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.8'
54
+ version: '0.9'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.10'
61
+ version: '0.14'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.10'
68
+ version: '0.14'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.34'
75
+ version: '0.49'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.34'
82
+ version: '0.49'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: fix
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.16'
89
+ version: '0.17'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.16'
96
+ version: '0.17'
97
97
  description: An ordered store of stuff to manage, for Ruby.
98
98
  email:
99
99
  - contact@cyril.email
@@ -115,6 +115,7 @@ files:
115
115
  - checksum/qi-3.0.0.gem.sha512
116
116
  - checksum/qi-3.0.1.gem.sha512
117
117
  - checksum/qi-3.0.2.gem.sha512
118
+ - checksum/qi-4.0.0.gem.sha512
118
119
  - fix/store_fix.rb
119
120
  - fix/support/coverage.rb
120
121
  - lib/qi.rb
@@ -141,9 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  version: '0'
142
143
  requirements: []
143
144
  rubyforge_project:
144
- rubygems_version: 2.4.5.1
145
+ rubygems_version: 2.6.11
145
146
  signing_key:
146
147
  specification_version: 4
147
148
  summary: Store to manage ordered stuff.
148
149
  test_files: []
149
- has_rdoc: