dotenv-mh 0.1.6 → 0.1.8
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 +4 -4
- data/.env +5 -0
- data/.gitignore +2 -1
- data/README.md +16 -10
- data/bin/dotenvInstaller +7 -5
- data/dotenv-mh.gemspec +2 -2
- data/lib/dotenv/loggerMh.rb +17 -0
- data/lib/dotenv/mh/version.rb +1 -1
- data/lib/dotenv/mh.rb +5 -12
- data/lib/dotenv/railtie.rb +0 -2
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aabe819b72fa1205261e63ca34281e1c5f3fcf842733197f67b65b8c9015656
|
4
|
+
data.tar.gz: 570b775441b54716dd130af5b8e22f36e34dff4e8fe0f4ef58f5866fefae33bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08f594ca7c483ae4c7d186f3a279dad9b9c1ce053ac17fa6f41729163a6b6a03ccdf8c4b914722c1edb3c37879000f68dd12cb15fb481054f7aabca41dc78f3f'
|
7
|
+
data.tar.gz: 5d44c7bd3a67d8e392b8c18c6f29dfa12f48bc3ddf2620198fd42cee3dd7fcb7a7a2539fdf3f492870888e9b7e71d8214c4e832e79645b4612e98748662e21f7
|
data/.env
CHANGED
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
# Dotenv
|
1
|
+
# Dotenv-mh
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Dotenv-mh is a simple gem inspired on the classic [dotenv](https://github.com/motdotla/dotenv) and adapted to Rails framework following [figaro](https://github.com/laserlemon/figaro) approach for initialization (Rails::Railtie).
|
4
|
+
Basically, it allows to load environment variables from a .env file when running on development. Once this gem is installed, your Rails application will automatically load your environment variables using a custom Rails::Railtie, so there is no need to modify the "config/application.rb".
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -14,16 +13,23 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
14
13
|
|
15
14
|
$ gem install dotenv-mh
|
16
15
|
|
17
|
-
##
|
16
|
+
## Execute Installer
|
17
|
+
Execute the following:
|
18
|
+
|
19
|
+
$ bundle exec dotenvInstaller
|
18
20
|
|
19
|
-
|
21
|
+
The installer will create a ".env" file and add it to your .gitignore.
|
20
22
|
|
21
|
-
##
|
23
|
+
## .env file
|
22
24
|
|
23
|
-
|
25
|
+
This follows the classic .env file structure, where each line represents a tuple of key-value.
|
24
26
|
|
25
|
-
|
27
|
+
# .env file
|
28
|
+
Variable1=value1
|
29
|
+
Variable2=value2
|
30
|
+
.....
|
31
|
+
AnotherVariable=AnotherValue
|
26
32
|
|
27
33
|
## Contributing
|
28
34
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/herreramaxi/dotenv-mh.
|
data/bin/dotenvInstaller
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
+
require "dotenv/loggerMh"
|
1
2
|
|
2
|
-
|
3
|
+
LoggerMh.logInfo("installing...")
|
3
4
|
|
4
5
|
if(!File.file?('.env')) then
|
5
|
-
|
6
|
+
LoggerMh.logInfo("creating .env file")
|
7
|
+
|
6
8
|
File.new(".env", "w")
|
7
9
|
|
8
10
|
if(File.file?('.gitignore')) then
|
9
|
-
|
11
|
+
LoggerMh.logInfo("adding .env into your .gitignore")
|
10
12
|
|
11
13
|
fileContent = File.read(".gitignore")
|
12
14
|
File.write(".gitignore", fileContent + "\n.env")
|
13
15
|
else
|
14
|
-
|
16
|
+
LoggerMh.logInfo("not able to add '.env' into your .gitignore, file does not exists...")
|
15
17
|
end
|
16
18
|
else
|
17
|
-
|
19
|
+
LoggerMh.logInfo(".env file already exists, skipping...")
|
18
20
|
end
|
19
21
|
|
data/dotenv-mh.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = ["herreramaxi@gmail.com"]
|
10
10
|
|
11
11
|
spec.summary = "dotenv gem for loading environment variables"
|
12
|
-
spec.description = "dotenv gem for loading environment variables from .env file.
|
13
|
-
|
12
|
+
spec.description = "dotenv gem for loading environment variables from .env file."
|
13
|
+
spec.homepage = "https://github.com/herreramaxi/dotenv-mh"
|
14
14
|
spec.required_ruby_version = ">= 2.6.0"
|
15
15
|
|
16
16
|
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module LoggerMh
|
2
|
+
def self.logInfo(message)
|
3
|
+
log("INFO", message)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.logError(message)
|
7
|
+
log("ERROR", message)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.logWarning(message)
|
11
|
+
log("WARNING", message)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.log(messageType, message)
|
15
|
+
puts "dotenv-mh | #{messageType} | #{Time.now.strftime('%d-%m-%Y %H-%M-%S.%L')} | #{message}"
|
16
|
+
end
|
17
|
+
end
|
data/lib/dotenv/mh/version.rb
CHANGED
data/lib/dotenv/mh.rb
CHANGED
@@ -2,31 +2,26 @@
|
|
2
2
|
|
3
3
|
require_relative "mh/version"
|
4
4
|
require_relative "railtie"
|
5
|
+
require_relative "LoggerMh"
|
5
6
|
|
6
7
|
module Dotenv
|
7
|
-
# module Mh
|
8
|
-
# class Dotenv
|
9
8
|
def self.load()
|
10
9
|
|
11
10
|
if(!File.file?('.env')) then
|
12
|
-
|
11
|
+
LoggerMh.logWarning(".env file not found")
|
13
12
|
return
|
14
13
|
end
|
15
14
|
|
16
|
-
|
15
|
+
LoggerMh.logInfo("loading variables from .env file...")
|
17
16
|
|
18
|
-
File.readlines('.env').each do |line|
|
19
|
-
|
20
|
-
|
21
|
-
if(line.start_with?("#")) then
|
22
|
-
puts("skipping: line comment")
|
17
|
+
File.readlines('.env').each do |line|
|
18
|
+
if(line.start_with?("#")) then
|
23
19
|
next
|
24
20
|
end
|
25
21
|
|
26
22
|
keyValue = line.strip().split("=", 2)
|
27
23
|
|
28
24
|
if(keyValue.length != 2) then
|
29
|
-
puts("skipping: wrong line detected")
|
30
25
|
next
|
31
26
|
end
|
32
27
|
|
@@ -36,6 +31,4 @@ module Dotenv
|
|
36
31
|
ENV[key] = value
|
37
32
|
end
|
38
33
|
end
|
39
|
-
# end
|
40
|
-
# end
|
41
34
|
end
|
data/lib/dotenv/railtie.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenv-mh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Herrera Maxi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: dotenv gem for loading environment variables from .env file.
|
14
|
-
a WIP, I would like to add a Rails initializer so that env variables can be loaded
|
15
|
-
from .env file.
|
13
|
+
description: dotenv gem for loading environment variables from .env file.
|
16
14
|
email:
|
17
15
|
- herreramaxi@gmail.com
|
18
16
|
executables:
|
@@ -29,11 +27,12 @@ files:
|
|
29
27
|
- bin/dotenvInstaller
|
30
28
|
- bin/setup
|
31
29
|
- dotenv-mh.gemspec
|
30
|
+
- lib/dotenv/loggerMh.rb
|
32
31
|
- lib/dotenv/mh.rb
|
33
32
|
- lib/dotenv/mh/version.rb
|
34
33
|
- lib/dotenv/railtie.rb
|
35
34
|
- sig/dotenv/mh.rbs
|
36
|
-
homepage:
|
35
|
+
homepage: https://github.com/herreramaxi/dotenv-mh
|
37
36
|
licenses: []
|
38
37
|
metadata: {}
|
39
38
|
post_install_message:
|