ardb 0.5.0 → 0.6.0
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/lib/ardb.rb +4 -0
- data/lib/ardb/runner.rb +2 -10
- data/lib/ardb/version.rb +1 -1
- data/test/helper.rb +3 -2
- data/test/unit/config_tests.rb +1 -0
- data/test/unit/runner_tests.rb +1 -0
- metadata +3 -3
data/lib/ardb.rb
CHANGED
@@ -6,6 +6,8 @@ require 'ns-options'
|
|
6
6
|
require 'ardb/version'
|
7
7
|
require 'ardb/root_path'
|
8
8
|
|
9
|
+
ENV['ARDB_DB_FILE'] ||= 'config/db'
|
10
|
+
|
9
11
|
module Ardb
|
10
12
|
NotConfiguredError = Class.new(RuntimeError)
|
11
13
|
|
@@ -21,6 +23,7 @@ module Ardb
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def self.init(establish_connection=true)
|
26
|
+
require self.config.db_file
|
24
27
|
validate!
|
25
28
|
Adapter.init
|
26
29
|
|
@@ -44,6 +47,7 @@ module Ardb
|
|
44
47
|
option :password, String, :required => false
|
45
48
|
end
|
46
49
|
|
50
|
+
option :db_file, Pathname, :default => ENV['ARDB_DB_FILE']
|
47
51
|
option :root_path, Pathname, :required => true
|
48
52
|
option :logger, :required => true
|
49
53
|
option :migrations_path, RootPath, :default => proc{ "db/migrations" }
|
data/lib/ardb/runner.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'ardb'
|
2
2
|
|
3
|
-
ENV['ARDB_CONFIG_FILE'] ||= 'config/db'
|
4
|
-
|
5
3
|
module Ardb; end
|
6
4
|
class Ardb::Runner
|
7
5
|
UnknownCmdError = Class.new(ArgumentError)
|
@@ -17,7 +15,8 @@ class Ardb::Runner
|
|
17
15
|
end
|
18
16
|
|
19
17
|
def run
|
20
|
-
|
18
|
+
Ardb.init(false) # don't establish a connection
|
19
|
+
|
21
20
|
case @cmd_name
|
22
21
|
when 'migrate'
|
23
22
|
require 'ardb/runner/migrate_command'
|
@@ -41,13 +40,6 @@ class Ardb::Runner
|
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
44
|
-
private
|
45
|
-
|
46
|
-
def setup_run
|
47
|
-
require ENV['ARDB_CONFIG_FILE']
|
48
|
-
Ardb.init(false) # don't establish a connection
|
49
|
-
end
|
50
|
-
|
51
43
|
class NullCommand
|
52
44
|
def run
|
53
45
|
# if this was a real command it would do something here
|
data/lib/ardb/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -7,5 +7,6 @@ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
|
7
7
|
# require pry for debugging (`binding.pry`)
|
8
8
|
require 'pry'
|
9
9
|
|
10
|
-
ENV['
|
11
|
-
require
|
10
|
+
ENV['ARDB_DB_FILE'] = 'tmp/testdb/config/db'
|
11
|
+
require 'ardb'
|
12
|
+
Ardb.init(false)
|
data/test/unit/config_tests.rb
CHANGED
@@ -10,6 +10,7 @@ class Ardb::Config
|
|
10
10
|
subject{ Ardb::Config }
|
11
11
|
|
12
12
|
should have_namespace :db
|
13
|
+
should have_option :db_file, Pathname, :default => ENV['ARDB_DB_FILE']
|
13
14
|
should have_option :root_path, Pathname, :required => true
|
14
15
|
should have_option :logger, :required => true
|
15
16
|
should have_options :migrations_path, :schema_path
|
data/test/unit/runner_tests.rb
CHANGED
metadata
CHANGED