chicagowarehouse 0.3.2 → 0.3.3
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.
- data/Rakefile +1 -1
- data/chicagowarehouse.gemspec +2 -2
- data/lib/chicago/database/dataset_builder.rb +1 -1
- data/lib/chicago/database/schema_generator.rb +2 -2
- data/lib/chicago/schema/column.rb +1 -1
- data/lib/chicago/schema/dimension_reference.rb +7 -4
- data/spec/schema/dimension_reference_spec.rb +7 -4
- metadata +4 -4
data/Rakefile
CHANGED
|
@@ -14,7 +14,7 @@ require 'rake'
|
|
|
14
14
|
require 'jeweler'
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
|
16
16
|
gem.name = "chicagowarehouse"
|
|
17
|
-
gem.version = "0.3.
|
|
17
|
+
gem.version = "0.3.3"
|
|
18
18
|
gem.summary = "Ruby Data Warehousing"
|
|
19
19
|
gem.description = "Simple Data Warehouse toolkit for ruby"
|
|
20
20
|
gem.author = "Roland Swingler"
|
data/chicagowarehouse.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{chicagowarehouse}
|
|
8
|
-
s.version = "0.3.
|
|
8
|
+
s.version = "0.3.3"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = [%q{Roland Swingler}]
|
|
12
|
-
s.date = %q{2012-10-
|
|
12
|
+
s.date = %q{2012-10-30}
|
|
13
13
|
s.description = %q{Simple Data Warehouse toolkit for ruby}
|
|
14
14
|
s.email = %q{roland.swingler@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -66,7 +66,7 @@ module Chicago
|
|
|
66
66
|
|
|
67
67
|
unless to_join.empty?
|
|
68
68
|
@dataset = to_join.inject(@dataset) do |dataset, t|
|
|
69
|
-
dataset.join(t.table_name.as(t.name), :id => t.
|
|
69
|
+
dataset.join(t.table_name.as(t.name), :id => t.database_name.qualify(@base_table.name))
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
end
|
|
@@ -91,7 +91,7 @@ module Chicago
|
|
|
91
91
|
def indexes
|
|
92
92
|
indexes = @table.columns.select(&:indexed?).inject({}) do |hsh, d|
|
|
93
93
|
hsh.merge("#{d.name}_idx".to_sym => {
|
|
94
|
-
:columns => d.
|
|
94
|
+
:columns => d.database_name,
|
|
95
95
|
:unique => false})
|
|
96
96
|
end
|
|
97
97
|
indexes.merge!(natural_key_index) if @table.natural_key
|
|
@@ -109,7 +109,7 @@ module Chicago
|
|
|
109
109
|
|
|
110
110
|
def natural_key_index_columns
|
|
111
111
|
@table.natural_key.map do |name|
|
|
112
|
-
@table[name].
|
|
112
|
+
@table[name].database_name rescue raise MissingDefinitionError.new("Column #{name} is not defined in #{@table.name}")
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
end
|
|
@@ -9,8 +9,6 @@ module Chicago
|
|
|
9
9
|
extend Forwardable
|
|
10
10
|
|
|
11
11
|
def_delegators :@dimension, :columns, :column_definitions, :identifiers, :main_identifier, :identifiable?, :original_key, :natural_key, :table_name, :[], :key_table_name
|
|
12
|
-
|
|
13
|
-
attr_reader :key_name
|
|
14
12
|
|
|
15
13
|
def initialize(name, dimension, opts={})
|
|
16
14
|
super name, :integer, opts.merge(:min => 0)
|
|
@@ -19,9 +17,14 @@ module Chicago
|
|
|
19
17
|
@key_name = opts[:key_name] || "#{@name}_dimension_id".to_sym
|
|
20
18
|
end
|
|
21
19
|
|
|
20
|
+
# Returns the key name of this dimension.
|
|
21
|
+
def database_name
|
|
22
|
+
@key_name
|
|
23
|
+
end
|
|
24
|
+
|
|
22
25
|
def to_hash
|
|
23
26
|
hsh = super
|
|
24
|
-
hsh[:name] =
|
|
27
|
+
hsh[:name] = database_name
|
|
25
28
|
hsh
|
|
26
29
|
end
|
|
27
30
|
|
|
@@ -30,7 +33,7 @@ module Chicago
|
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
def qualify_by(table)
|
|
33
|
-
|
|
36
|
+
database_name.qualify(table)
|
|
34
37
|
end
|
|
35
38
|
|
|
36
39
|
# Returns the first null record id for this dimension, or 0 if
|
|
@@ -59,8 +59,9 @@ describe Chicago::Schema::DimensionReference do
|
|
|
59
59
|
described_class.new(:foo, @dimension).column_type.should == :integer
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
it "
|
|
63
|
-
described_class.new(:foo, @dimension).
|
|
62
|
+
it "has the key column as the database name" do
|
|
63
|
+
described_class.new(:foo, @dimension).database_name.
|
|
64
|
+
should == :foo_dimension_id
|
|
64
65
|
end
|
|
65
66
|
|
|
66
67
|
it "qualfies a column based on the column name" do
|
|
@@ -70,7 +71,8 @@ describe Chicago::Schema::DimensionReference do
|
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
it "can be qualified, and qualifies the key name" do
|
|
73
|
-
described_class.new(:foo, @dimension).qualify_by(:facts_bar).
|
|
74
|
+
described_class.new(:foo, @dimension).qualify_by(:facts_bar).
|
|
75
|
+
should == :foo_dimension_id.qualify(:facts_bar)
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
it "should be considered a kind of dimension" do
|
|
@@ -78,7 +80,8 @@ describe Chicago::Schema::DimensionReference do
|
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
it "can override the key selected as the reference" do
|
|
81
|
-
described_class.new(:foo, @dimension, :key_name => :baz_dimension_id).
|
|
83
|
+
described_class.new(:foo, @dimension, :key_name => :baz_dimension_id).
|
|
84
|
+
database_name.should ==:baz_dimension_id
|
|
82
85
|
end
|
|
83
86
|
|
|
84
87
|
it "uses the first null record id as the default value" do
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chicagowarehouse
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 21
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 3
|
|
9
|
-
-
|
|
10
|
-
version: 0.3.
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.3.3
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Roland Swingler
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2012-10-
|
|
18
|
+
date: 2012-10-30 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|