napa 0.1.4 → 0.1.6
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/lib/napa/version.rb +1 -1
- data/lib/tasks/db.rake +20 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fe0fa94a5dd767848ebc3aa7cd844852d337fe0
|
4
|
+
data.tar.gz: c3a75f4bc02be82326a6b4c84a5b7a822e5053dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 120c728a6838492420a2c97b5e4aa35e0c6ce1cf1be1223076d60f0a6304211a67d919c0433a3abce911d2e1991ff3694c3a17682239832bf673797cb83d8107
|
7
|
+
data.tar.gz: 8c745d7661deba0db7ccdb4bb163f880cae94306f4d01949a7a15d11cd4bb42396792f09e1694d4252aae98fe0f2b195d7923a473c05d5265113f83bd12d30be
|
data/.rubocop.yml
CHANGED
data/lib/napa/version.rb
CHANGED
data/lib/tasks/db.rake
CHANGED
@@ -7,6 +7,7 @@ unless defined?(Rails)
|
|
7
7
|
end
|
8
8
|
|
9
9
|
namespace :db do
|
10
|
+
|
10
11
|
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
|
11
12
|
task :migrate => :environment do
|
12
13
|
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
|
@@ -15,18 +16,14 @@ unless defined?(Rails)
|
|
15
16
|
|
16
17
|
desc "Create the database"
|
17
18
|
task :create => :environment do
|
18
|
-
|
19
|
-
|
20
|
-
ActiveRecord::Base.establish_connection(adapter)
|
21
|
-
ActiveRecord::Base.connection.create_database(db.fetch('database'))
|
19
|
+
establish_connection
|
20
|
+
ActiveRecord::Base.connection.create_database(db_conf.fetch('database'))
|
22
21
|
end
|
23
22
|
|
24
23
|
desc "Delete the database"
|
25
24
|
task :drop => :environment do
|
26
|
-
|
27
|
-
|
28
|
-
ActiveRecord::Base.establish_connection(adapter)
|
29
|
-
ActiveRecord::Base.connection.drop_database(db.fetch('database'))
|
25
|
+
establish_connection
|
26
|
+
ActiveRecord::Base.connection.drop_database(db_conf.fetch('database'))
|
30
27
|
end
|
31
28
|
|
32
29
|
desc "Create the test database"
|
@@ -86,4 +83,19 @@ unless defined?(Rails)
|
|
86
83
|
end
|
87
84
|
end
|
88
85
|
end
|
86
|
+
|
87
|
+
def db_conf
|
88
|
+
config = YAML.load(ERB.new(File.read('config/database.yml')).result)[Napa.env]
|
89
|
+
end
|
90
|
+
|
91
|
+
def establish_connection
|
92
|
+
ActiveRecord::Base.configurations = db_conf
|
93
|
+
if db_conf['adapter'] == 'em_postgresql' || db_conf['adapter'] == 'postgresql'
|
94
|
+
# drop and create need to be performed with a connection to the 'postgres' (system) database
|
95
|
+
ActiveRecord::Base.establish_connection db_conf.merge('database' => 'postgres',
|
96
|
+
'schema_search_path' => 'public')
|
97
|
+
else
|
98
|
+
ActiveRecord::Base.establish_connection(db_conf)
|
99
|
+
end
|
100
|
+
end
|
89
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: napa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darby Frey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|