ar-octopus 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/Appraisals CHANGED
@@ -1,10 +1,6 @@
1
- appraise "rails2" do
2
- gem "activerecord", "~> 2.3"
3
- gem "actionpack", "~> 2.3"
4
- end
5
-
6
1
  appraise "rails30" do
7
2
  gem "activerecord", "~> 3.0.11"
3
+ gem 'mysql2', '< 0.3'
8
4
  end
9
5
 
10
6
  appraise "rails31" do
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ar-octopus.gemspec
4
4
  gemspec
@@ -5,7 +5,7 @@
5
5
  Octopus is a better way to do Database Sharding in ActiveRecord. Sharding allows multiple databases in the same rails application. While there are several projects that implement Sharding (e.g. DbCharmer, DataFabric, MultiDb), each project has its own limitations. The main goal of octopus project is to provide a better way of doing Database Sharding.
6
6
 
7
7
  ## Feature list:
8
- The api is designed to be simple as possible. Octopus focuses on the end user, giving the power of multiple databases but with reliable code and flexibility. Octopus is focused on Rails 3, but is compatible with Rails 2.x.
8
+ The api is designed to be simple as possible. Octopus focuses on the end user, giving the power of multiple databases but with reliable code and flexibility. Octopus is compatible with Rails 3.
9
9
 
10
10
  Octopus supports:
11
11
 
@@ -25,27 +25,11 @@ When using replication, all writes queries will be sent to master, and read quer
25
25
 
26
26
  ## Install
27
27
 
28
- ### Rails 2.x
29
-
30
- Install the octopus gem:
31
-
32
- sudo gem install ar-octopus
33
-
34
- Add this line to enviroment.rb:
35
-
36
- config.gem 'ar-octopus', :lib => "octopus"
37
-
38
- ### Rails 3.x
39
-
40
28
  Add this line to Gemfile:
41
29
 
42
30
  gem 'ar-octopus', :require => 'octopus'
43
31
 
44
- **Note**: The `ar-octopus` gem build is out of date. Until a new build is created, we recommend using the gem from this repo by placing `gem "ar-octopus", github: "tchandy/octopus", require: "octopus"` in your Gemfile instead of the above line. Alternatively you can [create your own fork](https://github.com/tchandy/octopus/fork_select) (for added stability against changes to master) and reference that fork from your Gemfile: `gem "ar-octopus", github: "<fork owner>/octopus", require: "octopus"`.
45
-
46
- Run a bundle install:
47
-
48
- bundle install
32
+ Currently, Octopus doesn't support Rails 2. If you need support for rails 2, please use the version 0.5.0.
49
33
 
50
34
  ## Upgrading
51
35
 
@@ -63,10 +47,6 @@ master database to each of the shards:
63
47
  Once the task completes migrations will operate normally and schema information will be stored in each shard database
64
48
  going forward.
65
49
 
66
- In order to run this task in Rails 2.3, you'll need to tell Rails to load Octopus' rake tasks by adding this to your `Rakefile`:
67
-
68
- Dir["#{Gem.searcher.find('ar-octopus').full_gem_path}/lib/tasks/**/*.rake"].each { |ext| load ext }
69
-
70
50
  ## How to use Octopus?
71
51
 
72
52
  First, you need to create a config file, shards.yml, inside your config/ directory. to see the syntax and how this file should look, please checkout <a href="http://wiki.github.com/tchandy/octopus/config-file">this page on wiki</a>.
@@ -185,7 +165,7 @@ Contributors are welcome! To run the test suite, you need mysql, postgresql and
185
165
  bundle exec rake appraisal:install
186
166
  bundle exec rake spec
187
167
 
188
- This command will run the spec suite for all rails versions supported (Rails 2.3, Rails 3.0 and Rails 3.1).
168
+ This command will run the spec suite for all rails versions supported (Rails 3.0, Rails 3.1 and Rails 3.2).
189
169
  To run our integrations tests inside sample_app, you need to following commands:
190
170
 
191
171
  cd sample_app
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ namespace :db do
18
18
  }
19
19
 
20
20
  mysql_spec = {
21
- :adapter => 'mysql',
21
+ :adapter => 'mysql2',
22
22
  :host => 'localhost',
23
23
  :username => (ENV['MYSQL_USER'] || "root"),
24
24
  :encoding => 'utf8'
@@ -21,11 +21,11 @@ Gem::Specification.new do |s|
21
21
  "Octopus now stores schema version information in each shard and migrations will not " \
22
22
  "work properly unless this task is invoked."
23
23
 
24
- s.add_dependency 'activerecord', '>= 2.3.0'
25
- s.add_dependency 'activesupport', '>= 2.3.0'
24
+ s.add_dependency 'activerecord', '>= 3.0.0', '< 4.0'
25
+ s.add_dependency 'activesupport', '>= 3.0.0', '< 4.0'
26
26
  s.add_development_dependency 'rake', '>= 0.8.7'
27
27
  s.add_development_dependency 'rspec', '>= 2.0.0'
28
- s.add_development_dependency 'mysql', '2.8.1'
28
+ s.add_development_dependency 'mysql2', '> 0.3'
29
29
  s.add_development_dependency 'pg', '>= 0.11.0'
30
30
  s.add_development_dependency 'sqlite3', '>= 1.3.4'
31
31
  s.add_development_dependency 'pry'
@@ -64,14 +64,6 @@ module Octopus
64
64
  @environments ||= config['environments'] || ['production']
65
65
  end
66
66
 
67
- def self.rails2?
68
- ActiveRecord::VERSION::MAJOR == 2
69
- end
70
-
71
- def self.rails3?
72
- ActiveRecord::VERSION::MAJOR == 3
73
- end
74
-
75
67
  def self.rails30?
76
68
  ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0
77
69
  end
@@ -110,23 +102,14 @@ require "octopus/migration"
110
102
  require "octopus/association_collection"
111
103
  require "octopus/has_and_belongs_to_many_association"
112
104
  require "octopus/association"
113
-
114
- if Octopus.rails2?
115
- require "octopus/rails2/association"
116
- require "octopus/rails2/persistence"
117
- require "octopus/rails2/scope"
118
- end
119
-
120
- if Octopus.rails3?
121
- require "octopus/rails3/persistence"
122
- require "octopus/rails3/log_subscriber"
123
- require "octopus/rails3/abstract_adapter"
124
- require "octopus/railtie"
125
- end
105
+ require "octopus/rails3/persistence"
106
+ require "octopus/rails3/log_subscriber"
107
+ require "octopus/rails3/abstract_adapter"
108
+ require "octopus/railtie"
126
109
 
127
110
  if Octopus.rails30?
128
- require "octopus/rails2/association"
129
- require "octopus/rails3/arel"
111
+ require "octopus/rails3.0/arel"
112
+ require "octopus/rails3.0/association"
130
113
  end
131
114
 
132
115
  if Octopus.rails31? || Octopus.rails32?
@@ -139,4 +122,3 @@ end
139
122
 
140
123
  require "octopus/proxy"
141
124
  require "octopus/scope_proxy"
142
- require "octopus/logger"
@@ -1,11 +1,6 @@
1
1
  require "set"
2
2
  require "active_support/core_ext/module/aliasing"
3
-
4
- if Octopus.rails2?
5
- require "active_support/core_ext/array/wrapper"
6
- else
7
- require "active_support/core_ext/array/wrap"
8
- end
3
+ require "active_support/core_ext/array/wrap"
9
4
 
10
5
  module Octopus::Migration
11
6
  module InstanceOrClassMethods
@@ -16,10 +16,8 @@ module Octopus::Model
16
16
  self.reset_table_name()
17
17
  end
18
18
 
19
- if Octopus.rails3?
20
- self.reset_column_information
21
- self.instance_variable_set(:@quoted_table_name, nil)
22
- end
19
+ self.reset_column_information
20
+ self.instance_variable_set(:@quoted_table_name, nil)
23
21
  end
24
22
 
25
23
  def using(shard)
@@ -45,13 +43,7 @@ module Octopus::Model
45
43
  end
46
44
  end
47
45
 
48
- if Octopus.rails3?
49
- after_initialize :set_current_shard
50
- else
51
- def after_initialize
52
- set_current_shard()
53
- end
54
- end
46
+ after_initialize :set_current_shard
55
47
  end
56
48
 
57
49
  def hijack_connection()
@@ -170,5 +162,3 @@ module Octopus::Model
170
162
  end
171
163
 
172
164
  ActiveRecord::Base.extend(Octopus::Model)
173
-
174
- class OctopusModel < ActiveRecord::Base; end;
File without changes
@@ -1,5 +1,5 @@
1
1
  module Octopus
2
- module Rails2
2
+ module Rails3
3
3
  module Association
4
4
  def association_accessor_methods(reflection, association_proxy_class)
5
5
  super
@@ -83,4 +83,4 @@ module Octopus
83
83
  end
84
84
  end
85
85
 
86
- ActiveRecord::Base.extend(Octopus::Rails2::Association)
86
+ ActiveRecord::Base.extend(Octopus::Rails3::Association)
@@ -1,3 +1,3 @@
1
1
  module Octopus
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -1,5 +1,5 @@
1
1
  mysql: &mysql
2
- adapter: mysql
2
+ adapter: mysql2
3
3
  username: <%= ENV['MYSQL_USER'] || 'root' %>
4
4
  host: localhost
5
5
 
@@ -15,6 +15,7 @@ octopus:
15
15
  password:
16
16
  database: octopus_shard_1
17
17
  encoding: unicode
18
+ host: localhost
18
19
 
19
20
  sqlite_shard:
20
21
  adapter: sqlite3
@@ -47,15 +47,13 @@ describe Octopus::Association, :shards => [:brazil, :master, :canada] do
47
47
  k.computer.should == c
48
48
  end
49
49
 
50
- if Octopus.rails3?
51
- it "should include models" do
52
- c = Computer.using(:brazil).create!(:name => "Computer Brazil")
53
- k = c.create_keyboard(:name => "Building keyboard")
54
- c.save()
55
- k.save()
50
+ it "should include models" do
51
+ c = Computer.using(:brazil).create!(:name => "Computer Brazil")
52
+ k = c.create_keyboard(:name => "Building keyboard")
53
+ c.save()
54
+ k.save()
56
55
 
57
- Computer.includes(:keyboard).find(c.id).should == c
58
- end
56
+ Computer.includes(:keyboard).find(c.id).should == c
59
57
  end
60
58
  end
61
59
 
@@ -110,11 +108,9 @@ describe Octopus::Association, :shards => [:brazil, :master, :canada] do
110
108
  @permission_brazil_2.roles.to_set.should == [@role].to_set
111
109
  end
112
110
 
113
- if !Octopus.rails3?
114
- it "update_attribute" do
115
- @permission_brazil_2.update_attribute(:role_ids, [@role.id])
116
- @permission_brazil_2.roles.to_set.should == [@role].to_set
117
- end
111
+ it "update_attribute" do
112
+ @permission_brazil_2.update_attribute(:role_ids, [@role.id])
113
+ @permission_brazil_2.roles.to_set.should == [@role].to_set
118
114
  end
119
115
 
120
116
  it "<<" do
@@ -265,11 +261,9 @@ describe Octopus::Association, :shards => [:brazil, :master, :canada] do
265
261
  @new_brazil_programmer.projects.to_set.should == [@project].to_set
266
262
  end
267
263
 
268
- if !Octopus.rails3?
269
- it "update_attribute" do
270
- @new_brazil_programmer.update_attribute(:project_ids, [@project.id])
271
- @new_brazil_programmer.projects.to_set.should == [@project].to_set
272
- end
264
+ it "update_attribute" do
265
+ @new_brazil_programmer.update_attribute(:project_ids, [@project.id])
266
+ @new_brazil_programmer.projects.to_set.should == [@project].to_set
273
267
  end
274
268
 
275
269
  it "<<" do
@@ -430,11 +424,9 @@ describe Octopus::Association, :shards => [:brazil, :master, :canada] do
430
424
  @brazil_client.items.to_set.should == [@item_brazil, @item_brazil_2].to_set
431
425
  end
432
426
 
433
- if !Octopus.rails3?
434
- it "update_attribute" do
435
- @brazil_client.update_attribute(:item_ids, [@item_brazil_2.id, @item_brazil.id])
436
- @brazil_client.items.to_set.should == [@item_brazil, @item_brazil_2].to_set
437
- end
427
+ it "update_attribute" do
428
+ @brazil_client.update_attribute(:item_ids, [@item_brazil_2.id, @item_brazil.id])
429
+ @brazil_client.items.to_set.should == [@item_brazil, @item_brazil_2].to_set
438
430
  end
439
431
 
440
432
  it "<<" do
@@ -568,11 +560,9 @@ describe Octopus::Association, :shards => [:brazil, :master, :canada] do
568
560
  @brazil_client.comments.to_set.should == [@comment_brazil, @comment_brazil_2].to_set
569
561
  end
570
562
 
571
- if !Octopus.rails3?
572
- it "update_attribute" do
573
- @brazil_client.update_attribute(:comment_ids, [@comment_brazil_2.id, @comment_brazil.id])
574
- @brazil_client.comments.to_set.should == [@comment_brazil, @comment_brazil_2].to_set
575
- end
563
+ it "update_attribute" do
564
+ @brazil_client.update_attribute(:comment_ids, [@comment_brazil_2.id, @comment_brazil.id])
565
+ @brazil_client.comments.to_set.should == [@comment_brazil, @comment_brazil_2].to_set
576
566
  end
577
567
 
578
568
  it "<<" do
@@ -1,22 +1,19 @@
1
1
  require "spec_helper"
2
2
 
3
- if Octopus.rails3?
4
- describe Octopus::LogSubscriber, :shards => [:canada] do
5
-
6
- before :each do
7
- @out = StringIO.new
8
- @log = Logger.new(@out)
9
- ActiveRecord::Base.logger = @log
10
- ActiveRecord::Base.logger.level = Logger::DEBUG
11
- end
3
+ describe Octopus::LogSubscriber, :shards => [:canada] do
4
+ before :each do
5
+ @out = StringIO.new
6
+ @log = Logger.new(@out)
7
+ ActiveRecord::Base.logger = @log
8
+ ActiveRecord::Base.logger.level = Logger::DEBUG
9
+ end
12
10
 
13
- after :each do
14
- ActiveRecord::Base.logger = nil
15
- end
11
+ after :each do
12
+ ActiveRecord::Base.logger = nil
13
+ end
16
14
 
17
- it "should add to the default logger the shard name the query was sent to" do
18
- User.using(:canada).create!(:name => "test")
19
- @out.string.should =~ /Shard: canada/
20
- end
15
+ it "should add to the default logger the shard name the query was sent to" do
16
+ User.using(:canada).create!(:name => "test")
17
+ @out.string.should =~ /Shard: canada/
21
18
  end
22
19
  end
@@ -256,7 +256,7 @@ describe Octopus::Model do
256
256
  it "should update the Arel Engine" do
257
257
  if ActiveRecord::VERSION::STRING > '2.4.0'
258
258
  User.using(:postgresql_shard).arel_engine.connection.adapter_name.should == "PostgreSQL"
259
- User.using(:alone_shard).arel_engine.connection.adapter_name.should == "MySQL"
259
+ User.using(:alone_shard).arel_engine.connection.adapter_name.should == "Mysql2"
260
260
  end
261
261
  end
262
262
 
@@ -338,44 +338,41 @@ describe Octopus::Model do
338
338
  User.using(:master).maximum(:number).should == 12
339
339
  end
340
340
 
341
- if Octopus.rails3?
342
- describe "any?" do
343
- before { User.using(:brazil).create!(:name => "User1") }
344
-
345
- it "works when true" do
346
- scope = User.using(:brazil).where(:name => "User1")
347
- scope.any?.should be_true
348
- end
341
+ describe "any?" do
342
+ before { User.using(:brazil).create!(:name => "User1") }
349
343
 
350
- it "works when false" do
351
- scope = User.using(:brazil).where(:name => "User2")
352
- scope.any?.should be_false
353
- end
344
+ it "works when true" do
345
+ scope = User.using(:brazil).where(:name => "User1")
346
+ scope.any?.should be_true
354
347
  end
355
348
 
356
- it "exists?" do
357
- @user = User.using(:brazil).create!(:name => "User1")
358
-
359
- User.using(:brazil).where(:name => "User1").exists?.should be_true
360
- User.using(:brazil).where(:name => "User2").exists?.should be_false
349
+ it "works when false" do
350
+ scope = User.using(:brazil).where(:name => "User2")
351
+ scope.any?.should be_false
361
352
  end
353
+ end
362
354
 
363
- describe "touch" do
364
- it "updates updated_at by default" do
365
- @user = User.using(:brazil).create!(:name => "User1")
366
- User.using(:brazil).update_all({:updated_at => Time.now - 3.months}, {:id => @user.id})
367
- @user.touch
368
- @user.reload.updated_at.to_date.should eq(Date.today)
369
- end
355
+ it "exists?" do
356
+ @user = User.using(:brazil).create!(:name => "User1")
370
357
 
371
- it "updates passed in attribute name" do
372
- @user = User.using(:brazil).create!(:name => "User1")
373
- User.using(:brazil).update_all({:created_at => Time.now - 3.months}, {:id => @user.id})
374
- @user.touch(:created_at)
375
- @user.reload.created_at.to_date.should eq(Date.today)
376
- end
358
+ User.using(:brazil).where(:name => "User1").exists?.should be_true
359
+ User.using(:brazil).where(:name => "User2").exists?.should be_false
360
+ end
361
+
362
+ describe "touch" do
363
+ it "updates updated_at by default" do
364
+ @user = User.using(:brazil).create!(:name => "User1")
365
+ User.using(:brazil).update_all({:updated_at => Time.now - 3.months}, {:id => @user.id})
366
+ @user.touch
367
+ @user.reload.updated_at.to_date.should eq(Date.today)
377
368
  end
378
369
 
370
+ it "updates passed in attribute name" do
371
+ @user = User.using(:brazil).create!(:name => "User1")
372
+ User.using(:brazil).update_all({:created_at => Time.now - 3.months}, {:id => @user.id})
373
+ @user.touch(:created_at)
374
+ @user.reload.created_at.to_date.should eq(Date.today)
375
+ end
379
376
  end
380
377
 
381
378
  if Octopus.rails32?
@@ -526,10 +523,8 @@ describe Octopus::Model do
526
523
  end
527
524
 
528
525
  it "should work using the rails 3.x syntax" do
529
- if Octopus.rails3?
530
- items = Item.using(:canada).joins(:client).where("clients.id = #{@client2.id}").all
531
- items.should == [@item1, @item2]
532
- end
526
+ items = Item.using(:canada).joins(:client).where("clients.id = #{@client2.id}").all
527
+ items.should == [@item1, @item2]
533
528
  end
534
529
 
535
530
  it "should work for include also, rails 2.x syntax" do
@@ -538,10 +533,8 @@ describe Octopus::Model do
538
533
  end
539
534
 
540
535
  it "should work for include also, rails 3.x syntax" do
541
- if Octopus.rails3?
542
- items = Item.using(:canada).includes(:client).where("clients.id = #{@client2.id}").all
543
- items.should == [@item1, @item2]
544
- end
536
+ items = Item.using(:canada).includes(:client).where("clients.id = #{@client2.id}").all
537
+ items.should == [@item1, @item2]
545
538
  end
546
539
 
547
540
  it "should work for multiple includes, with rails 2.x syntax" do
@@ -41,7 +41,7 @@ describe Octopus, :shards => [] do
41
41
  lambda { User.using(:crazy_shard).create!(:name => "Joaquim") }.should raise_error
42
42
 
43
43
  Octopus.setup do |config|
44
- config.shards = {:crazy_shard => {:adapter => "mysql", :database => "octopus_shard_5", :username => "root", :password => ""}}
44
+ config.shards = {:crazy_shard => {:adapter => "mysql2", :database => "octopus_shard_5", :username => "root", :password => ""}}
45
45
  end
46
46
 
47
47
  lambda { User.using(:crazy_shard).create!(:name => "Joaquim") }.should_not raise_error
@@ -32,7 +32,7 @@ describe Octopus::Proxy do
32
32
 
33
33
  it "should work with thiking sphinx" do
34
34
  config = proxy.instance_variable_get(:@config)
35
- config[:adapter].should == "mysql"
35
+ config[:adapter].should == "mysql2"
36
36
  config[:database].should == "octopus_shard_1"
37
37
  config[:username].should == "root"
38
38
  end
@@ -40,7 +40,7 @@ describe Octopus::Proxy do
40
40
  it 'should create a set with all adapters, to ensure that is needed to clean the table name.' do
41
41
  adapters = proxy.instance_variable_get(:@adapters)
42
42
  adapters.should be_kind_of(Set)
43
- adapters.to_a.should =~ ["sqlite3", "mysql", "postgresql"]
43
+ adapters.to_a.should =~ ["sqlite3", "mysql2", "postgresql"]
44
44
  end
45
45
 
46
46
  it 'should respond correctly to respond_to?(:pk_and_sequence_for)' do
@@ -2,15 +2,13 @@ require "spec_helper"
2
2
 
3
3
  describe Octopus::ScopeProxy do
4
4
  it "should allow nested queries" do
5
- if Octopus.rails3?
6
- @user1 = User.using(:brazil).create!(:name => "Thiago P", :number => 3)
7
- @user2 = User.using(:brazil).create!(:name => "Thiago", :number => 1)
8
- @user3 = User.using(:brazil).create!(:name => "Thiago", :number => 2)
5
+ @user1 = User.using(:brazil).create!(:name => "Thiago P", :number => 3)
6
+ @user2 = User.using(:brazil).create!(:name => "Thiago", :number => 1)
7
+ @user3 = User.using(:brazil).create!(:name => "Thiago", :number => 2)
9
8
 
10
- User.using(:brazil).where(:name => "Thiago").where(:number => 4).order(:number).all.should == []
11
- User.using(:brazil).where(:name => "Thiago").using(:canada).where(:number => 2).using(:brazil).order(:number).all.should == [@user3]
12
- User.using(:brazil).where(:name => "Thiago").using(:canada).where(:number => 4).using(:brazil).order(:number).all.should == []
13
- end
9
+ User.using(:brazil).where(:name => "Thiago").where(:number => 4).order(:number).all.should == []
10
+ User.using(:brazil).where(:name => "Thiago").using(:canada).where(:number => 2).using(:brazil).order(:number).all.should == [@user3]
11
+ User.using(:brazil).where(:name => "Thiago").using(:canada).where(:number => 4).using(:brazil).order(:number).all.should == []
14
12
  end
15
13
 
16
14
  it "should raise a exception when trying to send a query to a shard that don't exists" do
@@ -1,2 +1,4 @@
1
- ActiveRecord::Base.establish_connection(:adapter => "mysql", :database => "octopus_shard_1", :username => "root", :password => "")
1
+ require "logger"
2
+
3
+ ActiveRecord::Base.establish_connection(:adapter => "mysql2", :database => "octopus_shard_1", :username => "root", :password => "")
2
4
  ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'a'))
@@ -31,7 +31,7 @@ end
31
31
 
32
32
  #This class sets its own connection
33
33
  class CustomConnection < ActiveRecord::Base
34
- octopus_establish_connection(:adapter => "mysql", :database => "octopus_shard_2", :username => "root", :password => "")
34
+ octopus_establish_connection(:adapter => "mysql2", :database => "octopus_shard_2", :username => "root", :password => "")
35
35
  end
36
36
 
37
37
  #This items belongs to a client
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-octopus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-05-07 00:00:00.000000000 Z
14
+ date: 2013-07-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord
@@ -20,7 +20,10 @@ dependencies:
20
20
  requirements:
21
21
  - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
- version: 2.3.0
23
+ version: 3.0.0
24
+ - - <
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
24
27
  type: :runtime
25
28
  prerelease: false
26
29
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,7 +31,10 @@ dependencies:
28
31
  requirements:
29
32
  - - ! '>='
30
33
  - !ruby/object:Gem::Version
31
- version: 2.3.0
34
+ version: 3.0.0
35
+ - - <
36
+ - !ruby/object:Gem::Version
37
+ version: '4.0'
32
38
  - !ruby/object:Gem::Dependency
33
39
  name: activesupport
34
40
  requirement: !ruby/object:Gem::Requirement
@@ -36,7 +42,10 @@ dependencies:
36
42
  requirements:
37
43
  - - ! '>='
38
44
  - !ruby/object:Gem::Version
39
- version: 2.3.0
45
+ version: 3.0.0
46
+ - - <
47
+ - !ruby/object:Gem::Version
48
+ version: '4.0'
40
49
  type: :runtime
41
50
  prerelease: false
42
51
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +53,10 @@ dependencies:
44
53
  requirements:
45
54
  - - ! '>='
46
55
  - !ruby/object:Gem::Version
47
- version: 2.3.0
56
+ version: 3.0.0
57
+ - - <
58
+ - !ruby/object:Gem::Version
59
+ version: '4.0'
48
60
  - !ruby/object:Gem::Dependency
49
61
  name: rake
50
62
  requirement: !ruby/object:Gem::Requirement
@@ -78,21 +90,21 @@ dependencies:
78
90
  - !ruby/object:Gem::Version
79
91
  version: 2.0.0
80
92
  - !ruby/object:Gem::Dependency
81
- name: mysql
93
+ name: mysql2
82
94
  requirement: !ruby/object:Gem::Requirement
83
95
  none: false
84
96
  requirements:
85
- - - '='
97
+ - - ! '>'
86
98
  - !ruby/object:Gem::Version
87
- version: 2.8.1
99
+ version: '0.3'
88
100
  type: :development
89
101
  prerelease: false
90
102
  version_requirements: !ruby/object:Gem::Requirement
91
103
  none: false
92
104
  requirements:
93
- - - '='
105
+ - - ! '>'
94
106
  - !ruby/object:Gem::Version
95
- version: 2.8.1
107
+ version: '0.3'
96
108
  - !ruby/object:Gem::Dependency
97
109
  name: pg
98
110
  requirement: !ruby/object:Gem::Requirement
@@ -183,17 +195,14 @@ files:
183
195
  - lib/octopus/association.rb
184
196
  - lib/octopus/association_collection.rb
185
197
  - lib/octopus/has_and_belongs_to_many_association.rb
186
- - lib/octopus/logger.rb
187
198
  - lib/octopus/migration.rb
188
199
  - lib/octopus/model.rb
189
200
  - lib/octopus/proxy.rb
190
- - lib/octopus/rails2/association.rb
191
- - lib/octopus/rails2/persistence.rb
192
- - lib/octopus/rails2/scope.rb
201
+ - lib/octopus/rails3.0/arel.rb
202
+ - lib/octopus/rails3.0/association.rb
193
203
  - lib/octopus/rails3.1/singular_association.rb
194
204
  - lib/octopus/rails3.2/persistence.rb
195
205
  - lib/octopus/rails3/abstract_adapter.rb
196
- - lib/octopus/rails3/arel.rb
197
206
  - lib/octopus/rails3/log_subscriber.rb
198
207
  - lib/octopus/rails3/persistence.rb
199
208
  - lib/octopus/railtie.rb
@@ -283,7 +292,6 @@ files:
283
292
  - spec/migrations/9_raise_exception_with_multiple_invalid_group_names.rb
284
293
  - spec/octopus/association_spec.rb
285
294
  - spec/octopus/log_subscriber_spec.rb
286
- - spec/octopus/logger_spec.rb
287
295
  - spec/octopus/migration_spec.rb
288
296
  - spec/octopus/model_spec.rb
289
297
  - spec/octopus/octopus_spec.rb
@@ -318,7 +326,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
318
326
  version: '0'
319
327
  segments:
320
328
  - 0
321
- hash: 1814625454077145936
329
+ hash: 4146827815938397379
322
330
  required_rubygems_version: !ruby/object:Gem::Requirement
323
331
  none: false
324
332
  requirements:
@@ -327,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
327
335
  version: '0'
328
336
  segments:
329
337
  - 0
330
- hash: 1814625454077145936
338
+ hash: 4146827815938397379
331
339
  requirements: []
332
340
  rubyforge_project:
333
341
  rubygems_version: 1.8.24
@@ -352,7 +360,6 @@ test_files:
352
360
  - spec/migrations/9_raise_exception_with_multiple_invalid_group_names.rb
353
361
  - spec/octopus/association_spec.rb
354
362
  - spec/octopus/log_subscriber_spec.rb
355
- - spec/octopus/logger_spec.rb
356
363
  - spec/octopus/migration_spec.rb
357
364
  - spec/octopus/model_spec.rb
358
365
  - spec/octopus/octopus_spec.rb
@@ -1,19 +0,0 @@
1
- require "logger"
2
-
3
- class Octopus::Logger < Logger
4
- def initialize(logdev, shift_age = 0, shift_size = 1048576)
5
- ActiveSupport::Deprecation.warn "Octopus::Logger is deprecated and will be removed in Octopus 0.6.x", caller
6
- super
7
- end
8
-
9
- def format_message(severity, timestamp, progname, msg)
10
- str = super
11
-
12
- if ActiveRecord::Base.connection.respond_to?(:current_shard)
13
- str += "Shard: #{ActiveRecord::Base.connection.current_shard} -"
14
- end
15
-
16
- str
17
- end
18
- end
19
-
@@ -1,39 +0,0 @@
1
- module Octopus
2
- module Rails2
3
- module Persistence
4
- def self.included(base)
5
- base.instance_eval do
6
- alias_method_chain :destroy, :octopus
7
- alias_method_chain :delete, :octopus
8
- alias_method_chain :reload, :octopus
9
- end
10
- end
11
-
12
- def delete_with_octopus()
13
- if should_set_current_shard?
14
- Octopus.using(self.current_shard) { delete_without_octopus() }
15
- else
16
- delete_without_octopus()
17
- end
18
- end
19
-
20
- def destroy_with_octopus()
21
- if should_set_current_shard?
22
- Octopus.using(self.current_shard) { destroy_without_octopus() }
23
- else
24
- destroy_without_octopus()
25
- end
26
- end
27
-
28
- def reload_with_octopus(options = nil)
29
- if should_set_current_shard?
30
- Octopus.using(self.current_shard) { reload_without_octopus(options) }
31
- else
32
- reload_without_octopus(options)
33
- end
34
- end
35
- end
36
- end
37
- end
38
-
39
- ActiveRecord::Base.send(:include, Octopus::Rails2::Persistence)
@@ -1,17 +0,0 @@
1
- module Octopus
2
- module Rails2
3
- module Scope
4
- def self.included(base)
5
- base.instance_eval do
6
- alias_method_chain :proxy_found, :octopus
7
- end
8
- end
9
-
10
- def proxy_found_with_octopus
11
- load_found
12
- end
13
- end
14
- end
15
- end
16
-
17
- ActiveRecord::NamedScope::Scope.send(:include, Octopus::Rails2::Scope)
@@ -1,32 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Octopus::Logger, :shards => [:canada] do
4
- before :each do
5
- @out = StringIO.new
6
- @log = Octopus::Logger.new(@out)
7
- ActiveRecord::Base.logger = @log
8
- end
9
-
10
- after :each do
11
- ActiveRecord::Base.logger = nil
12
- end
13
-
14
- if Octopus.rails3?
15
- it "should add to the default logger what shard the query was sent" do
16
- User.using(:canada).create!(:name => "test")
17
- @out.string.should =~ /Shard: canada/
18
- end
19
- end
20
-
21
- it "should be deprecated" do
22
- @last_message = nil
23
- ActiveSupport::Deprecation.behavior = Proc.new { |message| @last_message = message }
24
- @log = Octopus::Logger.new(@out)
25
-
26
- if @last_message.is_a?(Array)
27
- @last_message.first.should =~ /DEPRECATION WARNING: Octopus::Logger is deprecated and will be removed in Octopus 0\.6\.x\./
28
- else
29
- @last_message.should =~ /DEPRECATION WARNING: Octopus::Logger is deprecated and will be removed in Octopus 0\.6\.x\./
30
- end
31
- end
32
- end