envl 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/envl.rb +18 -18
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5aa37cc038408f650f0faf1f6c7ddf7c86d6c33e7d5016c32a4eccd77b18d39a
4
- data.tar.gz: 11f57d53fade41b77a9605a91573a6da66380e956fe53cb6a75e04fdbff5ac0f
3
+ metadata.gz: a6de388c13bfbd050eb10d7697a533264c9da1abeb36c2096831e1ad8ae319d8
4
+ data.tar.gz: 889ea7025111da9f6f1af263161a2ae5f37c5924e047c6aa4c655dd7478588e3
5
5
  SHA512:
6
- metadata.gz: 574a2166521ae59db789391cdfde79d66e73e732ebbab3161880b01e2782c9740869415409e5057ccf26c86da02ceef73c039b61ea9edbd2eca8dbc4080336f2
7
- data.tar.gz: abf82ebb72e468ec0ffaf3d3dc1f00708c98d225f1e812a9c7096338bb16a2168b4e01bd0d95ad75159572a2335f69721433ccd78eef7dbdd3c75c51692745c4
6
+ metadata.gz: be8ff71ca202cc3780afc931d7c0be7f1cca9772e4ac81f219ee2f1d868dd3a760deb640c89052a7a824573ed871b421da2a132059a94030f3916d8b2a08b890
7
+ data.tar.gz: d2abdf1e6baabfcd8c56410e7b82896d88cbe8d5094bf92ffa436eb2b6253dd6f01433b4c58a37f213eacb0ce28ebdbc42949822a58589fb81b5e2904c835956
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,14 +1,14 @@
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.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Stauffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-14 00:00:00.000000000 Z
11
+ date: 2023-02-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple environment variable loader that reads .env files into ENV.
14
14
  email: scott@fuseraft.com
@@ -22,6 +22,7 @@ licenses:
22
22
  - MIT
23
23
  metadata:
24
24
  source_code_uri: https://github.com/scstauf/envl
25
+ documentation_uri: https://www.rubydoc.info/github/scstauf/envl
25
26
  post_install_message:
26
27
  rdoc_options: []
27
28
  require_paths:
@@ -37,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
38
  - !ruby/object:Gem::Version
38
39
  version: '0'
39
40
  requirements: []
40
- rubygems_version: 3.1.6
41
+ rubygems_version: 3.3.5
41
42
  signing_key:
42
43
  specification_version: 4
43
44
  summary: A simple environment variable loader.