cranium 0.4.1 → 0.4.2
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/cranium.gemspec +1 -1
- data/lib/cranium/dimension_manager.rb +2 -1
- data/spec/cranium/dimension_manager_spec.rb +17 -12
- 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: 5b878ec72b1afbd62b6d0c576653c4d5e5b1a0ee
|
4
|
+
data.tar.gz: 41b765f1e0cf25648cf30cee548555b7f0ffaaaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b52aa636e49d51d48fc86397330527fe31c40214a055ef7c405befe1e5b53fe255064259de4857a57e0b8374ae111ce5e66a3d677878b010502f5d8faadc9f3d
|
7
|
+
data.tar.gz: 98d0e5a309f127c50e7910c5510908dfb5e71a6f4f347f804c0118bb21a680bf45fb64b059b30866febb81e827dac8f65ea95a2830ea3826927d47e54f773c68
|
data/cranium.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'cranium'
|
3
|
-
spec.version = '0.4.
|
3
|
+
spec.version = '0.4.2'
|
4
4
|
spec.authors = ['Emarsys Technologies']
|
5
5
|
spec.email = ['smart-insight-dev@emarsys.com']
|
6
6
|
spec.description = %q{Provides Extract, Transform and Load functionality for loading data from CSV files to a Greenplum database.}
|
@@ -30,7 +30,8 @@ class Cranium::DimensionManager
|
|
30
30
|
|
31
31
|
|
32
32
|
def create_cache_for_field(value_field)
|
33
|
-
|
33
|
+
fields = @key_fields + [value_field]
|
34
|
+
to_multi_key_cache(db.select(*fields).group(*fields).map &:values)
|
34
35
|
end
|
35
36
|
|
36
37
|
|
@@ -34,28 +34,33 @@ describe Cranium::DimensionManager do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "#create_cache_for_field" do
|
37
|
+
let(:manager) { Cranium::DimensionManager.new :table, keys }
|
38
|
+
|
39
|
+
before do
|
40
|
+
database = double("Database connection")
|
41
|
+
query = double
|
42
|
+
allow(manager).to receive(:db).and_return database
|
43
|
+
allow(database).to receive(:select).with(*(keys + [:value_field])).and_return query
|
44
|
+
allow(query).to receive(:group).with(*(keys + [:value_field])).and_return dataset
|
45
|
+
end
|
46
|
+
|
37
47
|
context "with single key" do
|
38
|
-
let(:
|
48
|
+
let(:keys) { [:key] }
|
49
|
+
let(:dataset) { [{key: 1, value_field: 10},
|
50
|
+
{key: 2, value_field: 20}] }
|
39
51
|
|
40
52
|
it "should load key-value pairs into a hash" do
|
41
|
-
database = double("Database connection")
|
42
|
-
allow(manager).to receive(:db).and_return database
|
43
|
-
|
44
|
-
expect(database).to receive(:select_map).with([:key, :value_field]).and_return([[1, 10], [2, 20]])
|
45
|
-
|
46
53
|
expect(manager.create_cache_for_field(:value_field)).to eq [1] => 10, [2] => 20
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
50
57
|
context "with multiple keys" do
|
51
|
-
let(:
|
58
|
+
let(:keys) { [:key_1, :key_2] }
|
59
|
+
let(:dataset) { [{key_1: 1, key_2: 1, value_field: 11},
|
60
|
+
{key_1: 1, key_2: 2, value_field: 12},
|
61
|
+
{key_1: 2, key_2: 1, value_field: 21}] }
|
52
62
|
|
53
63
|
it "should load key-value pairs into a hash" do
|
54
|
-
database = double("Database connection")
|
55
|
-
allow(manager).to receive(:db).and_return database
|
56
|
-
|
57
|
-
expect(database).to receive(:select_map).with([:key_1, :key_2, :value_field]).and_return([[1, 1, 11], [1, 2, 12], [2, 1, 21]])
|
58
|
-
|
59
64
|
expect(manager.create_cache_for_field(:value_field)).to eq [1, 1] => 11, [1, 2] => 12, [2, 1] => 21
|
60
65
|
end
|
61
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cranium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emarsys Technologies
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -297,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
297
|
version: '0'
|
298
298
|
requirements: []
|
299
299
|
rubyforge_project:
|
300
|
-
rubygems_version: 2.
|
300
|
+
rubygems_version: 2.6.4
|
301
301
|
signing_key:
|
302
302
|
specification_version: 4
|
303
303
|
summary: Pure Ruby ETL framework
|