activerecord_url_connections 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/lib/activerecord_url_connections.rb +1 -1
- data/lib/activerecord_url_connections/version.rb +1 -1
- data/test/connection_test.rb +12 -12
- metadata +38 -40
data/Gemfile
CHANGED
@@ -9,7 +9,7 @@ module ActiveRecordURLConnections
|
|
9
9
|
:password => config.password,
|
10
10
|
:port => config.port,
|
11
11
|
:database => config.path.sub(%r{^/},""),
|
12
|
-
:
|
12
|
+
:host => config.host }
|
13
13
|
spec.reject!{ |key,value| value.nil? }
|
14
14
|
spec.merge!(split_query_options(config.query))
|
15
15
|
spec
|
data/test/connection_test.rb
CHANGED
@@ -18,18 +18,18 @@ class TestConnection < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def spec_hash(opts = {})
|
21
|
-
default_spec = { :adapter => "
|
21
|
+
default_spec = { :adapter => "postgresql",
|
22
22
|
:username => "user",
|
23
23
|
:password => "secret",
|
24
|
-
:
|
24
|
+
:host => "localhost",
|
25
25
|
:database => "mydatabase" }
|
26
26
|
default_spec.merge!(opts)
|
27
27
|
default_spec
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_generic_url_connection
|
31
|
-
connection_spec = mock_connection_spec(spec_hash, "
|
32
|
-
url = "
|
31
|
+
connection_spec = mock_connection_spec(spec_hash, "postgresql_connection")
|
32
|
+
url = "postgresql://user:secret@localhost/mydatabase"
|
33
33
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.any_instance.
|
34
34
|
expects(:establish_connection).with("ActiveRecord::Base", connection_spec)
|
35
35
|
ActiveRecord::Base.establish_connection(url)
|
@@ -37,7 +37,7 @@ class TestConnection < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
def test_works_with_traditional_hash_spec
|
39
39
|
spec = spec_hash
|
40
|
-
connection_spec = mock_connection_spec(spec, "
|
40
|
+
connection_spec = mock_connection_spec(spec, "postgresql_connection")
|
41
41
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.any_instance.
|
42
42
|
expects(:establish_connection).with("ActiveRecord::Base", connection_spec)
|
43
43
|
ActiveRecord::Base.establish_connection(spec)
|
@@ -61,11 +61,11 @@ class TestConnection < Test::Unit::TestCase
|
|
61
61
|
|
62
62
|
def test_supports_additional_options_as_params
|
63
63
|
spec = spec_hash(:encoding => "utf8",
|
64
|
-
:
|
64
|
+
:host => "remotehost.example.org",
|
65
65
|
:port => 3133,
|
66
66
|
:random_key => "blah")
|
67
|
-
connection_spec = mock_connection_spec(spec, "
|
68
|
-
url = "
|
67
|
+
connection_spec = mock_connection_spec(spec, "postgresql_connection")
|
68
|
+
url = "postgresql://user:secret@remotehost.example.org:3133/mydatabase?encoding=utf8&random_key=blah"
|
69
69
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.any_instance.
|
70
70
|
expects(:establish_connection).with("ActiveRecord::Base", connection_spec)
|
71
71
|
ActiveRecord::Base.establish_connection(url)
|
@@ -75,17 +75,17 @@ class TestConnection < Test::Unit::TestCase
|
|
75
75
|
spec = spec_hash
|
76
76
|
spec.delete(:username)
|
77
77
|
spec.delete(:password)
|
78
|
-
connection_spec = mock_connection_spec(spec, "
|
79
|
-
url = "
|
78
|
+
connection_spec = mock_connection_spec(spec, "postgresql_connection")
|
79
|
+
url = "postgresql://localhost/mydatabase"
|
80
80
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.any_instance.
|
81
81
|
expects(:establish_connection).with("ActiveRecord::Base", connection_spec)
|
82
82
|
ActiveRecord::Base.establish_connection(url)
|
83
83
|
end
|
84
84
|
|
85
85
|
def test_use_environment_variable_if_no_spec_provided
|
86
|
-
url = "
|
86
|
+
url = "postgresql://user:secret@localhost/mydatabase"
|
87
87
|
ENV["DATABASE_URL"] = url
|
88
|
-
connection_spec = mock_connection_spec(spec_hash, "
|
88
|
+
connection_spec = mock_connection_spec(spec_hash, "postgresql_connection")
|
89
89
|
ActiveRecord::ConnectionAdapters::ConnectionHandler.any_instance.
|
90
90
|
expects(:establish_connection).with("ActiveRecord::Base", connection_spec)
|
91
91
|
ActiveRecord::Base.establish_connection
|
metadata
CHANGED
@@ -1,39 +1,35 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_url_connections
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
4
5
|
prerelease:
|
5
|
-
version: 0.0.5
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Glenn Gillen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-09-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: activerecord
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70200263670480 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :runtime
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70200263670480
|
25
|
+
description: Allows database connections to be defined as URLS, then converted to
|
26
|
+
hash for use in ActiveRecord
|
27
|
+
email:
|
29
28
|
- glenn@rubypond.com
|
30
29
|
executables: []
|
31
|
-
|
32
30
|
extensions: []
|
33
|
-
|
34
31
|
extra_rdoc_files: []
|
35
|
-
|
36
|
-
files:
|
32
|
+
files:
|
37
33
|
- .gitignore
|
38
34
|
- Gemfile
|
39
35
|
- Rakefile
|
@@ -42,33 +38,35 @@ files:
|
|
42
38
|
- lib/activerecord_url_connections.rb
|
43
39
|
- lib/activerecord_url_connections/version.rb
|
44
40
|
- test/connection_test.rb
|
45
|
-
|
46
|
-
homepage: ""
|
41
|
+
homepage: ''
|
47
42
|
licenses: []
|
48
|
-
|
49
43
|
post_install_message:
|
50
44
|
rdoc_options: []
|
51
|
-
|
52
|
-
require_paths:
|
45
|
+
require_paths:
|
53
46
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
48
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version:
|
60
|
-
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
hash: -4592356007819432443
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
57
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version:
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
hash: -4592356007819432443
|
66
65
|
requirements: []
|
67
|
-
|
68
66
|
rubyforge_project: activerecord_url_connections
|
69
|
-
rubygems_version: 1.
|
67
|
+
rubygems_version: 1.8.15
|
70
68
|
signing_key:
|
71
69
|
specification_version: 3
|
72
70
|
summary: Convert URLs into AR friendly hashes
|
73
|
-
test_files:
|
71
|
+
test_files:
|
74
72
|
- test/connection_test.rb
|