rails_multisite 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_multisite might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b91ecd19c63a8bd3634436ba33604e1a2feb4a9
4
- data.tar.gz: 3b9b415a943a1c85cf1720c6d322c50aa0d98947
3
+ metadata.gz: 9125f561ab7f58fb9685d8a1ef7501add2dc2617
4
+ data.tar.gz: 6e1cda42fb46f76466b3828fd7f8a7c27054dc34
5
5
  SHA512:
6
- metadata.gz: 37dbdf795601d4725c45cf797accf5fe32e312683700a16555c316d4d5d969919a0df7e73336d16eb230675b7383841ed896044b37e4234e67bf8d79c03a20bf
7
- data.tar.gz: 43c6c2ae975e6361670d277a180796d16d4d1a57bde686d36ca9f5ae3642e57343ab079fd49f1e51d567f4efd33fbc424c7bdf06ac5eaff44c6553c157575f6f
6
+ metadata.gz: 20bbec27a4d049bb250257bf6b3c3a354ff70617cac6eec973a1a64a8e888bea80ddfd9e169a1612d273059b20bb1400e22bbdd639c90e26d0c22ad80f5b4444
7
+ data.tar.gz: 37fa6cdbe00e7d32e20d8b10bac38e4f02350f3c6a2dd18f651c664caedebd3a8ea50e03143e0fcb57f7fb88b56a6f9063fd2af0b39eb69f7af0aad4824ad88e
data/README.md CHANGED
@@ -6,7 +6,7 @@ Using its middleware you can partition your app so each hostname has its own db.
6
6
 
7
7
  It provides a series of helper for working with multiple database, and some additional rails tasks for working with them.
8
8
 
9
- It was extracted from Discourse. http://discourse.org
9
+ It was extracted from Discourse. https://discourse.org
10
10
 
11
11
  ## Installation
12
12
 
@@ -26,8 +26,35 @@ Or install it yourself as:
26
26
 
27
27
  Configuration requires a file called: `config/multisite.yml` that specifies connection specs for all dbs.
28
28
 
29
+ ```
30
+ mlp:
31
+ adapter: postgresql
32
+ database: discourse_mlp
33
+ username: discourse_mlp
34
+ password: applejack
35
+ host: dbhost
36
+ pool: 5
37
+ timeout: 5000
38
+ db_id: 1 # ensure db_id is unique for each site
39
+ host_names:
40
+ - discourse.equestria.com
41
+ - discourse.equestria.internal
42
+
43
+ drwho:
44
+ adapter: postgresql
45
+ database: discourse_who
46
+ username: discourse_who
47
+ password: "Up the time stream without a TARDIS"
48
+ host: dbhost
49
+ pool: 5
50
+ timeout: 5000
51
+ db_id: 2# ensure db_id is unique for each site
52
+ host_names:
53
+ - discuss.tardis.gallifrey
54
+ ```
55
+
29
56
 
30
- ### Exectue a query on each connection
57
+ ### Execute a query on each connection
31
58
 
32
59
  ```
33
60
  RailsMultisite::ConnectionManagement.each_connection do |db|
@@ -1,3 +1,4 @@
1
1
  require "rails_multisite/version"
2
2
  require "rails_multisite/railtie"
3
+ require "rails_multisite/formatter"
3
4
  require "rails_multisite/connection_management"
@@ -61,7 +61,7 @@ module RailsMultisite
61
61
  rval
62
62
  end
63
63
 
64
- def self.with_connection(db = "default")
64
+ def self.with_connection(db = DEFAULT)
65
65
  old = current_db
66
66
  connected = ActiveRecord::Base.connection_pool.connected?
67
67
 
@@ -137,7 +137,7 @@ module RailsMultisite
137
137
  end
138
138
 
139
139
  def self.all_dbs
140
- ["default"] +
140
+ [DEFAULT] +
141
141
  if defined?(@@db_spec_cache) && @@db_spec_cache
142
142
  @@db_spec_cache.keys.to_a
143
143
  else
@@ -146,7 +146,7 @@ module RailsMultisite
146
146
  end
147
147
 
148
148
  def self.current_db
149
- ActiveRecord::Base.connection_pool.spec.config[:db_key] || "default"
149
+ ActiveRecord::Base.connection_pool.spec.config[:db_key] || DEFAULT
150
150
  end
151
151
 
152
152
  def self.config_filename=(config_filename)
@@ -175,7 +175,7 @@ module RailsMultisite
175
175
  no_prepared_statements = ActiveRecord::Base.configurations[Rails.env]["prepared_statements"] == false
176
176
 
177
177
  configs.each do |k,v|
178
- raise ArgumentError.new("Please do not name any db default!") if k == "default"
178
+ raise ArgumentError.new("Please do not name any db default!") if k == DEFAULT
179
179
  v[:db_key] = k
180
180
  v[:prepared_statements] = false if no_prepared_statements
181
181
  end
@@ -0,0 +1,7 @@
1
+ module RailsMultisite
2
+ class Formatter < ::ActiveSupport::Logger::SimpleFormatter
3
+ def call(severity, timestamp, progname, msg)
4
+ "[#{RailsMultisite::ConnectionManagement.current_db}] #{super}"
5
+ end
6
+ end
7
+ end
@@ -8,6 +8,7 @@ module RailsMultisite
8
8
  Rails.configuration.multisite = false
9
9
  if File.exists?(ConnectionManagement.config_filename)
10
10
  Rails.configuration.multisite = true
11
+ Rails.logger.formatter = RailsMultisite::Formatter.new
11
12
  ConnectionManagement.load_settings!
12
13
  app.middleware.insert_after(ActiveRecord::ConnectionAdapters::ConnectionManagement, RailsMultisite::ConnectionManagement)
13
14
  app.middleware.delete(ActiveRecord::ConnectionAdapters::ConnectionManagement)
@@ -16,8 +17,6 @@ module RailsMultisite
16
17
  end
17
18
  end
18
19
  end
19
-
20
-
21
20
  end
22
21
  end
23
22
 
@@ -1,3 +1,3 @@
1
1
  module RailsMultisite
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_multisite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Multi tenancy support for Rails
14
14
  email:
@@ -21,6 +21,7 @@ files:
21
21
  - README.md
22
22
  - lib/rails_multisite.rb
23
23
  - lib/rails_multisite/connection_management.rb
24
+ - lib/rails_multisite/formatter.rb
24
25
  - lib/rails_multisite/railtie.rb
25
26
  - lib/rails_multisite/version.rb
26
27
  - lib/tasks/db.rake
@@ -44,8 +45,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
45
  version: '0'
45
46
  requirements: []
46
47
  rubyforge_project:
47
- rubygems_version: 2.4.5.1
48
+ rubygems_version: 2.5.1
48
49
  signing_key:
49
50
  specification_version: 4
50
51
  summary: Multi tenancy support for Rails
51
52
  test_files: []
53
+ has_rdoc: