sinatra-activerecord 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/sinatra/activerecord.rb +8 -10
  2. metadata +3 -3
@@ -29,17 +29,15 @@ module Sinatra
29
29
  def database_file=(path)
30
30
  require 'pathname'
31
31
 
32
- return if app_file.nil?
33
- path = File.join(File.dirname(app_file), path) if Pathname.new(path).relative?
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
- if %w[development test production].any? { |env| database_hash[env] }
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(database_url)
64
- if database_url.is_a?(String)
65
- if database_url =~ %r{^sqlite3?://[^/]+$}
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
- database_url.sub(/^sqlite:/, "sqlite3:")
69
+ database_spec.sub(/^sqlite:/, "sqlite3:")
72
70
  else
73
- database_url
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.1
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-01-08 00:00:00.000000000 Z
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: -6445329919965563
127
+ hash: -897588111
128
128
  requirements: []
129
129
  rubyforge_project:
130
130
  rubygems_version: 1.8.23