dbenvy 0.0.1 → 0.0.2

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: 7c2ca8dc51341425a9b3f00a5d58f9819b3aa89d
4
- data.tar.gz: c815f682f306ecf0f5c6a2de078ba9d067e63054
3
+ metadata.gz: c4cbf40ffe72b693dd603e82176a823ad5b36d8f
4
+ data.tar.gz: 1ee3cffdba2ed2b609736d7ce19bc121af998b9a
5
5
  SHA512:
6
- metadata.gz: b999b5909f36bfcb42a55013bcb7cf8bdf721ee92167f5705a7a42ad2cb0b8cf31505479511c294a0875c4a5f31fdabc21151f2b76a54db445b7c6d53848f056
7
- data.tar.gz: 08fb0c39d6df36f85ca63c8b0b2eae8ff46bb5d30dc9c9115b9d3688c11bc7d2c1fbc898a611c257c58f33681468bed9aba18b221f93859c7d3b5265a977b0f5
6
+ metadata.gz: ef5b63db0130967cf8bf74efdec9466453de491a48521d0df78ba844b7a60902dbbb71fe5ab4d2ce9f9cbdae05b11b1c465367ffff93590f5299d3f779810857
7
+ data.tar.gz: 99472c23d5c814e41c188ce9698ccf96231309e2b31cd6a55a9bd805800908b9ae7b373ecf1d2a893f4312178a87498ba79424bdc64e9a5745559ba93806f46e
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3-p551
4
+ - 2.0.0-p598
5
+ - 2.1.5
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Dbenvy
1
+ [![Build Status](https://travis-ci.org/reevoo/dbenvy.svg?branch=master)](https://travis-ci.org/reevoo/dbenvy)
2
+
3
+ # DBEnvy
2
4
 
3
5
  Load DB info from the environment
4
6
 
@@ -16,12 +18,16 @@ And then execute:
16
18
 
17
19
  ## Usage
18
20
 
19
- Add the following to your database.yml file and set the DATABASE_URL environment variable
21
+ Add the following to your database.yml file and set the DATABASE_URL environment variable.
20
22
 
21
23
  ```
22
- <% DBEnvy.yaml %>
24
+ <%= DBEnvy.yaml %>
23
25
  ```
24
26
 
27
+ ## Note
28
+
29
+ You do not need this in a Rails 4.1 app as loading database info from DATABASE_URL is supported out of the box
30
+
25
31
  ## Contributing
26
32
 
27
33
  1. Fork it ( https://github.com/reevoo/dbenvy/fork )
data/Rakefile CHANGED
@@ -3,3 +3,4 @@ require 'rspec/core/rake_task'
3
3
  RSpec::Core::RakeTask.new(:spec)
4
4
 
5
5
  task release: :spec
6
+ task default: :spec
data/lib/dbenvy.rb CHANGED
@@ -29,7 +29,7 @@ class DBEnvy
29
29
  private
30
30
 
31
31
  def rails_env
32
- ENV['RAILS_ENV']
32
+ ENV['RAILS_ENV'] || Rails.env if defined?(Rails)
33
33
  end
34
34
 
35
35
  def credentials
@@ -1,3 +1,3 @@
1
1
  class DBEnvy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -56,6 +56,42 @@ describe DBEnvy do
56
56
  end
57
57
  end
58
58
 
59
+ context 'when RAILS_ENV is not set but Rails.env is avaliable' do
60
+ module Rails
61
+ extend self
62
+
63
+ def env
64
+ nil
65
+ end
66
+ end
67
+
68
+ context 'uses RAILS_ENV if it can' do
69
+ before do
70
+ ENV['DATABASE_URL'] = 'mysql2://reevoo:secret@db456.reevoover.com:3306/reevoo_awesome'
71
+ ENV['RAILS_ENV'] = 'ENV'
72
+ allow(Rails).to receive(:env).and_return('env')
73
+ end
74
+
75
+ specify do
76
+ expect(YAML.load(yaml)['ENV']).to_not be_nil
77
+ expect(YAML.load(yaml)['env']).to be_nil
78
+ end
79
+ end
80
+
81
+ context 'uses Rails.env if RAILS_ENV is not set' do
82
+ before do
83
+ ENV['DATABASE_URL'] = 'mysql2://reevoo:secret@db456.reevoover.com:3306/reevoo_awesome'
84
+ ENV['RAILS_ENV'] = nil
85
+ allow(Rails).to receive(:env).and_return('env')
86
+ end
87
+
88
+ specify do
89
+ expect(YAML.load(yaml)['ENV']).to be_nil
90
+ expect(YAML.load(yaml)['env']).to_not be_nil
91
+ end
92
+ end
93
+ end
94
+
59
95
  context 'when RAILS_ENV is set' do
60
96
  before do
61
97
  ENV['RAILS_ENV'] = 'production'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbenvy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -75,8 +75,8 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
+ - ".travis.yml"
78
79
  - Gemfile
79
- - Gemfile.lock
80
80
  - LICENSE.txt
81
81
  - README.md
82
82
  - Rakefile