napa 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9da429ae573a9e4204d8a2cf060185ef578b881
4
- data.tar.gz: 477095dad47b80a1f3de19c47b104d2b2b9a04fb
3
+ metadata.gz: 4fe0fa94a5dd767848ebc3aa7cd844852d337fe0
4
+ data.tar.gz: c3a75f4bc02be82326a6b4c84a5b7a822e5053dd
5
5
  SHA512:
6
- metadata.gz: 5ba07a913e24c756cd7de67fb2b32d4cc55d4e50e917fdeb3e64a67b2cabc7ed7602201c8bd825b9d65319b1595f908405b193afb564e7170c048aff64049a1d
7
- data.tar.gz: e4b7643b90506178f03964aaef1693cf42ec2be3b1ac625c9c2585ea40a0637411786bbb135cb463ea61aa057b233889dc7e3932bb87485d876ea92244fc2c8b
6
+ metadata.gz: 120c728a6838492420a2c97b5e4aa35e0c6ce1cf1be1223076d60f0a6304211a67d919c0433a3abce911d2e1991ff3694c3a17682239832bf673797cb83d8107
7
+ data.tar.gz: 8c745d7661deba0db7ccdb4bb163f880cae94306f4d01949a7a15d11cd4bb42396792f09e1694d4252aae98fe0f2b195d7923a473c05d5265113f83bd12d30be
data/.rubocop.yml CHANGED
@@ -14,4 +14,10 @@ NumericLiterals:
14
14
  Enabled: false
15
15
 
16
16
  MethodLength:
17
- Enabled: false
17
+ Enabled: false
18
+
19
+ AllCops:
20
+ Excludes:
21
+ - db/**
22
+ - config/**
23
+ - script/**
data/lib/napa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Napa
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.6'
3
3
 
4
4
  class Version
5
5
  class << self
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
- db = YAML.load(ERB.new(File.read('./config/database.yml')).result)[Napa.env]
19
- adapter = db.merge({'database'=> 'mysql'})
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
- db = YAML.load(ERB.new(File.read('./config/database.yml')).result)[Napa.env]
27
- adapter = db.merge({'database'=> 'mysql'})
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
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-04 00:00:00.000000000 Z
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake