dotenv-rails 1.0.1 → 1.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: 49d848769361cfe126de3970731872daba88fd17
4
- data.tar.gz: 464ede881818b54ecd166be93584d1b56ccaedf0
3
+ metadata.gz: d9b8a2f36a1e82b0bbb76f969ed18daefaa0f53d
4
+ data.tar.gz: bb950985d9d6dedd2f49f5921abea128c66042ad
5
5
  SHA512:
6
- metadata.gz: f8e73a6875908b0aa1bd7e0c71a96e754ca9d60f072ca818c417c4eeeece5ff4a960a9fb2da9d802ad29ad510d0723c856e877ce08dc96f5ed5020001ca6e775
7
- data.tar.gz: 295256358888ce282ce396beaf89ce7d78780c668a7b4eba3a658c579393e24b9ca2b257028132b38d4f9ed58c48e7762d4fec24d60951880876d91200374333
6
+ metadata.gz: 54fc237f8118410e5c35dc24ec52efd1153d034e1c6f01e8b61e3b4776e0e08ddf58bd4b4e8066099459bbac9610cbc08fae5f8cb8cd5530a6c4bac217ae654a
7
+ data.tar.gz: e81f9732b8e9a8a7000dbefd5f0358d1ea2a6e50c26a3d9c1e3516b6b0ad979876d469f944fab28ec099c6b66cab9229265374cf2bac33b1179b46e9fd898290
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/dotenv/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.version = Dotenv::VERSION
6
+ gem.authors = ["Brandon Keepers"]
7
+ gem.email = ["brandon@opensoul.org"]
8
+ gem.description = %q{Autoload dotenv in Rails.}
9
+ gem.summary = %q{Autoload dotenv in Rails.}
10
+ gem.homepage = "https://github.com/bkeepers/dotenv"
11
+ gem.license = 'MIT'
12
+
13
+ gem.files = `git ls-files | grep rails`.split($\)
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "dotenv-rails"
16
+ gem.require_paths = ["lib"]
17
+
18
+ gem.add_dependency 'dotenv', Dotenv::VERSION
19
+
20
+ gem.add_development_dependency 'spring'
21
+ gem.add_development_dependency 'railties'
22
+ end
data/lib/dotenv-rails.rb CHANGED
@@ -1 +1 @@
1
- require "dotenv/railtie"
1
+ require "dotenv/rails"
@@ -0,0 +1,10 @@
1
+ # If you use gems that require environment variables to be set before they are
2
+ # loaded, then list `dotenv-rails` in the `Gemfile` before those other gems and
3
+ # require `dotenv/rails-now`.
4
+ #
5
+ # gem "dotenv-rails", :require => "dotenv/rails-now"
6
+ # gem "gem-that-requires-env-variables"
7
+ #
8
+
9
+ require 'dotenv/rails'
10
+ Dotenv::Railtie.load
@@ -0,0 +1,27 @@
1
+ require 'dotenv'
2
+ begin
3
+ require 'spring/watcher'
4
+ rescue LoadError
5
+ # Spring is not available
6
+ end
7
+
8
+ module Dotenv
9
+ class Railtie < Rails::Railtie
10
+ config.before_configuration { load }
11
+
12
+ # Public: Load dotenv
13
+ #
14
+ # This will get called during the `before_configuration` callback, but you
15
+ # can manually call `Dotenv::Railtie.load` if you needed it sooner.
16
+ def load
17
+ Dotenv.load Rails.root.join('.env')
18
+ Spring.watch Rails.root.join('.env') if defined?(Spring)
19
+ end
20
+
21
+ # Rails uses `#method_missing` to delegate all class methods to the
22
+ # instance, which means `Kernel#load` gets called here. We don't want that.
23
+ def self.load
24
+ instance.load
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'rails'
3
+ require 'dotenv/rails'
4
+
5
+ describe Dotenv::Railtie do
6
+ # Fake watcher for Spring
7
+ class SpecWatcher < Struct.new(:items)
8
+ def initialize
9
+ @items = Set.new
10
+ end
11
+
12
+ def add(*items)
13
+ @items.merge items
14
+ end
15
+ end
16
+
17
+ before do
18
+ allow(Rails).to receive(:root).and_return Pathname.new(File.expand_path('../../../', __FILE__))
19
+ allow(Spring).to receive(:application_root_path).and_return(Rails.root)
20
+ Spring.watcher = SpecWatcher.new
21
+ end
22
+
23
+ context 'before_configuration' do
24
+ it 'calls #load' do
25
+ expect(Dotenv::Railtie.instance).to receive(:load)
26
+ ActiveSupport.run_load_hooks(:before_configuration)
27
+ end
28
+ end
29
+
30
+ context 'load' do
31
+ before { Dotenv::Railtie.load }
32
+
33
+ it 'watches .env with Spring' do
34
+ Spring.watcher.include? Rails.root.join('.env')
35
+ end
36
+
37
+ it 'loads .env' do
38
+ expect(ENV).to have_key('DOTENV')
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-04 00:00:00.000000000 Z
11
+ date: 2014-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -16,14 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: 1.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: 1.0.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: spring
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: railties
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: Autoload dotenv in Rails.
28
56
  email:
29
57
  - brandon@opensoul.org
@@ -31,7 +59,11 @@ executables: []
31
59
  extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
62
+ - dotenv-rails.gemspec
34
63
  - lib/dotenv-rails.rb
64
+ - lib/dotenv/rails-now.rb
65
+ - lib/dotenv/rails.rb
66
+ - spec/dotenv/rails_spec.rb
35
67
  homepage: https://github.com/bkeepers/dotenv
36
68
  licenses:
37
69
  - MIT
@@ -56,4 +88,5 @@ rubygems_version: 2.2.2
56
88
  signing_key:
57
89
  specification_version: 4
58
90
  summary: Autoload dotenv in Rails.
59
- test_files: []
91
+ test_files:
92
+ - spec/dotenv/rails_spec.rb