db-charmer 1.6.12 → 1.6.13

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ 1.6.13 (2010-08-17):
2
+
3
+ Starting with this version we use Rails.env instead of RAILS_ENV to auto-detect rails
4
+ environment. If you use DbCharmer in non-rails project, please set DbCharmer.env manually.
5
+
6
+ Bugfixes: Thanks to Eric Lindvall we now allow connection names that have symbols ruby
7
+ wouldn't like for class names.
8
+
9
+ ----------------------------------------------------------------------------------------
1
10
  1.6.12 (2010-05-09):
2
11
 
3
12
  Starting with this version we use Rails.cache (memcache or whatever you use in your project)
data/README.rdoc CHANGED
@@ -27,6 +27,10 @@ To install db-charmer as a Rails plugin use this:
27
27
 
28
28
  script/plugin install git://github.com/kovyrin/db-charmer.git
29
29
 
30
+ _Notice_: If you use db-charmer in a non-rails project, you may need to set <tt>DbCharmer.env</tt> to a correct value
31
+ before using any of its connection management methods. Correct value here is a valid <tt>database.yml</tt>
32
+ first-level section name.
33
+
30
34
 
31
35
  == Easy ActiveRecord Connection Management
32
36
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.12
1
+ 1.6.13
data/db-charmer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{db-charmer}
8
- s.version = "1.6.12"
8
+ s.version = "1.6.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexey Kovyrin"]
12
- s.date = %q{2010-05-09}
12
+ s.date = %q{2010-08-17}
13
13
  s.description = %q{ActiveRecord Connections Magic (slaves, multiple connections, etc)}
14
14
  s.email = %q{alexey@kovyrin.net}
15
15
  s.extra_rdoc_files = [
@@ -50,14 +50,14 @@ Gem::Specification.new do |s|
50
50
  s.homepage = %q{http://github.com/kovyrin/db-charmer}
51
51
  s.rdoc_options = ["--charset=UTF-8"]
52
52
  s.require_paths = ["lib"]
53
- s.rubygems_version = %q{1.3.6}
53
+ s.rubygems_version = %q{1.3.7}
54
54
  s.summary = %q{ActiveRecord Connections Magic}
55
55
 
56
56
  if s.respond_to? :specification_version then
57
57
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
58
  s.specification_version = 3
59
59
 
60
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
61
  s.add_runtime_dependency(%q<rails>, [">= 2.2.0"])
62
62
  s.add_runtime_dependency(%q<blankslate>, [">= 0"])
63
63
  else
data/lib/db_charmer.rb CHANGED
@@ -2,7 +2,7 @@ module DbCharmer
2
2
  @@connections_should_exist = true
3
3
  mattr_accessor :connections_should_exist
4
4
 
5
- @@env = defined?(RAILS_ENV) ? RAILS_ENV : 'development'
5
+ @@env = defined?(Rails) ? Rails.env : 'development'
6
6
  mattr_accessor :env
7
7
 
8
8
  def self.connections_should_exist?
@@ -4,13 +4,23 @@ module DbCharmer
4
4
 
5
5
  def establish_real_connection_if_exists(name, should_exist = false)
6
6
  name = name.to_s
7
- config = configurations[DbCharmer.env][name]
7
+
8
+ # Check environment name
9
+ config = configurations[DbCharmer.env]
10
+ unless config
11
+ error = "Invalid environment name (does not exist in database.yml): #{DbCharmer.env}. Please set correct Rails.env or DbCharmer.env."
12
+ raise ArgumentError, error
13
+ end
14
+
15
+ # Check connection name
16
+ config = config[name]
8
17
  unless config
9
18
  if should_exist
10
19
  raise ArgumentError, "Invalid connection name (does not exist in database.yml): #{DbCharmer.env}/#{name}"
11
20
  end
12
21
  return # No need to establish connection - they do not want us to
13
22
  end
23
+
14
24
  # Pass connection name with config
15
25
  config[:connection_name] = name
16
26
  establish_connection(config)
@@ -70,7 +70,7 @@ module DbCharmer
70
70
 
71
71
  # Generates unique names for our abstract AR classes
72
72
  def self.abstract_connection_class_name(connection_name)
73
- "::AutoGeneratedAbstractConnectionClass#{connection_name.to_s.camelize}"
73
+ "::AutoGeneratedAbstractConnectionClass#{connection_name.to_s.gsub(/\W+/, '_').camelize}"
74
74
  end
75
75
  end
76
76
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db-charmer
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 6
8
- - 12
9
- version: 1.6.12
9
+ - 13
10
+ version: 1.6.13
10
11
  platform: ruby
11
12
  authors:
12
13
  - Alexey Kovyrin
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-09 00:00:00 -04:00
18
+ date: 2010-08-17 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rails
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 7
27
30
  segments:
28
31
  - 2
29
32
  - 2
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: blankslate
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 3
41
46
  segments:
42
47
  - 0
43
48
  version: "0"
@@ -92,23 +97,27 @@ rdoc_options:
92
97
  require_paths:
93
98
  - lib
94
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
95
101
  requirements:
96
102
  - - ">="
97
103
  - !ruby/object:Gem::Version
104
+ hash: 3
98
105
  segments:
99
106
  - 0
100
107
  version: "0"
101
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
102
110
  requirements:
103
111
  - - ">="
104
112
  - !ruby/object:Gem::Version
113
+ hash: 3
105
114
  segments:
106
115
  - 0
107
116
  version: "0"
108
117
  requirements: []
109
118
 
110
119
  rubyforge_project:
111
- rubygems_version: 1.3.6
120
+ rubygems_version: 1.3.7
112
121
  signing_key:
113
122
  specification_version: 3
114
123
  summary: ActiveRecord Connections Magic