sequel_rails3 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -12,14 +12,14 @@ module SequelRails3
12
12
  end
13
13
 
14
14
  def normalize!
15
+ symbolize_keys!
16
+
15
17
  each_pair do |k, v|
16
- k = k.to_sym
17
18
  case k
18
19
  when :uri
19
20
  self[:url] = delete(:uri)
20
21
  when :adapter
21
- v = v.to_sym
22
- case v
22
+ case v.to_sym
23
23
  when :sqlite3
24
24
  self[k] = :sqlite
25
25
  when :postgresql
@@ -30,18 +30,25 @@ module SequelRails3
30
30
 
31
31
  # always use jdbc when running jruby
32
32
  if defined?(JRUBY_VERSION)
33
- self[:adapter] = "jdbc:#{self[:adapter]}"
33
+ if self[:adapter]
34
+ case self[:adapter].to_sym
35
+ when :postgres
36
+ self[:adapter] = :postgresql
37
+ end
38
+ self[:adapter] = "jdbc:#{self[:adapter]}"
39
+ end
34
40
  end
35
-
41
+
36
42
  # some adapters only support an url
37
- if self[:adapter] =~ "^(jdbc|do):"
38
- port = self[:port] ? ":#{self[:port]}" : ""
43
+ if self[:adapter] && self[:adapter] =~ /^(jdbc|do):/
39
44
  params = {}
40
45
  each_pair do |k, v|
41
- next if [].include?(:adapter, :host, :port, :database)
46
+ next if [:adapter, :host, :port, :database].include?(k)
42
47
  params[k] = v
43
48
  end
44
- self[:url] = "%s://%s%s/%s?%s" % [self[:adapter], self[:host], port, self[:database], params]
49
+ params_str = params.each_pair{ |k, v| "#{k}=#{v}" }
50
+ port = self[:port] ? ":#{self[:port]}" : ""
51
+ self[:url] = "%s://%s%s/%s?%s" % [self[:adapter], self[:host], port, self[:database], params_str]
45
52
  end
46
53
  end
47
54
  end
@@ -17,7 +17,7 @@ module SequelRails3
17
17
 
18
18
  Sequel::Model.plugin :active_model
19
19
 
20
- self.db = Sequel.connect(config)
20
+ self.db = config[:url] ? Sequel.connect(config[:url], config) : Sequel.connect(config)
21
21
  end
22
22
 
23
23
  initializer 'sequel_rails3.logging', :after => :initialize_logger do |app|
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sequel_rails3}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Corin Langosch"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Corin Langosch