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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6b020b239493c54e26e8c832c6c9681b51e1853b20a8221385f7c9d809e8f3e
4
- data.tar.gz: d3f22c420da0b3e9fe336ad3daf394e86cd780f5dd8179fb2aba42ad314d24df
3
+ metadata.gz: 5aabe819b72fa1205261e63ca34281e1c5f3fcf842733197f67b65b8c9015656
4
+ data.tar.gz: 570b775441b54716dd130af5b8e22f36e34dff4e8fe0f4ef58f5866fefae33bf
5
5
  SHA512:
6
- metadata.gz: ab5b8e449a568ac0931b69c882a9fb6dc9cd53057d9d06e1e518c8cb1f1a7e224d01669ae13b1846230370875f86e94ac318e11c54d1da88daa36c66869891a7
7
- data.tar.gz: 363ef9b34709e8b8d77ef884f25b3828e153061f5545cec5578810fbb2cd53d95052e740897a8208345a4186bbfbd755e62a2d51460b686b4df8ad646047f596
6
+ metadata.gz: '08f594ca7c483ae4c7d186f3a279dad9b9c1ce053ac17fa6f41729163a6b6a03ccdf8c4b914722c1edb3c37879000f68dd12cb15fb481054f7aabca41dc78f3f'
7
+ data.tar.gz: 5d44c7bd3a67d8e392b8c18c6f29dfa12f48bc3ddf2620198fd42cee3dd7fcb7a7a2539fdf3f492870888e9b7e71d8214c4e832e79645b4612e98748662e21f7
data/.env CHANGED
@@ -0,0 +1,5 @@
1
+ TEST_ENV_VARIABLE1=test1
2
+ #Commment
3
+ TEST_ENV_VARIABLE2=test2
4
+ TEST_ENV_VARIABLE3=test3
5
+ TEST_ENV_VARIABLE4=test4=with=equals
data/.gitignore CHANGED
@@ -4,4 +4,5 @@
4
4
  /gemfiles/*.gemfile.lock
5
5
  /pkg
6
6
  /tmp
7
- .env
7
+ .env
8
+ *.gem
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
- # Dotenv::Mh
1
+ # Dotenv-mh
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/dotenv/mh`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- ## Usage
16
+ ## Execute Installer
17
+ Execute the following:
18
+
19
+ $ bundle exec dotenvInstaller
18
20
 
19
- TODO: Write usage instructions here
21
+ The installer will create a ".env" file and add it to your .gitignore.
20
22
 
21
- ## Development
23
+ ## .env file
22
24
 
23
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
25
+ This follows the classic .env file structure, where each line represents a tuple of key-value.
24
26
 
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/dotenv-mh.
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
- puts ("installing...")
3
+ LoggerMh.logInfo("installing...")
3
4
 
4
5
  if(!File.file?('.env')) then
5
- puts "creating .env file"
6
+ LoggerMh.logInfo("creating .env file")
7
+
6
8
  File.new(".env", "w")
7
9
 
8
10
  if(File.file?('.gitignore')) then
9
- puts "adding .env into your .gitignore"
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
- puts(".gitignore does not exists, skipping...")
16
+ LoggerMh.logInfo("not able to add '.env' into your .gitignore, file does not exists...")
15
17
  end
16
18
  else
17
- puts ".env file already exists, skipping..."
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. This is a WIP, I would like to add a Rails initializer so that env variables can be loaded from .env file."
13
- # spec.homepage = "Put your gem's website or public repo URL here."
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dotenv
4
4
  module Mh
5
- VERSION = "0.1.6"
5
+ VERSION = "0.1.8"
6
6
  end
7
7
  end
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
- puts ".env file not found"
11
+ LoggerMh.logWarning(".env file not found")
13
12
  return
14
13
  end
15
14
 
16
- puts "loading .env file..."
15
+ LoggerMh.logInfo("loading variables from .env file...")
17
16
 
18
- File.readlines('.env').each do |line|
19
- puts(line)
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
@@ -4,8 +4,6 @@ require "dotenv/mh"
4
4
  module Dotenv
5
5
  class Railtie < Rails::Railtie
6
6
  config.before_configuration do
7
- puts "dotenv-mh: loading .env variables"
8
-
9
7
  Dotenv.load()
10
8
  end
11
9
  end
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.6
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-10-17 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: dotenv gem for loading environment variables from .env file. This is
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: