sinatra-dm 0.1.1 → 0.1.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.
- data/VERSION +1 -1
- data/lib/sinatra/dm.rb +13 -2
- data/lib/sinatra/dm/rake.rb +15 -2
- data/sinatra-dm.gemspec +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/sinatra/dm.rb
CHANGED
@@ -15,7 +15,7 @@ module Sinatra
|
|
15
15
|
#
|
16
16
|
module DataMapperExtension
|
17
17
|
|
18
|
-
VERSION = '0.1.
|
18
|
+
VERSION = '0.1.2' unless const_defined?(:VERSION)
|
19
19
|
def self.version; "Sinatra::DataMapperExtension v#{VERSION}"; end
|
20
20
|
|
21
21
|
module Helpers
|
@@ -46,7 +46,9 @@ module Sinatra
|
|
46
46
|
# @database = nil
|
47
47
|
set :dm_setup_context, context
|
48
48
|
set :database_url, url
|
49
|
-
|
49
|
+
db_type = database_url.split('://').first
|
50
|
+
db_url = database_url.sub(::APP_ROOT, '').sub("#{db_type}://",'')
|
51
|
+
puts "-- - activated DataMapper #{db_type.capitalize} Database at [ #{db_url} ]"
|
50
52
|
database_logger
|
51
53
|
database
|
52
54
|
end
|
@@ -137,6 +139,7 @@ module Sinatra
|
|
137
139
|
|
138
140
|
|
139
141
|
def self.registered(app)
|
142
|
+
app.set :db_dir, "#{::APP_ROOT}/db"
|
140
143
|
app.set :dm_logger_level, :debug
|
141
144
|
app.set :dm_logger_path, lambda { "#{::APP_ROOT}/log/dm.#{environment}.log" }
|
142
145
|
app.set :dm_setup_context, :default
|
@@ -147,6 +150,14 @@ module Sinatra
|
|
147
150
|
|
148
151
|
app.helpers DataMapperExtension::Helpers
|
149
152
|
|
153
|
+
## add the extension specific options to those inspectable by :options_inspect method
|
154
|
+
if app.respond_to?(:sinatra_options_for_inspection)
|
155
|
+
%w( db_dir dm_logger_path dm_logger_level database_url
|
156
|
+
dm_setup_context database ).each do |m|
|
157
|
+
app.sinatra_options_for_inspection << m
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
150
161
|
# QUESTION:: Should this actually be here?
|
151
162
|
# or should I just use the rake tasks
|
152
163
|
#
|
data/lib/sinatra/dm/rake.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
|
2
2
|
namespace :db do
|
3
3
|
|
4
|
+
namespace :production do
|
5
|
+
|
6
|
+
desc "Convert development.db into production.db"
|
7
|
+
task :setup do
|
8
|
+
sh "cp db/development.db db/production.db"
|
9
|
+
end
|
10
|
+
end #/ namespace production
|
11
|
+
|
12
|
+
|
4
13
|
desc "Backup database to .tar.gz file (=> db:backup:db)"
|
5
14
|
task :backup => ['db:backup:db']
|
6
15
|
|
@@ -33,10 +42,14 @@ namespace :db do
|
|
33
42
|
unless args.db
|
34
43
|
msg = %Q[\nERROR:\n\n You must define the :db variable like this:\n]
|
35
44
|
msg << %Q[ rake db:bootstrap db=db/name-of-database.db\n\n]
|
36
|
-
puts
|
45
|
+
puts msg
|
37
46
|
else
|
38
47
|
sh "sqlite3 #{args.db} < db/bootstraps/#{args.db.sub(/^db\//,'')}.sql"
|
39
48
|
puts "-- DB [ #{args.db}] bootstrapped with [ db/bootstraps/#{args.db.sub(/^db\//,'')}.sql ]l\n\n"
|
49
|
+
# if test(?d, '.git/config')
|
50
|
+
# sh "git add db/bootstraps/#{args.db.sub(/^db\//,'')}.sql"
|
51
|
+
# sh %Q{git commit -m "#{Time.now.strftime("%Y-%d-%m at %H:%M:%S")} : updated DB bootstraps for #{args.db}" }
|
52
|
+
# end
|
40
53
|
end
|
41
54
|
|
42
55
|
end
|
@@ -49,7 +62,7 @@ namespace :db do
|
|
49
62
|
msg = %Q[\nERROR:\n\n You must define the DB variable like this:\n]
|
50
63
|
msg << %Q[ rake db:bootstrap:new db=db/name-of-database.db\n]
|
51
64
|
msg << %Q[ bf=db/bootstraps/name.sql \n\n]
|
52
|
-
puts
|
65
|
+
puts msg
|
53
66
|
else
|
54
67
|
sh "sqlite3 #{args.db} < #{args.bf}"
|
55
68
|
puts "-- created new DB [ #{args.db} ]\n"
|
data/sinatra-dm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra-dm}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["kematzy"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-11-06}
|
13
13
|
s.description = %q{Sinatra Extension for working with DataMapper (another Sinatra-Sequel Rip-off)}
|
14
14
|
s.email = %q{kematzy@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
::APP_ROOT = File.join(File.dirname(__FILE__), 'fixtures')
|
2
3
|
|
3
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
@@ -20,7 +21,6 @@ def fixtures_path
|
|
20
21
|
"#{File.dirname(File.expand_path(__FILE__))}/fixtures"
|
21
22
|
end
|
22
23
|
|
23
|
-
::APP_ROOT = fixtures_path
|
24
24
|
|
25
25
|
class MyTestApp < Sinatra::Base
|
26
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-dm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kematzy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-06 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|