dot_env 0.0.2 → 0.0.3

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: 9db1083c3054071191608fd181c50d848c8c855c
4
- data.tar.gz: 7ce8c558c89ffa9a1d16629f6337f4f4730c5762
3
+ metadata.gz: 7443ad9f09e454c484d03a691f8fddbc5dcc82b1
4
+ data.tar.gz: c64a46f7cd37bad12f3fece9697688740c02f524
5
5
  SHA512:
6
- metadata.gz: e36c72834cda6e85de35d940f96ff9de5ecbcd32967c7a13daae92bbe89d3d3f986fc30a1a1d429c6d5237e6f893b6897fda2aa069bc31c67acf07c56e37e3de
7
- data.tar.gz: 5936b86351ea9e23a60d1318215965cb349627fa71c6a233b2d00b7f3e534ff8eec187caf5d4c970a63e4659c3901b0be2ebaf9b91e2dd79b333049addc2c252
6
+ metadata.gz: 796b54c21373af9fe89bfbaaaf598e2ddc48b836d5823efffa82fc0d3c7f1588385e5ba3be8a7ffc2b32b792f6ce775f0119333058311f0ce73f7be87c11ab96
7
+ data.tar.gz: 72c3ae51c10893e83b4f5611e6c2008aaa72d784294d9e07f7837eeb86d6dbc112175f4f64747ccdf9d6e1e37066e6dc170d091c21f6ad9622023f8b8ce17d96
data/README.md CHANGED
@@ -6,12 +6,16 @@
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'dot_env', github: 'kaze/dot_env'
9
+ gem 'dot_env'
10
10
 
11
11
  And then execute:
12
12
 
13
13
  $ bundle
14
14
 
15
+ Or simply:
16
+
17
+ $ gem install dot_env
18
+
15
19
  ## Usage
16
20
 
17
21
  Basic usage:
@@ -38,6 +42,21 @@ You can use any other name for your settings file, and you can add that name as
38
42
 
39
43
  After parsing every variable's type will be `string`, except booleans and arrays.
40
44
 
45
+ Environment settings file example:
46
+
47
+ # example .env file
48
+
49
+ APP_ENV = "development"
50
+ APP_ROOT = $PWD
51
+ AN_ARRAY = ['one', '$HOME', True, 42]
52
+
53
+ There could be empty, and comment rows (prepended with a `#` sign at the beginning of the row) in the file.
54
+
55
+ After setting up the environment, you could access these variables from your code:
56
+
57
+ ENV['APP_ENV'] #=> 'development'
58
+ ENV['APP_ROOT'] #=> '/path/to/here'
59
+ ENV['AN_ARRAY'] #=> ['one', '/home/username', true, '42']
41
60
 
42
61
  ## Contributing
43
62
 
@@ -4,8 +4,6 @@ require_relative 'dot_env/parser'
4
4
  require_relative 'dot_env/environment'
5
5
 
6
6
  module DotEnv
7
- @log = Logger.new($stdout)
8
- @log.level = Logger::DEBUG
9
7
  @parser = DotEnv::Parser
10
8
  @env = DotEnv::Environment.new(@parser, ARGV)
11
9
  @env_file = @env.fetch('ENVIRONMENT_SETTINGS_FILE', '.env')
@@ -21,16 +19,12 @@ module DotEnv
21
19
 
22
20
  def self.set_default_env(filepath)
23
21
  current_env = @env.get_current
24
- # @log.info "Environment settings file ('#{filepath}') not found."
25
- # @log.info "Setting up #{current_env} environment."
26
22
  @env.set_current(current_env)
27
23
  end
28
24
 
29
25
  def self.set_environment(filepath)
30
26
  self.read_env_file(filepath)
31
27
  current_env = @env.get_current
32
- # @log.info "Environment settings file ('#{filepath}') found."
33
- # @log.info "Setting up #{current_env} environment."
34
28
  rescue Errno::ENOENT
35
29
  self.set_default_env(filepath)
36
30
  end
@@ -4,7 +4,9 @@ module DotEnv
4
4
  FALSEWORDS = ['false', 'no', '0']
5
5
 
6
6
  def self.get_value_pair(line)
7
- return line.chomp.split('=').each {|v| v.gsub!(/['"]/, '') }.each(&:strip!)
7
+ key, value = line.chomp.split('=').each {|v| v.gsub!(/['"]/, '') }.each(&:strip!)
8
+ value = self.expand(value)
9
+ [key, value]
8
10
  end
9
11
 
10
12
  def self.cleanup(value)
@@ -1,3 +1,3 @@
1
1
  module DotEnv
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -17,7 +17,7 @@ describe DotEnv do
17
17
  ENV['APP_NAME'].must_equal 'testapp'
18
18
  ENV['AN_ARRAY'].must_equal '[egy, ketto, harom]'
19
19
  ENV['UNBELIEVABLE'].must_equal 'True'
20
- ENV['SOMEWHERE'].must_equal '$HOME'
20
+ ENV['SOMEWHERE'].must_equal ENV['HOME']
21
21
  end
22
22
 
23
23
  it "can read back those settings" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dot_env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - zsolt kormany