chicagowarehouse 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
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.
|
17
|
+
gem.version = "0.4.2"
|
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 = "chicagowarehouse"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.2"
|
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 = "2013-04-
|
12
|
+
s.date = "2013-04-16"
|
13
13
|
s.description = "Simple Data Warehouse toolkit for ruby"
|
14
14
|
s.email = "roland.swingler@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,6 +28,7 @@ module Chicago
|
|
28
28
|
when :string then string_type(column.min, column.max)
|
29
29
|
when :money then :decimal
|
30
30
|
when :percent then :decimal
|
31
|
+
when :hash then :binary
|
31
32
|
else
|
32
33
|
column.column_type
|
33
34
|
end
|
@@ -71,7 +72,7 @@ module Chicago
|
|
71
72
|
class MysqlTypeConverter < DbTypeConverter
|
72
73
|
def db_type(column)
|
73
74
|
return :enum if column.elements && column.elements.size < 65_536
|
74
|
-
super
|
75
|
+
super(column)
|
75
76
|
end
|
76
77
|
|
77
78
|
# Returns table options for a dimension or fact table.
|
@@ -52,8 +52,11 @@ module Chicago
|
|
52
52
|
@elements = @opts[:elements]
|
53
53
|
@default = @opts[:default]
|
54
54
|
@descriptive = !! @opts[:descriptive]
|
55
|
-
@internal = !! @opts[:internal]
|
56
|
-
|
55
|
+
@internal = @opts.has_key?(:internal) ? !! @opts[:internal] :
|
56
|
+
column_type == :hash
|
57
|
+
@unique = !! @opts[:unique]
|
58
|
+
@optional = !! (@opts.has_key?(:optional) ? @opts[:optional] :
|
59
|
+
@opts[:null])
|
57
60
|
end
|
58
61
|
|
59
62
|
# Returns the type of this column. This is an abstract type,
|
@@ -134,6 +137,10 @@ module Chicago
|
|
134
137
|
@descriptive
|
135
138
|
end
|
136
139
|
|
140
|
+
def unique?
|
141
|
+
@unique
|
142
|
+
end
|
143
|
+
|
137
144
|
# Returns true if both definition's attributes are equal.
|
138
145
|
def ==(other)
|
139
146
|
other.kind_of?(self.class) &&
|
@@ -152,6 +159,11 @@ module Chicago
|
|
152
159
|
@textual ||= [:string, :text].include?(column_type)
|
153
160
|
end
|
154
161
|
|
162
|
+
# Returns true if the column stores a binary value.
|
163
|
+
def binary?
|
164
|
+
@binary ||= [:binary, :hash].include?(column_type)
|
165
|
+
end
|
166
|
+
|
155
167
|
def hash #:nodoc:
|
156
168
|
name.hash
|
157
169
|
end
|
@@ -196,6 +208,8 @@ module Chicago
|
|
196
208
|
[12,2]
|
197
209
|
elsif column_type == :percent
|
198
210
|
[6,3]
|
211
|
+
elsif column_type == :hash
|
212
|
+
16
|
199
213
|
end
|
200
214
|
end
|
201
215
|
|
@@ -210,7 +224,7 @@ module Chicago
|
|
210
224
|
end
|
211
225
|
|
212
226
|
def default_null(type)
|
213
|
-
[:date, :timestamp, :datetime].include?(type)
|
227
|
+
[:date, :timestamp, :datetime, :hash, :binary].include?(type)
|
214
228
|
end
|
215
229
|
|
216
230
|
def default_min(type)
|
@@ -31,6 +31,11 @@ shared_examples_for "All DB type converters" do
|
|
31
31
|
@tc.db_type(column).should == :decimal
|
32
32
|
end
|
33
33
|
|
34
|
+
it "should return :binary for a hash column type" do
|
35
|
+
column = Schema::Column.new(:id, :hash)
|
36
|
+
@tc.db_type(column).should == :binary
|
37
|
+
end
|
38
|
+
|
34
39
|
it "should assume any other type is a database type and return it" do
|
35
40
|
column = Schema::Column.new(:id, :foo)
|
36
41
|
@tc.db_type(column).should == :foo
|
data/spec/schema/column_spec.rb
CHANGED
@@ -148,7 +148,27 @@ describe Chicago::Schema::Column do
|
|
148
148
|
described_class.new(:foo, :string, :null => true, :optional => false).
|
149
149
|
should_not be_optional
|
150
150
|
end
|
151
|
+
|
152
|
+
it "can be unique" do
|
153
|
+
described_class.new(:foo, :string, :unique => true).
|
154
|
+
should be_unique
|
155
|
+
|
156
|
+
described_class.new(:foo, :string).
|
157
|
+
should_not be_unique
|
158
|
+
end
|
151
159
|
|
160
|
+
it "is binary if a hash" do
|
161
|
+
described_class.new(:foo, :hash).should be_binary
|
162
|
+
end
|
163
|
+
|
164
|
+
it "is nullable by default if a hash" do
|
165
|
+
described_class.new(:foo, :hash).should be_null
|
166
|
+
end
|
167
|
+
|
168
|
+
it "is internal by default if a hash" do
|
169
|
+
described_class.new(:foo, :hash).should be_internal
|
170
|
+
end
|
171
|
+
|
152
172
|
it "is visitable" do
|
153
173
|
visitor = mock(:visitor)
|
154
174
|
column = described_class.new(:foo, :integer)
|
@@ -157,7 +177,7 @@ describe Chicago::Schema::Column do
|
|
157
177
|
end
|
158
178
|
end
|
159
179
|
|
160
|
-
describe "Chicago::Schema::Column#
|
180
|
+
describe "Chicago::Schema::Column#to_hash" do
|
161
181
|
it "should have a :name entry" do
|
162
182
|
Chicago::Schema::Column.new(:username, :string, :max => 8).to_hash[:name].should == :username
|
163
183
|
end
|
@@ -194,6 +214,10 @@ describe "Chicago::Schema::Column#hash" do
|
|
194
214
|
Chicago::Schema::Column.new(:some_value, :money).to_hash[:size].should == [12,2]
|
195
215
|
end
|
196
216
|
|
217
|
+
it "should have a default :size of 16 for hash types" do
|
218
|
+
Chicago::Schema::Column.new(:some_value, :hash).to_hash[:size].should == 16
|
219
|
+
end
|
220
|
+
|
197
221
|
it "should be unsigned by default if a percentage" do
|
198
222
|
Chicago::Schema::Column.new(:some_value, :percent).to_hash[:unsigned].should be_true
|
199
223
|
end
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
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: 2013-04-
|
18
|
+
date: 2013-04-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|