sinatra-activerecord 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sinatra/activerecord.rb +8 -10
- metadata +3 -3
data/lib/sinatra/activerecord.rb
CHANGED
@@ -29,17 +29,15 @@ module Sinatra
|
|
29
29
|
def database_file=(path)
|
30
30
|
require 'pathname'
|
31
31
|
|
32
|
-
return if
|
33
|
-
path = File.join(
|
32
|
+
return if root.nil?
|
33
|
+
path = File.join(root, path) if Pathname.new(path).relative?
|
34
34
|
|
35
35
|
if File.exists?(path)
|
36
36
|
require 'yaml'
|
37
37
|
require 'erb'
|
38
38
|
|
39
39
|
database_hash = YAML.load(ERB.new(File.read(path)).result) || {}
|
40
|
-
|
41
|
-
database_hash = database_hash[environment.to_s]
|
42
|
-
end
|
40
|
+
database_hash = database_hash[environment.to_s] if database_hash[environment.to_s]
|
43
41
|
set :database, database_hash
|
44
42
|
end
|
45
43
|
end
|
@@ -60,17 +58,17 @@ module Sinatra
|
|
60
58
|
|
61
59
|
private
|
62
60
|
|
63
|
-
def resolve_spec(
|
64
|
-
if
|
65
|
-
if
|
61
|
+
def resolve_spec(database_spec)
|
62
|
+
if database_spec.is_a?(String)
|
63
|
+
if database_spec =~ %r{^sqlite3?://[^/]+$}
|
66
64
|
warn <<-MESSAGE.strip_heredoc
|
67
65
|
It seems your database URL looks something like this: "sqlite3://<database_name>".
|
68
66
|
This doesn't work anymore, you need to use 3 slashes, like this: "sqlite3:///<database_name>".
|
69
67
|
MESSAGE
|
70
68
|
end
|
71
|
-
|
69
|
+
database_spec.sub(/^sqlite:/, "sqlite3:")
|
72
70
|
else
|
73
|
-
|
71
|
+
database_spec
|
74
72
|
end
|
75
73
|
end
|
76
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
segments:
|
126
126
|
- 0
|
127
|
-
hash: -
|
127
|
+
hash: -897588111
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
130
|
rubygems_version: 1.8.23
|