qi 5.0.0 → 5.1.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: c19af7d11b3ccf284b27da37e26488f9be22d4ed
4
- data.tar.gz: c7f9a5f9991da7cd645f5daf0c896f09056652eb
3
+ metadata.gz: b71cc8f8f8249bea5ddb1b585a4fa0d114641ff9
4
+ data.tar.gz: 50c20bbcc0cce557118d7c805280b1e006b1976f
5
5
  SHA512:
6
- metadata.gz: 9663fc03fdb5efd6f3e747dfb23e2c340fb90912d05b9cf83449c10c0b3b0ec7bcf3e258ff0eda3d5a9fefd217bc6863bdc93f50917e259ca58c13e8e1c01fe3
7
- data.tar.gz: dcf383cac108d85104c0bb4287ad5a1986f509e9e30989396d8ad7bddbbb3d13933f96d95a7f71cdf09c50a1f7a73797a70f9a9ae755b98d6ad66a7e281436f7
6
+ metadata.gz: b0ca154a36dfb588f6a29b3e092e62cd21a7feb1d4b5fe46ca4101fb7018afa84d35c6449e3d1071159658a90397a4643e607e39c94fa0d0e7f863cbf2daf784
7
+ data.tar.gz: f13fbe0ba4b0a1d80267fc5747e40aa78ab41031709cb7b627ddf39a6c6b7942add34a16e38e2f54975fe4fe95bbee3e8f7141df0545b1c7ba0ced6adcb82efb
data/README.md CHANGED
@@ -33,11 +33,11 @@ Or install it yourself as:
33
33
  ```ruby
34
34
  require 'qi'
35
35
 
36
- db = Qi::Store.new(8) # => #<Qi::Store:0x007f82129493c8 @cells=[nil, nil, nil, nil, nil, nil, nil, nil], @deleted_content=nil>
36
+ db = Qi::Store.new(8) # => #<Qi::Store:0x007fb79f09b8d0 @size=8, @captured=nil, @position={}>
37
37
 
38
- result = db.call(2, 3, 'p') # => #<Qi::Store:0x007f821293a170 @cells=[nil, nil, nil, "p", nil, nil, nil, nil], @deleted_content=nil>
39
- result.store.cells # => [nil, nil, nil, "p", nil, nil, nil, nil]
40
- result.deleted_content # => nil
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
41
41
  ```
42
42
 
43
43
  ## Versioning
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: %i[test doc_stats rubocop]
21
+ task default: %i[test doc_stats]
@@ -1 +1 @@
1
- 5.0.0
1
+ 5.1.0
@@ -0,0 +1 @@
1
+ b4a7910e65556a19a74e0beffa3a00d05b38da150749ff73ea30df62aeaea2e6626a7680304a4bc62ccfd0850b6c948017e8ba4911b06adcd1162fa21b627a72
@@ -8,6 +8,14 @@ Fix.describe Qi::Store do
8
8
  it { MUST eql [nil, nil, nil, nil, nil, nil, nil, nil] }
9
9
  end
10
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
+
11
19
  on :captured do
12
20
  it { MUST be_nil }
13
21
  end
@@ -5,24 +5,37 @@ module Qi
5
5
  def initialize(size, captured = nil, position = {})
6
6
  @size = Integer(size)
7
7
  @captured = captured
8
- @position = Hash(position.compact)
9
-
10
- freeze
8
+ @position = Hash(position).compact
11
9
  end
12
10
 
13
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
+
14
21
  self.class.new(
15
22
  size,
16
23
  position[capture_position_id],
17
24
  position.merge(
18
- Integer(position_id) => nil,
19
- Integer(capture_position_id) => content
25
+ position_id => nil,
26
+ capture_position_id => content
20
27
  )
21
28
  )
22
29
  end
23
30
 
24
31
  def to_a
25
- (0...size).map { |i| position[i] }
32
+ range.map { |i| position[i] }
33
+ end
34
+
35
+ protected
36
+
37
+ def range
38
+ 0...size
26
39
  end
27
40
  end
28
41
  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: 5.0.0
4
+ version: 5.1.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-05 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -116,6 +116,7 @@ files:
116
116
  - checksum/qi-3.0.1.gem.sha512
117
117
  - checksum/qi-3.0.2.gem.sha512
118
118
  - checksum/qi-4.0.0.gem.sha512
119
+ - checksum/qi-5.0.0.gem.sha512
119
120
  - fix/store_fix.rb
120
121
  - fix/support/coverage.rb
121
122
  - lib/qi.rb