wd_sinatra_sequel 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 878e150cac3a9efc347eb8d0476dee987242e226
4
- data.tar.gz: e3dd5d0920e9316f8fc22198bf9a2d2c68fbed48
3
+ metadata.gz: af844175ad819319e4f37249a5eb71ffce6e4e6b
4
+ data.tar.gz: 301364bba13599d29ef028a81b4e2aeab6da588a
5
5
  SHA512:
6
- metadata.gz: 12f9ec2348d8429baf884dadcf5614723ec5f37abac2f654b03a5a257a8c90c330659b921749119cb009e80d36fa68efa1497ae4c6efeefcd0f9345700884a74
7
- data.tar.gz: 58b3db04db89a04682f8bb99e117c3e99ce445231e2c8f592407913681c9ed6c5ecea72b9cbee5adc0e9883165f52c3997df54cf1bf7129749d963819b37efa9
6
+ metadata.gz: d21cad413f7331d1682af3cf5127adea0f9b9c7681f63ebe1b82bd7968c52cefdadeefa37442a75d24de0eedc8bb157c63646728c6a424ba026285ff01225496
7
+ data.tar.gz: a221269be0b96cff95a87034f389e6eb302c626a85d93fb048919445635ed79899944c3f2abafefed1feea5a0aa32d5cf9923bd3a64e536a1e9675d5a30af0e6
@@ -1,3 +1,6 @@
1
+ ## 0.0.4
2
+ * refactor the db file and loading of db config
3
+
1
4
  ## 0.0.3
2
5
  * require yaml for loading config
3
6
 
data/README.md CHANGED
@@ -36,12 +36,13 @@ Add an Sequel `database.yml` file in your config folder and then require this
36
36
  gem in your `app.rb` file and connect to the DB:
37
37
 
38
38
  require 'wd_sinatra_sequel'
39
- DB = WdSinatraSequel::DBConnector.set_db_connection
39
+ WdSinatraSequel::DBConnector.set_db_connection
40
+ WdSinatraSequel::DBConnector.connect_to_db
40
41
 
41
42
 
42
43
  The DB settings can be accessed via:
43
44
 
44
- DBConnector::DB_CONFIG[RACK_ENV]
45
+ WdSinatraSequel::DBConnector::DB_CONFIG[RACK_ENV]
45
46
 
46
47
  ## Rake tasks
47
48
 
@@ -19,7 +19,8 @@ module WdSinatraSequel
19
19
 
20
20
  ##### DB Connection ########
21
21
  module DBConnector
22
- DB_CONFIG = YAML.load_file(File.join(WDSinatra::AppLoader.root_path, "config", "database.yml"))
22
+ DB_FILE = File.join(WDSinatra::AppLoader.root_path, "config", "database.yml")
23
+ DB_CONFIG = YAML.load_file(DB_FILE)
23
24
 
24
25
  module_function
25
26
 
@@ -33,11 +34,9 @@ module WdSinatraSequel
33
34
  end
34
35
 
35
36
  # Establish the DB connection
36
- db_file = File.join(WDSinatra::AppLoader.root_path, "config", "database.yml")
37
- if File.exist?(db_file)
38
- hash_settings = YAML.load_file(db_file)
39
- if hash_settings && hash_settings[env]
40
- @db_configurations = hash_settings
37
+ if File.exist?(DB_FILE)
38
+ if DB_CONFIG && DB_CONFIG[env]
39
+ @db_configurations = DB_CONFIG
41
40
  @db_configuration = @db_configurations[env]
42
41
  # add loggers
43
42
  @db_configuration['loggers'] ||= []
@@ -49,10 +48,10 @@ module WdSinatraSequel
49
48
  end
50
49
  connect_to_db unless ENV['DONT_CONNECT']
51
50
  else
52
- raise "#{db_file} doesn't have an entry for the #{env} environment"
51
+ raise "#{DB_FILE} doesn't have an entry for the #{env} environment"
53
52
  end
54
53
  else
55
- raise "#{db_file} file missing, can't connect to the DB"
54
+ raise "#{DB_FILE} file missing, can't connect to the DB"
56
55
  end
57
56
  end
58
57
 
@@ -1,3 +1,3 @@
1
1
  module WdSinatraSequel
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wd_sinatra_sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Chu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-01 00:00:00.000000000 Z
11
+ date: 2013-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry