dynashard 0.1.0 → 0.2.0

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/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'activerecord', '>= 3.0'
4
+ gem 'arel', '>= 2.0'
4
5
 
5
6
  group :development do
6
7
  gem "shoulda", ">= 0"
data/Gemfile.lock CHANGED
@@ -2,95 +2,74 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  abstract (1.0.0)
5
- actionmailer (3.0.1)
6
- actionpack (= 3.0.1)
7
- mail (~> 2.2.5)
8
- actionpack (3.0.1)
9
- activemodel (= 3.0.1)
10
- activesupport (= 3.0.1)
5
+ actionpack (3.0.3)
6
+ activemodel (= 3.0.3)
7
+ activesupport (= 3.0.3)
11
8
  builder (~> 2.1.2)
12
9
  erubis (~> 2.6.6)
13
- i18n (~> 0.4.1)
10
+ i18n (~> 0.4)
14
11
  rack (~> 1.2.1)
15
- rack-mount (~> 0.6.12)
16
- rack-test (~> 0.5.4)
12
+ rack-mount (~> 0.6.13)
13
+ rack-test (~> 0.5.6)
17
14
  tzinfo (~> 0.3.23)
18
- activemodel (3.0.1)
19
- activesupport (= 3.0.1)
15
+ activemodel (3.0.3)
16
+ activesupport (= 3.0.3)
20
17
  builder (~> 2.1.2)
21
- i18n (~> 0.4.1)
22
- activerecord (3.0.1)
23
- activemodel (= 3.0.1)
24
- activesupport (= 3.0.1)
25
- arel (~> 1.0.0)
18
+ i18n (~> 0.4)
19
+ activerecord (3.0.3)
20
+ activemodel (= 3.0.3)
21
+ activesupport (= 3.0.3)
22
+ arel (~> 2.0.2)
26
23
  tzinfo (~> 0.3.23)
27
- activeresource (3.0.1)
28
- activemodel (= 3.0.1)
29
- activesupport (= 3.0.1)
30
- activesupport (3.0.1)
31
- arel (1.0.1)
32
- activesupport (~> 3.0.0)
24
+ activesupport (3.0.3)
25
+ arel (2.0.7)
33
26
  builder (2.1.2)
34
27
  diff-lcs (1.1.2)
35
28
  erubis (2.6.6)
36
29
  abstract (>= 1.0.0)
37
- factory_girl (1.3.2)
38
- factory_girl_rails (1.0)
30
+ factory_girl (1.3.3)
31
+ factory_girl_rails (1.0.1)
39
32
  factory_girl (~> 1.3)
40
- rails (>= 3.0.0.beta4)
33
+ railties (>= 3.0.0)
41
34
  git (1.2.5)
42
- i18n (0.4.2)
35
+ i18n (0.5.0)
43
36
  jeweler (1.5.2)
44
37
  bundler (~> 1.0.0)
45
38
  git (>= 1.2.5)
46
39
  rake
47
- mail (2.2.9)
48
- activesupport (>= 2.3.6)
49
- i18n (~> 0.4.1)
50
- mime-types (~> 1.16)
51
- treetop (~> 1.4.8)
52
- mime-types (1.16)
53
- polyglot (0.3.1)
54
40
  rack (1.2.1)
55
41
  rack-mount (0.6.13)
56
42
  rack (>= 1.0.0)
57
- rack-test (0.5.6)
43
+ rack-test (0.5.7)
58
44
  rack (>= 1.0)
59
- rails (3.0.1)
60
- actionmailer (= 3.0.1)
61
- actionpack (= 3.0.1)
62
- activerecord (= 3.0.1)
63
- activeresource (= 3.0.1)
64
- activesupport (= 3.0.1)
65
- bundler (~> 1.0.0)
66
- railties (= 3.0.1)
67
- railties (3.0.1)
68
- actionpack (= 3.0.1)
69
- activesupport (= 3.0.1)
70
- rake (>= 0.8.4)
71
- thor (~> 0.14.0)
45
+ railties (3.0.3)
46
+ actionpack (= 3.0.3)
47
+ activesupport (= 3.0.3)
48
+ rake (>= 0.8.7)
49
+ thor (~> 0.14.4)
72
50
  rake (0.8.7)
73
51
  rcov (0.9.9)
74
- rspec (2.1.0)
75
- rspec-core (~> 2.1.0)
76
- rspec-expectations (~> 2.1.0)
77
- rspec-mocks (~> 2.1.0)
78
- rspec-core (2.1.0)
79
- rspec-expectations (2.1.0)
52
+ rspec (2.4.0)
53
+ rspec-core (~> 2.4.0)
54
+ rspec-expectations (~> 2.4.0)
55
+ rspec-mocks (~> 2.4.0)
56
+ rspec-core (2.4.0)
57
+ rspec-expectations (2.4.0)
80
58
  diff-lcs (~> 1.1.2)
81
- rspec-mocks (2.1.0)
59
+ rspec-mocks (2.4.0)
82
60
  shoulda (2.11.3)
83
- sqlite3-ruby (1.3.2)
84
- thor (0.14.4)
85
- treetop (1.4.8)
86
- polyglot (>= 0.3.1)
87
- tzinfo (0.3.23)
61
+ sqlite3 (1.3.3)
62
+ sqlite3-ruby (1.3.3)
63
+ sqlite3 (>= 1.3.3)
64
+ thor (0.14.6)
65
+ tzinfo (0.3.24)
88
66
 
89
67
  PLATFORMS
90
68
  ruby
91
69
 
92
70
  DEPENDENCIES
93
71
  activerecord (>= 3.0)
72
+ arel (>= 2.0)
94
73
  bundler (~> 1.0.0)
95
74
  factory_girl_rails
96
75
  jeweler (~> 1.5.2)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/dynashard.gemspec ADDED
@@ -0,0 +1,90 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dynashard}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Nick Hengeveld"]
12
+ s.date = %q{2011-01-31}
13
+ s.description = %q{Dynashard allows you to shard your ActiveRecord models. Models can be configured to shard based on context that can be defined dynamically.}
14
+ s.email = %q{nickh@verticalresponse.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "dynashard.gemspec",
28
+ "lib/dynashard.rb",
29
+ "lib/dynashard/associations.rb",
30
+ "lib/dynashard/connection_handler.rb",
31
+ "lib/dynashard/model.rb",
32
+ "lib/dynashard/validations.rb",
33
+ "spec/associations_spec.rb",
34
+ "spec/connection_handler_spec.rb",
35
+ "spec/dynashard_spec.rb",
36
+ "spec/model_spec.rb",
37
+ "spec/spec_helper.rb",
38
+ "spec/support/factories.rb",
39
+ "spec/support/models.rb",
40
+ "spec/validation_spec.rb"
41
+ ]
42
+ s.homepage = %q{http://github.com/nickh/dynashard}
43
+ s.licenses = ["MIT"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.7}
46
+ s.summary = %q{Dynamic sharding for ActiveRecord}
47
+ s.test_files = [
48
+ "spec/associations_spec.rb",
49
+ "spec/connection_handler_spec.rb",
50
+ "spec/db/schema.rb",
51
+ "spec/dynashard_spec.rb",
52
+ "spec/model_spec.rb",
53
+ "spec/spec_helper.rb",
54
+ "spec/support/factories.rb",
55
+ "spec/support/models.rb",
56
+ "spec/validation_spec.rb"
57
+ ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
64
+ s.add_runtime_dependency(%q<activerecord>, [">= 3.0"])
65
+ s.add_runtime_dependency(%q<arel>, [">= 2.0"])
66
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
67
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
68
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
69
+ s.add_development_dependency(%q<rcov>, [">= 0"])
70
+ s.add_runtime_dependency(%q<activerecord>, [">= 3.0"])
71
+ else
72
+ s.add_dependency(%q<activerecord>, [">= 3.0"])
73
+ s.add_dependency(%q<arel>, [">= 2.0"])
74
+ s.add_dependency(%q<shoulda>, [">= 0"])
75
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
76
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
77
+ s.add_dependency(%q<rcov>, [">= 0"])
78
+ s.add_dependency(%q<activerecord>, [">= 3.0"])
79
+ end
80
+ else
81
+ s.add_dependency(%q<activerecord>, [">= 3.0"])
82
+ s.add_dependency(%q<arel>, [">= 2.0"])
83
+ s.add_dependency(%q<shoulda>, [">= 0"])
84
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
85
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
86
+ s.add_dependency(%q<rcov>, [">= 0"])
87
+ s.add_dependency(%q<activerecord>, [">= 3.0"])
88
+ end
89
+ end
90
+
data/lib/dynashard.rb CHANGED
@@ -164,4 +164,3 @@ require 'dynashard/model'
164
164
  require 'dynashard/associations'
165
165
  require 'dynashard/connection_handler'
166
166
  require 'dynashard/validations'
167
- require 'dynashard/arel_sql_engine'
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynashard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 1
7
+ - 2
9
8
  - 0
10
- version: 0.1.0
9
+ version: 0.2.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Nick Hengeveld
@@ -19,95 +18,103 @@ date: 2011-01-31 00:00:00 -08:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- prerelease: false
24
21
  name: activerecord
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirement: &id001 !ruby/object:Gem::Requirement
26
23
  none: false
27
24
  requirements:
28
25
  - - ">="
29
26
  - !ruby/object:Gem::Version
30
- hash: 7
31
27
  segments:
32
28
  - 3
33
29
  - 0
34
30
  version: "3.0"
35
- requirement: *id001
31
+ type: :runtime
32
+ prerelease: false
33
+ version_requirements: *id001
36
34
  - !ruby/object:Gem::Dependency
37
- type: :development
35
+ name: arel
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 2
43
+ - 0
44
+ version: "2.0"
45
+ type: :runtime
38
46
  prerelease: false
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
39
49
  name: shoulda
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
50
+ requirement: &id003 !ruby/object:Gem::Requirement
41
51
  none: false
42
52
  requirements:
43
53
  - - ">="
44
54
  - !ruby/object:Gem::Version
45
- hash: 3
46
55
  segments:
47
56
  - 0
48
57
  version: "0"
49
- requirement: *id002
50
- - !ruby/object:Gem::Dependency
51
58
  type: :development
52
59
  prerelease: false
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
53
62
  name: bundler
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
63
+ requirement: &id004 !ruby/object:Gem::Requirement
55
64
  none: false
56
65
  requirements:
57
66
  - - ~>
58
67
  - !ruby/object:Gem::Version
59
- hash: 23
60
68
  segments:
61
69
  - 1
62
70
  - 0
63
71
  - 0
64
72
  version: 1.0.0
65
- requirement: *id003
66
- - !ruby/object:Gem::Dependency
67
73
  type: :development
68
74
  prerelease: false
75
+ version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
69
77
  name: jeweler
70
- version_requirements: &id004 !ruby/object:Gem::Requirement
78
+ requirement: &id005 !ruby/object:Gem::Requirement
71
79
  none: false
72
80
  requirements:
73
81
  - - ~>
74
82
  - !ruby/object:Gem::Version
75
- hash: 7
76
83
  segments:
77
84
  - 1
78
85
  - 5
79
86
  - 2
80
87
  version: 1.5.2
81
- requirement: *id004
82
- - !ruby/object:Gem::Dependency
83
88
  type: :development
84
89
  prerelease: false
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
85
92
  name: rcov
86
- version_requirements: &id005 !ruby/object:Gem::Requirement
93
+ requirement: &id006 !ruby/object:Gem::Requirement
87
94
  none: false
88
95
  requirements:
89
96
  - - ">="
90
97
  - !ruby/object:Gem::Version
91
- hash: 3
92
98
  segments:
93
99
  - 0
94
100
  version: "0"
95
- requirement: *id005
96
- - !ruby/object:Gem::Dependency
97
- type: :runtime
101
+ type: :development
98
102
  prerelease: false
103
+ version_requirements: *id006
104
+ - !ruby/object:Gem::Dependency
99
105
  name: activerecord
100
- version_requirements: &id006 !ruby/object:Gem::Requirement
106
+ requirement: &id007 !ruby/object:Gem::Requirement
101
107
  none: false
102
108
  requirements:
103
109
  - - ">="
104
110
  - !ruby/object:Gem::Version
105
- hash: 7
106
111
  segments:
107
112
  - 3
108
113
  - 0
109
114
  version: "3.0"
110
- requirement: *id006
115
+ type: :runtime
116
+ prerelease: false
117
+ version_requirements: *id007
111
118
  description: Dynashard allows you to shard your ActiveRecord models. Models can be configured to shard based on context that can be defined dynamically.
112
119
  email: nickh@verticalresponse.com
113
120
  executables: []
@@ -125,13 +132,12 @@ files:
125
132
  - README.md
126
133
  - Rakefile
127
134
  - VERSION
135
+ - dynashard.gemspec
128
136
  - lib/dynashard.rb
129
- - lib/dynashard/arel_sql_engine.rb
130
137
  - lib/dynashard/associations.rb
131
138
  - lib/dynashard/connection_handler.rb
132
139
  - lib/dynashard/model.rb
133
140
  - lib/dynashard/validations.rb
134
- - spec/arel_sql_engine_spec.rb
135
141
  - spec/associations_spec.rb
136
142
  - spec/connection_handler_spec.rb
137
143
  - spec/dynashard_spec.rb
@@ -155,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
161
  requirements:
156
162
  - - ">="
157
163
  - !ruby/object:Gem::Version
158
- hash: 3
164
+ hash: -2881092534266890665
159
165
  segments:
160
166
  - 0
161
167
  version: "0"
@@ -164,7 +170,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
170
  requirements:
165
171
  - - ">="
166
172
  - !ruby/object:Gem::Version
167
- hash: 3
168
173
  segments:
169
174
  - 0
170
175
  version: "0"
@@ -176,7 +181,6 @@ signing_key:
176
181
  specification_version: 3
177
182
  summary: Dynamic sharding for ActiveRecord
178
183
  test_files:
179
- - spec/arel_sql_engine_spec.rb
180
184
  - spec/associations_spec.rb
181
185
  - spec/connection_handler_spec.rb
182
186
  - spec/db/schema.rb
@@ -1,22 +0,0 @@
1
- module Dynashard
2
- module ArelEngineExtensions
3
- def self.included(base)
4
- base.alias_method_chain :connection, :dynashard
5
- end
6
-
7
- def connection_with_dynashard
8
- if @ar && @ar.respond_to?(:dynashard_klass)
9
- @ar.dynashard_klass.connection
10
- elsif @ar && @ar.sharding_enabled?
11
- spec = Dynashard.shard_context[@ar.dynashard_context]
12
- raise "Missing #{@ar.dynashard_context} shard context" if spec.nil?
13
- spec = spec.call if spec.respond_to?(:call)
14
- Dynashard.class_for(spec).connection
15
- else
16
- connection_without_dynashard
17
- end
18
- end
19
- end
20
- end
21
-
22
- Arel::Sql::Engine.send(:include, Dynashard::ArelEngineExtensions)
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Dynashard::ArelEngineExtensions' do
4
- before(:each) do
5
- @mock_record = mock()
6
- @engine = Arel::Sql::Engine.new(@mock_record)
7
- end
8
-
9
- describe '#connection_with_dynashard' do
10
- context 'with a sharding association owner' do
11
- it "returns the generated model subclass connection" do
12
- @mock_record.should_receive(:dynashard_klass).once.and_return(mock(:connection => :subclass_connection))
13
- @engine.should_receive(:connection_without_dynashard).never
14
- @engine.connection.should == :subclass_connection
15
- end
16
- end
17
-
18
- context 'with a sharding model' do
19
- before(:each) do
20
- @mock_record.should_receive(:sharding_enabled?).and_return(true)
21
- @mock_record.should_receive(:dynashard_context).at_least(:once).and_return(:dynashard_context)
22
- end
23
-
24
- context 'and no defined sharding context' do
25
- it 'raises an exception' do
26
- Dynashard.shard_context[:dynashard_context] = nil
27
- lambda do
28
- @engine.connection
29
- end.should raise_error
30
- end
31
- end
32
-
33
- context 'and a defined sharding context' do
34
- it 'returns the generated shard class connection' do
35
- Dynashard.should_receive(:class_for).with(:shard_spec).and_return(mock(:connection => :shard_connection))
36
- Dynashard.shard_context[:dynashard_context] = :shard_spec
37
- @engine.should_receive(:connection_without_dynashard).never
38
- @engine.connection.should == :shard_connection
39
- end
40
- end
41
- end
42
-
43
- context 'with a non-sharding model' do
44
- it 'returns the default connection' do
45
- @mock_record.should_receive(:sharding_enabled?).and_return(false)
46
- @engine.should_receive(:connection_without_dynashard).and_return(:model_connection)
47
- @engine.connection.should == :model_connection
48
- end
49
- end
50
- end
51
- end