collectr 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/collectr.gemspec +1 -1
- data/lib/bag.rb +4 -1
- data/lib/collectr/version.rb +1 -1
- data/spec/bag_spec.rb +24 -0
- data/spec/hash_spec.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d729df6dad12da0f9a37520c150d6ddbdb17f0
|
4
|
+
data.tar.gz: a8d13216fd9fdd85cccb1b2c4d4a0681213684da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0acf26c68a25e7905da007339d834a6df6371542b2558868a4fac0ddb09e2a732d260b977a04732eec20f630a840838be10f1af7e06afdf498aad74494ea51c
|
7
|
+
data.tar.gz: fc973ab5d3b28b910d25a7c025ad8fac8472f9c9268a77c11f6d2a3db6c4f5f9d4ddc50e8ab8c2e6cdd57413a52dde5bc8d57b97111b50dc068da11a362eca55
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
[](https://travis-ci.org/brianmd/collectr) [](http://badge.fury.io/rb/collectr) [](https://coveralls.io/github/brianmd/collectr?branch=master)
|
1
2
|
# Collectr
|
2
3
|
|
3
|
-
|
4
|
+
Abstraction for thread-safe collections (array, hash, set, bag).
|
5
|
+
|
6
|
+
Once it is fleshed out, will include complete abstractions for redis and memory.
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
data/collectr.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Collectr::VERSION
|
9
9
|
spec.authors = ["Brian Murphy-Dye"]
|
10
10
|
spec.email = ["brian@murphydye.com"]
|
11
|
-
spec.summary = %q{Abstraction thread-safe collections (array, hash, set, bag).}
|
11
|
+
spec.summary = %q{Abstraction for thread-safe collections (array, hash, set, bag).}
|
12
12
|
spec.description = %q{}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
data/lib/bag.rb
CHANGED
data/lib/collectr/version.rb
CHANGED
data/spec/bag_spec.rb
CHANGED
@@ -4,15 +4,39 @@ require 'bag'
|
|
4
4
|
describe Bag do
|
5
5
|
subject(:bag) { Bag.new }
|
6
6
|
|
7
|
+
it 'handles empty bag' do
|
8
|
+
expect(bag).to be_empty
|
9
|
+
expect(bag.size).to eq(0)
|
10
|
+
expect(bag.count).to eq(0)
|
11
|
+
expect(bag.bag).to eq({})
|
12
|
+
expect(bag.as_sorted_counts).to eq([])
|
13
|
+
end
|
14
|
+
|
7
15
|
it 'handles repetitions' do
|
8
16
|
bag << 1 << 1 << 2 << 1 << 'a'
|
9
17
|
expect(bag.keys).to eq([1,2,'a'])
|
10
18
|
end
|
11
19
|
|
20
|
+
it 'clones well' do
|
21
|
+
bag << 1 << 1 << 2 << 1 << 'a'
|
22
|
+
new_bag = bag.clone
|
23
|
+
expect( bag.as_sorted_counts).to eq([[1,3],[2,1],['a',1]])
|
24
|
+
expect(new_bag.as_sorted_counts).to eq([[1,3],[2,1],['a',1]])
|
25
|
+
bag << 'a'
|
26
|
+
expect( bag.as_sorted_counts).to eq([[1,3],['a',2],[2,1]])
|
27
|
+
expect(new_bag.as_sorted_counts).to eq([[1,3],[2,1],['a',1]])
|
28
|
+
end
|
29
|
+
|
12
30
|
it 'handles #each' do
|
13
31
|
bag << 1 << 1 << 2 << 1 << 'a'
|
14
32
|
hash = {}
|
15
33
|
bag.each{ |key,val| hash[key] = val }
|
34
|
+
expect(bag.size).to eq(3)
|
35
|
+
expect(bag.count).to eq(5)
|
16
36
|
expect(hash).to eq({1=>3, 2=>1, 'a'=>1})
|
37
|
+
expect(bag[1]).to eq(3)
|
38
|
+
expect(bag['a']).to eq(1)
|
39
|
+
expect(bag.bag).to eq(hash)
|
40
|
+
expect(bag.as_sorted_counts).to eq([[1,3],[2,1],['a',1]])
|
17
41
|
end
|
18
42
|
end
|
data/spec/hash_spec.rb
CHANGED
@@ -17,7 +17,10 @@ shared_examples 'a hash' do
|
|
17
17
|
context 'after an item is added' do
|
18
18
|
before { collection.clear ; collection[1] = 'a1' }
|
19
19
|
it { expect(collection.size).to eq(1) }
|
20
|
+
it { expect(collection.key?(1)).to be true }
|
21
|
+
it { expect(collection.has_key?(1)).to be true }
|
20
22
|
it { expect(collection[1]).to eq('a1') }
|
23
|
+
it { collection.delete(1); expect(collection.size).to eq(0) }
|
21
24
|
end
|
22
25
|
|
23
26
|
context 'after multiple items are added' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collectr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Murphy-Dye
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -246,7 +246,7 @@ rubyforge_project:
|
|
246
246
|
rubygems_version: 2.4.8
|
247
247
|
signing_key:
|
248
248
|
specification_version: 4
|
249
|
-
summary: Abstraction thread-safe collections (array, hash, set, bag).
|
249
|
+
summary: Abstraction for thread-safe collections (array, hash, set, bag).
|
250
250
|
test_files:
|
251
251
|
- spec/bag_spec.rb
|
252
252
|
- spec/hash_spec.rb
|