chicagowarehouse 0.4.8 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # The distinct extension won't work in Sequel 3.30 onwards at present.
4
- gem "sequel", ">= 3.34", "< 4.7"
3
+ gem "sequel", ">= 4.7"
5
4
  gem "sequel_migration_builder", ">= 0.3.2"
6
5
  gem "chronic"
7
6
 
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.4.8"
17
+ gem.version = "0.5.0"
18
18
  gem.summary = "Ruby Data Warehousing"
19
19
  gem.description = "Simple Data Warehouse toolkit for ruby"
20
20
  gem.author = "Roland Swingler"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "chicagowarehouse"
8
- s.version = "0.4.8"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Roland Swingler"]
12
- s.date = "2014-03-21"
12
+ s.date = "2014-04-03"
13
13
  s.description = "Simple Data Warehouse toolkit for ruby"
14
14
  s.email = "roland.swingler@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
27
27
  "lib/chicago.rb",
28
28
  "lib/chicago/core_ext/hash.rb",
29
29
  "lib/chicago/core_ext/sequel/dataset.rb",
30
- "lib/chicago/core_ext/sequel/sql.rb",
31
30
  "lib/chicago/data/month.rb",
32
31
  "lib/chicago/database/constants.rb",
33
32
  "lib/chicago/database/dataset_builder.rb",
@@ -55,7 +54,6 @@ Gem::Specification.new do |s|
55
54
  "lib/chicago/schema/query_column.rb",
56
55
  "lib/chicago/schema/table.rb",
57
56
  "lib/chicago/star_schema.rb",
58
- "spec/core_ext/sequel_extensions_spec.rb",
59
57
  "spec/data/month_spec.rb",
60
58
  "spec/database/db_type_converter_spec.rb",
61
59
  "spec/database/migration_file_writer_spec.rb",
@@ -83,14 +81,14 @@ Gem::Specification.new do |s|
83
81
  s.homepage = "http://github.com/notonthehighstreet/chicago"
84
82
  s.licenses = ["MIT"]
85
83
  s.require_paths = ["lib"]
86
- s.rubygems_version = "1.8.28"
84
+ s.rubygems_version = "1.8.25"
87
85
  s.summary = "Ruby Data Warehousing"
88
86
 
89
87
  if s.respond_to? :specification_version then
90
88
  s.specification_version = 3
91
89
 
92
90
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
93
- s.add_runtime_dependency(%q<sequel>, ["< 4.7", ">= 3.34"])
91
+ s.add_runtime_dependency(%q<sequel>, [">= 4.7"])
94
92
  s.add_runtime_dependency(%q<sequel_migration_builder>, [">= 0.3.2"])
95
93
  s.add_runtime_dependency(%q<chronic>, [">= 0"])
96
94
  s.add_development_dependency(%q<mysql2>, [">= 0"])
@@ -104,7 +102,7 @@ Gem::Specification.new do |s|
104
102
  s.add_development_dependency(%q<ZenTest>, [">= 0"])
105
103
  s.add_development_dependency(%q<timecop>, [">= 0"])
106
104
  else
107
- s.add_dependency(%q<sequel>, ["< 4.7", ">= 3.34"])
105
+ s.add_dependency(%q<sequel>, [">= 4.7"])
108
106
  s.add_dependency(%q<sequel_migration_builder>, [">= 0.3.2"])
109
107
  s.add_dependency(%q<chronic>, [">= 0"])
110
108
  s.add_dependency(%q<mysql2>, [">= 0"])
@@ -119,7 +117,7 @@ Gem::Specification.new do |s|
119
117
  s.add_dependency(%q<timecop>, [">= 0"])
120
118
  end
121
119
  else
122
- s.add_dependency(%q<sequel>, ["< 4.7", ">= 3.34"])
120
+ s.add_dependency(%q<sequel>, [">= 4.7"])
123
121
  s.add_dependency(%q<sequel_migration_builder>, [">= 0.3.2"])
124
122
  s.add_dependency(%q<chronic>, [">= 0"])
125
123
  s.add_dependency(%q<mysql2>, [">= 0"])
data/lib/chicago.rb CHANGED
@@ -6,7 +6,6 @@ Sequel.extension(:core_extensions)
6
6
 
7
7
  # TODO: move this back to the Sequel MySQL adapter
8
8
  require 'chicago/core_ext/sequel/dataset'
9
- require 'chicago/core_ext/sequel/sql'
10
9
 
11
10
  require 'chicago/core_ext/hash'
12
11
  require 'chicago/data/month'
@@ -159,7 +159,7 @@ module Chicago
159
159
  end
160
160
 
161
161
  def select_name
162
- :count.sql_function(@column.count_name.distinct)
162
+ :count.sql_function(@column.count_name).distinct
163
163
  end
164
164
 
165
165
  def label
@@ -3,9 +3,9 @@ require "spec_helper"
3
3
  shared_examples_for "All DB type converters" do
4
4
  context "#db_type" do
5
5
  before(:each) do
6
- @dimension = stub(:dimension)
6
+ @dimension = double(:dimension)
7
7
  end
8
-
8
+
9
9
  it "should return :varchar for a string column" do
10
10
  column = Schema::Column.new(:id, :string)
11
11
  @tc.db_type(column).should == :varchar
@@ -40,7 +40,7 @@ end
40
40
 
41
41
  describe "DbTypeConverter.for_db" do
42
42
  before :each do
43
- @mock_db = mock()
43
+ @mock_db = double()
44
44
  end
45
45
 
46
46
  it "should return a type converter specific to MySQL if the database type is :mysql" do
@@ -61,7 +61,7 @@ end
61
61
  describe "Generic DbTypeConverter" do
62
62
  it_behaves_like "All DB type converters"
63
63
 
64
- before :each do
64
+ before :each do
65
65
  @tc = Database::TypeConverters::DbTypeConverter.new
66
66
  end
67
67
 
@@ -96,7 +96,7 @@ describe Chicago::Database::TypeConverters::MysqlTypeConverter do
96
96
  :bigint => [0, 18446744073709551615]
97
97
 
98
98
  }.each do |expected_db_type, range|
99
-
99
+
100
100
  it "should return #{expected_db_type} if the maximum column value < #{range.max} and min is >= #{range.min}" do
101
101
  column = Schema::Column.new(:id, :integer, :max => range.max, :min => range.min)
102
102
  @tc.db_type(column).should == expected_db_type
@@ -104,11 +104,11 @@ describe Chicago::Database::TypeConverters::MysqlTypeConverter do
104
104
  end
105
105
 
106
106
  it "should raise an ArgumentError if either of the min/max values are out of bounds" do
107
- column = Schema::Column.new(:id,
108
- :integer,
109
- :min => 0,
107
+ column = Schema::Column.new(:id,
108
+ :integer,
109
+ :min => 0,
110
110
  :max => 18_446_744_073_709_551_616)
111
-
111
+
112
112
  lambda { @tc.db_type(column) }.should raise_error(ArgumentError)
113
113
  end
114
114
 
@@ -118,7 +118,7 @@ describe Chicago::Database::TypeConverters::MysqlTypeConverter do
118
118
  end
119
119
 
120
120
  it "should return :varchar if the column definition has a large number of elements" do
121
- column = Schema::Column.new(:id, :string, :elements => stub(:size => 70_000))
121
+ column = Schema::Column.new(:id, :string, :elements => double(:size => 70_000))
122
122
  @tc.db_type(column).should == :varchar
123
123
  end
124
124
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Chicago::Database::MigrationFileWriter do
4
4
  before :each do
5
- @mock_db = mock(:db)
5
+ @mock_db = double(:db)
6
6
  @mock_db.stub(:database_type).and_return(:generic)
7
7
  @builder = described_class.new(@mock_db, "schema")
8
8
  end
@@ -14,21 +14,21 @@ describe Chicago::Database::MigrationFileWriter do
14
14
  end
15
15
 
16
16
  it "should write out a migration file generated by Sequel::MigrationBuilder" do
17
- schema = stub(:schema)
17
+ schema = double(:schema)
18
18
 
19
- generator = stub(:generator)
19
+ generator = double(:generator)
20
20
  generator.should_receive(:traverse).
21
21
  with(schema).and_return(:table => :definitions)
22
22
  Chicago::Database::SchemaGenerator.stub(:new).and_return(generator)
23
-
24
- migration_builder = mock(:migration_builder)
23
+
24
+ migration_builder = double(:migration_builder)
25
25
  migration_builder.should_receive(:generate_migration).
26
26
  with(:table => :definitions).and_return("migration content")
27
27
  Sequel::MigrationBuilder.stub(:new).and_return(migration_builder)
28
-
28
+
29
29
  file = StringIO.new
30
30
  File.stub(:open).and_yield(file)
31
-
31
+
32
32
  @builder.write_migration_file(schema)
33
33
 
34
34
  file.rewind
data/spec/query_spec.rb CHANGED
@@ -30,7 +30,7 @@ describe Chicago::Query do
30
30
  boolean :recent
31
31
  end
32
32
  end
33
-
33
+
34
34
  @schema.define_fact(:sales) do
35
35
  dimensions :product, :customer.as(:buyer), :customer.as(:seller)
36
36
 
@@ -61,7 +61,7 @@ describe Chicago::Query do
61
61
  }.to raise_error(StandardError)
62
62
  end
63
63
  end
64
-
64
+
65
65
  describe "#table" do
66
66
  it "returns the schema table definition" do
67
67
  described_class.new(@schema, :table_name => "sales", :query_type => "fact").table.should == @schema.fact(:sales)
@@ -84,13 +84,13 @@ describe Chicago::Query do
84
84
  it "is a Sequel::Dataset" do
85
85
  @q.dataset.should be_kind_of(Sequel::Dataset)
86
86
  end
87
-
87
+
88
88
  it "selects a qualified column" do
89
89
  @q.select("product.name")
90
90
  @q.dataset.opts[:select].
91
91
  should == [:name.qualify(:product).as("product.name".to_sym)]
92
92
  end
93
-
93
+
94
94
  it "selects multiple qualified columns" do
95
95
  @q.select("product.name", "product.type")
96
96
  @q.dataset.opts[:select].
@@ -104,7 +104,7 @@ describe Chicago::Query do
104
104
  @q.dataset.sql.should =~ /COUNT\(DISTINCT `product`\.`original_id`\)/i
105
105
  end
106
106
  end
107
-
107
+
108
108
  describe "generates a dataset for a fact that" do
109
109
  before :each do
110
110
  @q = described_class.new(@schema,
@@ -117,13 +117,13 @@ describe Chicago::Query do
117
117
  end
118
118
 
119
119
  it "can be generated for a specific database" do
120
- dataset = stub(:dataset).as_null_object
121
- database = stub(:database).as_null_object
120
+ dataset = double(:dataset).as_null_object
121
+ database = double(:database).as_null_object
122
122
  database.stub(:[]).and_return(dataset)
123
-
123
+
124
124
  @q.dataset(database).should == dataset
125
125
  end
126
-
126
+
127
127
  it "selects from the correctly aliased table" do
128
128
  @q.dataset.sql.should =~ /FROM `facts_sales` AS `sales`/
129
129
  end
@@ -216,7 +216,7 @@ describe Chicago::Query do
216
216
  :pivot => "sales.product.type"})
217
217
  }.to raise_error(Chicago::UnimplementedError)
218
218
  end
219
-
219
+
220
220
  it "via IF, for a measure, by a boolean column" do
221
221
  @q.select({ :column => "sales.total",
222
222
  :op => "sum",
@@ -288,7 +288,7 @@ describe Chicago::Query do
288
288
  @q.dataset.opts[:group].should be_nil
289
289
  end
290
290
  end
291
-
291
+
292
292
  it "groups on a degenerate dimension column" do
293
293
  @q.select 'sales.order_ref'
294
294
  @q.dataset.opts[:group].should == ['sales.order_ref'.to_sym]
@@ -336,7 +336,7 @@ describe Chicago::Query do
336
336
  @q.dataset.sql.
337
337
  should =~ /INNER JOIN `dimension_product` AS `product` ON \(`product`.`id` = `sales`.`product_dimension_id`\)/
338
338
  end
339
-
339
+
340
340
  it "joins on multiple tables" do
341
341
  @q.select("sales.buyer.name", "sales.seller.name")
342
342
  @q.dataset.opts[:join].map(&:table_alias).
@@ -460,7 +460,7 @@ describe Chicago::Query do
460
460
  it "can filter based on multiple contains" do
461
461
  @q.filter({:column => "sales.product.sku", :value => ["123", "AB", "foo"], :op => :ncon}).dataset.sql.should =~ /WHERE \(\(`product`\.`sku` NOT LIKE '%123%'( ESCAPE '.+')?\) AND \(`product`\.`sku` NOT LIKE '%AB%'( ESCAPE '.+')?\) AND \(`product`\.`sku` NOT LIKE '%foo%'( ESCAPE '.+')?\)\)/
462
462
  end
463
-
463
+
464
464
  it "does not join the base table when filtering" do
465
465
  @q.
466
466
  filter({:column => "sales.order_ref", :value => "123", :op => :eq}).dataset.opts[:join].should be_nil
@@ -4,7 +4,7 @@ describe Chicago::Schema::Column do
4
4
  subject { described_class.new(:user_name, :string) }
5
5
 
6
6
  it_behaves_like "a column"
7
-
7
+
8
8
  it "should be equal to another column definition with the same attributes" do
9
9
  described_class.new(:username, :string).should == described_class.new(:username, :string)
10
10
  end
@@ -160,7 +160,7 @@ describe Chicago::Schema::Column do
160
160
  described_class.new(:foo, :string).
161
161
  should_not be_unique
162
162
  end
163
-
163
+
164
164
  it "is binary if a hash" do
165
165
  described_class.new(:foo, :binary).should be_binary
166
166
  end
@@ -174,7 +174,7 @@ describe Chicago::Schema::Column do
174
174
  end
175
175
 
176
176
  it "is visitable" do
177
- visitor = mock(:visitor)
177
+ visitor = double(:visitor)
178
178
  column = described_class.new(:foo, :integer)
179
179
  visitor.should_receive(:visit_column).with(column)
180
180
  column.visit(visitor)
@@ -2,22 +2,22 @@ require 'spec_helper'
2
2
 
3
3
  describe Chicago::Schema::Builders::DimensionBuilder do
4
4
  before :each do
5
- @builder = described_class.new(stub())
5
+ @builder = described_class.new(double())
6
6
  end
7
7
 
8
8
  it "builds a dimension" do
9
9
  @builder.build("foo").should be_kind_of(Chicago::Schema::Dimension)
10
10
  end
11
-
11
+
12
12
  it "builds a dimension with a name" do
13
13
  @builder.build("foo").name.should == :foo
14
14
  end
15
15
 
16
- it "can have a column builder specified" do
16
+ it "can have a column builder specified" do
17
17
  @builder.column_builder = Class.new do
18
18
  def initialize(klass)
19
19
  end
20
-
20
+
21
21
  def build
22
22
  [:column] if block_given?
23
23
  end
@@ -75,7 +75,7 @@ describe Chicago::Schema::DimensionReference do
75
75
  end
76
76
 
77
77
  it "qualfies a column based on the column name" do
78
- column = stub(:column, :name => :baz)
78
+ column = double(:column, :name => :baz)
79
79
  column.should_receive(:qualify_by).with(:dimension_foo)
80
80
  described_class.new(:foo, @dimension).qualify(column)
81
81
  end
@@ -97,9 +97,9 @@ describe Chicago::Schema::DimensionReference do
97
97
  it "uses the first null record id as the default value" do
98
98
  described_class.new(:foo, @dimension).default_value.should == 1
99
99
  end
100
-
100
+
101
101
  it "is visitable" do
102
- visitor = mock(:visitor)
102
+ visitor = double(:visitor)
103
103
  column = described_class.new(:foo, @dimension)
104
104
  visitor.should_receive(:visit_dimension_reference).with(column)
105
105
  column.visit(visitor)
@@ -16,7 +16,7 @@ describe Chicago::Schema::Dimension do
16
16
  end
17
17
 
18
18
  it "has columns" do
19
- column = stub(:column)
19
+ column = double(:column)
20
20
  described_class.new(:foo, :columns => [column]).
21
21
  columns.should == [column]
22
22
  end
@@ -26,30 +26,30 @@ describe Chicago::Schema::Dimension do
26
26
  end
27
27
 
28
28
  it "can qualify a column" do
29
- described_class.new(:foo).qualify(stub(:column, :name => :bar)).
29
+ described_class.new(:foo).qualify(double(:column, :name => :bar)).
30
30
  should == :bar.qualify(:dimension_foo)
31
31
  end
32
32
 
33
33
  it "provides a hash-like accessor syntax for columns" do
34
- column = stub(:column, :name => :bar)
34
+ column = double(:column, :name => :bar)
35
35
  dimension = described_class.new(:foo, :columns => [column])
36
36
  dimension[:bar].should == column
37
37
  end
38
38
 
39
39
  it "can have identifiers" do
40
- identifiers = [stub(:i), stub(:j)]
40
+ identifiers = [double(:i), double(:j)]
41
41
  described_class.new(:user, :identifiers => identifiers).
42
42
  identifiers.should == identifiers
43
43
  end
44
44
 
45
45
  it "can have a main identifier" do
46
- identifiers = [stub(:i), stub(:j)]
46
+ identifiers = [double(:i), double(:j)]
47
47
  described_class.new(:user, :identifiers => identifiers).
48
48
  main_identifier.should == identifiers.first
49
49
  end
50
50
 
51
51
  it "has null records" do
52
- column = stub(:column, :name => :bar, :default_value => '')
52
+ column = double(:column, :name => :bar, :default_value => '')
53
53
 
54
54
  options = {
55
55
  :columns => [column],
@@ -61,7 +61,7 @@ describe Chicago::Schema::Dimension do
61
61
  end
62
62
 
63
63
  it "can create null records in the database, replacing existing records" do
64
- db = mock(:db)
64
+ db = double(:db)
65
65
  db.stub(:[]).and_return(db)
66
66
  db.stub(:table_exists?).with(:keys_dimension_user).and_return(true)
67
67
  db.should_receive(:insert_replace).twice.and_return(db)
@@ -73,7 +73,7 @@ describe Chicago::Schema::Dimension do
73
73
  end
74
74
 
75
75
  it "doesn't attempt to create null rows in non-existent key table" do
76
- db = mock(:db)
76
+ db = double(:db)
77
77
  db.stub(:[]).and_return(db)
78
78
  db.stub(:table_exists?).with(:keys_dimension_user).and_return(false)
79
79
  db.should_receive(:insert_replace).and_return(db)
@@ -106,23 +106,23 @@ describe Chicago::Schema::Dimension do
106
106
  end
107
107
 
108
108
  it "supports original_key if it has an original_id column [DEPRECATED]" do
109
- column = stub(:c, :name => :original_id)
109
+ column = double(:c, :name => :original_id)
110
110
  described_class.new(:user, :columns => [column]).original_key.should == column
111
111
  end
112
112
 
113
113
  it "is considered identifiable if it has an original key [DEPRECATED]" do
114
- column = stub(:c, :name => :original_id)
114
+ column = double(:c, :name => :original_id)
115
115
  described_class.new(:user, :columns => [column]).should be_identifiable
116
116
  end
117
117
 
118
118
  it "is considered countable if it has an original key [DEPRECATED]" do
119
- column = stub(:c, :name => :original_id)
119
+ column = double(:c, :name => :original_id)
120
120
  described_class.new(:user, :columns => [column]).should be_countable
121
121
  described_class.new(:user, :columns => []).should_not be_countable
122
122
  end
123
123
 
124
124
  it "can be marked as uncountable" do
125
- column = stub(:c, :name => :original_id)
125
+ column = double(:c, :name => :original_id)
126
126
  described_class.new(:user, :columns => [column],
127
127
  :uncountable => true).should_not be_countable
128
128
  end
@@ -132,7 +132,7 @@ describe Chicago::Schema::Dimension do
132
132
  end
133
133
 
134
134
  it "is visitable" do
135
- visitor = mock(:visitor)
135
+ visitor = double(:visitor)
136
136
  dimension = described_class.new(:foo)
137
137
  visitor.should_receive(:visit_dimension).with(dimension)
138
138
  dimension.visit(visitor)
@@ -6,7 +6,7 @@ describe Chicago::Schema::Fact do
6
6
  it "has a table name" do
7
7
  described_class.new("foo").table_name.should == :facts_foo
8
8
  end
9
-
9
+
10
10
  it "has no dimensions by default" do
11
11
  described_class.new("foo").dimensions.should be_empty
12
12
  end
@@ -22,30 +22,30 @@ describe Chicago::Schema::Fact do
22
22
  it "can have a description" do
23
23
  described_class.new(:foo, :description => "bar").description.should == "bar"
24
24
  end
25
-
25
+
26
26
  it "can have dimensions" do
27
- dimension = stub(:dimension)
27
+ dimension = double(:dimension)
28
28
  described_class.new("foo", :dimensions => [dimension]).
29
29
  dimensions.should == [dimension]
30
30
  end
31
31
 
32
32
  it "has degenerate dimensions" do
33
- column = stub(:column)
33
+ column = double(:column)
34
34
  described_class.new("foo", :degenerate_dimensions => [column]).
35
35
  degenerate_dimensions.should == [column]
36
36
  end
37
37
 
38
38
  it "has measures" do
39
- column = stub(:column)
39
+ column = double(:column)
40
40
  described_class.new("foo", :measures => [column]).
41
41
  measures.should == [column]
42
42
  end
43
43
 
44
44
  it "has columns defined as dimensions, degenerate dimensions & measures" do
45
45
 
46
- dimension = stub(:dimension)
47
- column = stub(:column)
48
- column_2 = stub(:column_2)
46
+ dimension = double(:dimension)
47
+ column = double(:column)
48
+ column_2 = double(:column_2)
49
49
  fact = described_class.new("foo",
50
50
  :dimensions => [dimension],
51
51
  :degenerate_dimensions => [column],
@@ -54,19 +54,19 @@ describe Chicago::Schema::Fact do
54
54
  end
55
55
 
56
56
  it "can qualify a column" do
57
- described_class.new(:foo).qualify(stub(:column, :name => :bar)).
57
+ described_class.new(:foo).qualify(double(:column, :name => :bar)).
58
58
  should == :bar.qualify(:facts_foo)
59
59
  end
60
60
 
61
61
  it "provides a hash-like accessor syntax for columns" do
62
- measure = stub(:column, :name => :bar)
62
+ measure = double(:column, :name => :bar)
63
63
  fact = described_class.new(:foo, :measures => [measure])
64
64
  fact[:bar].should == measure
65
65
  end
66
66
 
67
67
  it "is factless if it has no measures" do
68
- described_class.new(:foo, :measures => [stub()]).should_not be_factless
69
- described_class.new(:foo).should be_factless
68
+ described_class.new(:foo, :measures => [double()]).should_not be_factless
69
+ described_class.new(:foo).should be_factless
70
70
  end
71
71
 
72
72
  it "can define a natural key" do
@@ -75,7 +75,7 @@ describe Chicago::Schema::Fact do
75
75
  end
76
76
 
77
77
  it "is visitable" do
78
- visitor = mock(:visitor)
78
+ visitor = double(:visitor)
79
79
  fact = described_class.new(:foo)
80
80
  visitor.should_receive(:visit_fact).with(fact)
81
81
  fact.visit(visitor)
@@ -8,7 +8,7 @@ describe Chicago::Schema::Measure do
8
8
  it "should not be semi_additive by default" do
9
9
  described_class.new(:rate, :integer).should_not be_semi_additive
10
10
  end
11
-
11
+
12
12
  it "can be defined as semi_additive" do
13
13
  described_class.new(:rate, :integer, :semi_additive => true).
14
14
  should be_semi_additive
@@ -17,9 +17,9 @@ describe Chicago::Schema::Measure do
17
17
  it "is not indexed" do
18
18
  described_class.new(:rate, :integer).should_not be_indexed
19
19
  end
20
-
20
+
21
21
  it "is visitable" do
22
- visitor = mock(:visitor)
22
+ visitor = double(:visitor)
23
23
  measure = described_class.new(:foo, :integer)
24
24
  visitor.should_receive(:visit_measure).with(measure)
25
25
  measure.visit(visitor)
@@ -2,9 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  describe Chicago::Schema::NamedElementCollection do
4
4
  before :each do
5
- @e = stub(:element, :name => :foo)
5
+ @e = double(:element, :name => :foo)
6
6
  end
7
-
7
+
8
8
  it "supports adding an element via add" do
9
9
  subject.add(@e)
10
10
  subject.to_a.should == [@e]
@@ -35,8 +35,8 @@ describe Chicago::Schema::NamedElementCollection do
35
35
 
36
36
  it "returns true from contains? if the collection contains the same-named element" do
37
37
  subject.add @e
38
- subject.contain?(stub(:element, :name => :foo)).should be_true
39
- subject.contain?(stub(:element, :name => :bar)).should be_false
38
+ subject.contain?(double(:element, :name => :foo)).should be_true
39
+ subject.contain?(double(:element, :name => :bar)).should be_false
40
40
  end
41
41
 
42
42
  it "returns the number of elements in a collection from size" do
@@ -61,7 +61,7 @@ describe Chicago::Schema::NamedElementCollection do
61
61
 
62
62
  it "has elements that are unique by name" do
63
63
  subject.add(@e)
64
- subject.add(stub(:element, :name => :foo))
64
+ subject.add(double(:element, :name => :foo))
65
65
  subject.size.should == 1
66
66
  end
67
67
  end
@@ -2,10 +2,10 @@ require 'spec_helper'
2
2
 
3
3
  describe Chicago::Schema::PivotedColumn do
4
4
  before :each do
5
- @column = stub(:column)
6
- @pivot = stub(:pivot)
5
+ @column = double(:column)
6
+ @pivot = double(:pivot)
7
7
  end
8
-
8
+
9
9
  it "has a nil group name" do
10
10
  described_class.new(@column, @pivot, 0, true).group_name.should be_nil
11
11
  end
@@ -3,10 +3,10 @@ require 'chicago/schema/query_column'
3
3
 
4
4
  describe Chicago::Schema::QueryColumn do
5
5
  describe "a standard column" do
6
- let(:owner) { stub(:owner).as_null_object }
7
- let(:column) { stub(:column, :calculated? => false).as_null_object }
6
+ let(:owner) { double(:owner).as_null_object }
7
+ let(:column) { double(:column, :calculated? => false).as_null_object }
8
8
  subject { described_class.column(owner, column, "foo.bar") }
9
-
9
+
10
10
  it "should have a column alias" do
11
11
  subject.column_alias.should == "foo.bar"
12
12
  end
@@ -38,9 +38,9 @@ describe Chicago::Schema::QueryColumn do
38
38
  end
39
39
 
40
40
  describe "a virtual column generated from calculation" do
41
- let(:calculation) { stub(:calculation).as_null_object }
42
- let(:owner) { stub(:owner).as_null_object }
43
- let(:column) { stub(:column, :calculated? => true, :calculation => calculation).as_null_object }
41
+ let(:calculation) { double(:calculation).as_null_object }
42
+ let(:owner) { double(:owner).as_null_object }
43
+ let(:column) { double(:column, :calculated? => true, :calculation => calculation).as_null_object }
44
44
  subject { described_class.column(owner, column, "foo.bar") }
45
45
 
46
46
  it "should have a column alias" do
@@ -68,16 +68,16 @@ describe Chicago::Schema::QueryColumn do
68
68
  end
69
69
 
70
70
  describe "a dimension column" do
71
- let(:owner) { stub(:owner).as_null_object }
72
- let(:column) { stub(:column).as_null_object }
71
+ let(:owner) { double(:owner).as_null_object }
72
+ let(:column) { double(:column).as_null_object }
73
73
  subject { described_class.column(owner, column, "foo.bar") }
74
74
 
75
75
  before :each do
76
76
  column.stub(:main_identifier).and_return(:name)
77
- column.stub(:original_key).and_return(stub(:name => :original_id))
77
+ column.stub(:original_key).and_return(double(:name => :original_id))
78
78
  column.stub(:kind_of?).with(Chicago::Schema::Dimension).and_return(true)
79
79
  end
80
-
80
+
81
81
  it "should have a column alias" do
82
82
  subject.column_alias.should == "foo.bar"
83
83
  end
@@ -108,20 +108,20 @@ describe Chicago::Schema::QueryColumn do
108
108
  end
109
109
 
110
110
  describe "a dimension identifier column" do
111
- let(:owner) { stub(:owner).as_null_object }
112
- let(:column) { stub(:column).as_null_object }
111
+ let(:owner) { double(:owner).as_null_object }
112
+ let(:column) { double(:column).as_null_object }
113
113
  subject { described_class.column(owner, column, "foo.bar") }
114
114
 
115
115
  before :each do
116
116
  column.stub(:name).and_return(:bar)
117
117
 
118
118
  owner.stub(:name).and_return(:foo)
119
- owner.stub(:original_key).and_return(stub(:name => :original_id))
119
+ owner.stub(:original_key).and_return(double(:name => :original_id))
120
120
  owner.stub(:kind_of?).with(Chicago::Schema::Dimension).and_return(true)
121
121
  owner.stub(:identifiable?).and_return(true)
122
122
  owner.stub(:identifiers).and_return([:bar])
123
123
  end
124
-
124
+
125
125
  it "should have a column alias" do
126
126
  subject.column_alias.should == "foo.bar"
127
127
  end
@@ -61,7 +61,7 @@ describe Chicago::StarSchema do
61
61
  null_record :id => 2, :email => "Not Applicable", :original_id => -1
62
62
  end
63
63
 
64
- db = stub(:db, :table_exists? => true)
64
+ db = double(:db, :table_exists? => true)
65
65
  db.stub_chain(:[], :insert_replace).and_return(db)
66
66
  db.should_receive(:multi_insert).with([{:id => 1, :email => "Missing"},
67
67
  {:id => 2, :email => "Not Applicable", :original_id => -1}])
@@ -208,7 +208,7 @@ describe Chicago::StarSchema do
208
208
  it "allows definition of a fact and a dimension with the same name" do
209
209
  @schema.define_fact(:user)
210
210
  expect { @schema.define_dimension(:user) }.
211
- to_not raise_error(Chicago::DuplicateTableError)
211
+ to_not raise_error
212
212
  end
213
213
 
214
214
  it "returns all dimensions and facts from #tables" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chicagowarehouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,30 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-21 00:00:00.000000000 Z
12
+ date: 2014-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - <
20
- - !ruby/object:Gem::Version
21
- version: '4.7'
22
19
  - - ! '>='
23
20
  - !ruby/object:Gem::Version
24
- version: '3.34'
21
+ version: '4.7'
25
22
  type: :runtime
26
23
  prerelease: false
27
24
  version_requirements: !ruby/object:Gem::Requirement
28
25
  none: false
29
26
  requirements:
30
- - - <
31
- - !ruby/object:Gem::Version
32
- version: '4.7'
33
27
  - - ! '>='
34
28
  - !ruby/object:Gem::Version
35
- version: '3.34'
29
+ version: '4.7'
36
30
  - !ruby/object:Gem::Dependency
37
31
  name: sequel_migration_builder
38
32
  requirement: !ruby/object:Gem::Requirement
@@ -243,7 +237,6 @@ files:
243
237
  - lib/chicago.rb
244
238
  - lib/chicago/core_ext/hash.rb
245
239
  - lib/chicago/core_ext/sequel/dataset.rb
246
- - lib/chicago/core_ext/sequel/sql.rb
247
240
  - lib/chicago/data/month.rb
248
241
  - lib/chicago/database/constants.rb
249
242
  - lib/chicago/database/dataset_builder.rb
@@ -271,7 +264,6 @@ files:
271
264
  - lib/chicago/schema/query_column.rb
272
265
  - lib/chicago/schema/table.rb
273
266
  - lib/chicago/star_schema.rb
274
- - spec/core_ext/sequel_extensions_spec.rb
275
267
  - spec/data/month_spec.rb
276
268
  - spec/database/db_type_converter_spec.rb
277
269
  - spec/database/migration_file_writer_spec.rb
@@ -310,7 +302,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
310
302
  version: '0'
311
303
  segments:
312
304
  - 0
313
- hash: 2494131027437127772
305
+ hash: -4302469989561989686
314
306
  required_rubygems_version: !ruby/object:Gem::Requirement
315
307
  none: false
316
308
  requirements:
@@ -319,7 +311,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
311
  version: '0'
320
312
  requirements: []
321
313
  rubyforge_project:
322
- rubygems_version: 1.8.28
314
+ rubygems_version: 1.8.25
323
315
  signing_key:
324
316
  specification_version: 3
325
317
  summary: Ruby Data Warehousing
@@ -1,62 +0,0 @@
1
- module Sequel
2
- # @private
3
- class Dataset
4
- COLUMN_DISTINCT = "DISTINCT ".freeze
5
-
6
- def distinct_expression_sql(e)
7
- s = ""
8
- distinct_expression_sql_append(s, e)
9
- s
10
- end
11
-
12
- def distinct_expression_sql_append(sql, e)
13
- sql << COLUMN_DISTINCT
14
- literal_append(sql, e.expression)
15
- end
16
-
17
- # Provide support for Sequel versions before 3.30.0
18
- unless method_defined?(:literal_append)
19
- def literal_append(sql, expression)
20
- sql << literal(expression)
21
- end
22
- end
23
- end
24
-
25
- module SQL
26
- class DistinctExpression < Expression # :nodoc:
27
- attr_reader :expression
28
-
29
- def initialize(expression)
30
- @expression = expression
31
- end
32
-
33
- to_s_method :distinct_expression_sql
34
- end
35
-
36
- module DistinctMethods
37
- def distinct
38
- DistinctExpression.new(self)
39
- end
40
- end
41
-
42
- # @private
43
- class ComplexExpression
44
- include DistinctMethods
45
- end
46
-
47
- # @private
48
- class GenericExpression
49
- include DistinctMethods
50
- end
51
- end
52
- end
53
-
54
- # @private
55
- class Symbol
56
- include Sequel::SQL::DistinctMethods
57
- end
58
-
59
- # @private
60
- class String
61
- include Sequel::SQL::DistinctMethods
62
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Symbol do
4
- it "should have a distinct method" do
5
- :foo.distinct.should be_kind_of(Sequel::SQL::DistinctExpression)
6
- end
7
- end
8
-
9
- describe String do
10
- it "should have a distinct method" do
11
- "foo".distinct.should be_kind_of(Sequel::SQL::DistinctExpression)
12
- end
13
- end
14
-
15
- describe Sequel::SQL::Expression do
16
- it "should have a distinct method" do
17
- :if.sql_function(true, 1, 0).distinct.should be_kind_of(Sequel::SQL::DistinctExpression)
18
- end
19
- end
20
-
21
- describe Sequel::SQL::DistinctExpression do
22
- it "has a reader for the wrapped expression" do
23
- described_class.new(:foo).expression.should == :foo
24
- end
25
-
26
- it "is rendered as 'DISTINCT expression'" do
27
- described_class.new(:foo).sql_literal(TEST_DB[:foo]).should == "DISTINCT `foo`"
28
- end
29
- end