envl 0.0.6 → 0.0.7

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/envl.rb +18 -18
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aa37cc038408f650f0faf1f6c7ddf7c86d6c33e7d5016c32a4eccd77b18d39a
4
- data.tar.gz: 11f57d53fade41b77a9605a91573a6da66380e956fe53cb6a75e04fdbff5ac0f
3
+ metadata.gz: 27b937b24641ec917f90e86e86654085e1d09d5f32d8a2adceb8fe3169565941
4
+ data.tar.gz: 4c3346ee897db277832231f517982b1efc9ffeaac2fb1fb74b0b42c4717625f6
5
5
  SHA512:
6
- metadata.gz: 574a2166521ae59db789391cdfde79d66e73e732ebbab3161880b01e2782c9740869415409e5057ccf26c86da02ceef73c039b61ea9edbd2eca8dbc4080336f2
7
- data.tar.gz: abf82ebb72e468ec0ffaf3d3dc1f00708c98d225f1e812a9c7096338bb16a2168b4e01bd0d95ad75159572a2335f69721433ccd78eef7dbdd3c75c51692745c4
6
+ metadata.gz: bd80ad860186cb3152a0c660e7a2fe9aea4320daa59ab449434eb2be5391c8162c031793e32d830697f225d20cd28c9314369dcfe5feb440cfacab052f77b992
7
+ data.tar.gz: 9d30c1309b51458273dad00253b1c493083ee0f2981a8af3be4a758567ff7baf5407f2de17ff2548f6dbe166cf83294ef1b6b1333c2c58884bf7249ffb7bc8c8
data/lib/envl.rb CHANGED
@@ -3,29 +3,36 @@
3
3
  class Envl
4
4
  @@loaded_vars = []
5
5
 
6
- # automatically finds all .env files and loads them into ENV.
6
+ # Automatically finds all .env files and loads them into ENV.
7
7
  def self.auto_load
8
8
  files = ['*.env', '*.env.*'].map { |s| Dir.glob(s, File::FNM_CASEFOLD) }.flatten.uniq
9
9
  self.load(files)
10
10
  end
11
11
 
12
- # finds and loads all .env files in a specific directory into ENV.
12
+ # Returns true if a given file is a .env file.
13
+ def self.is_env?(file)
14
+ ext = File.extname(file).downcase
15
+ name = File.basename(file).downcase
16
+ ext.include? '.env' or name[name.index('.')..].include? '.env'
17
+ end
18
+
19
+ # Returns all keys loaded into ENV.
20
+ def self.keys
21
+ @@loaded_vars
22
+ end
23
+
24
+ # Finds and loads all .env files in a specific directory into ENV.
13
25
  def self.load_path(path)
14
- files = [File.join(path, "*.env"), File.join(path, "*.env.*")].map { |s| Dir.glob(s, File::FNM_CASEFOLD) }.flatten.uniq
26
+ files = [File.join(path, '*.env'), File.join(path, '*.env.*')].map { |s| Dir.glob(s, File::FNM_CASEFOLD) }.flatten.uniq
15
27
  self.load(files)
16
28
  end
17
29
 
18
- # loads a single .env file into ENV.
30
+ # Loads a single .env file into ENV.
19
31
  def self.load_single(path)
20
32
  self.load([path])
21
33
  end
22
34
 
23
- # returns all loaded variables.
24
- def self.get_loaded_vars
25
- @@loaded_vars
26
- end
27
-
28
- # accepts an array of .env files and load thems into ENV.
35
+ # Accepts an array of .env files and load thems into ENV.
29
36
  def self.load(files)
30
37
  files.each do |f|
31
38
  self.load_env(f)
@@ -33,14 +40,7 @@ class Envl
33
40
  ENV
34
41
  end
35
42
 
36
- # sanity-check
37
- def self.is_env?(file)
38
- ext = File.extname(file).downcase
39
- name = File.basename(file).downcase
40
- ext.include? '.env' or name[name.index('.')..].include? '.env'
41
- end
42
-
43
- # loads a single .env file into ENV.
43
+ # Loads a single .env file into ENV.
44
44
  def self.load_env(file)
45
45
  begin
46
46
  return if not self.is_env?(file)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Stauffer
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
37
  - !ruby/object:Gem::Version
38
38
  version: '0'
39
39
  requirements: []
40
- rubygems_version: 3.1.6
40
+ rubygems_version: 3.3.5
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: A simple environment variable loader.