load_env 0.1.1 → 0.1.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 +4 -4
 - data/Gemfile.lock +2 -2
 - data/lib/load_env.rb +4 -3
 - data/lib/load_env/loader.rb +2 -3
 - data/lib/load_env/railtie.rb +5 -0
 - data/lib/load_env/version.rb +1 -1
 - data/lib/tasks/load_env.rake +24 -0
 - data/load_env.gemspec +1 -1
 - metadata +5 -5
 - data/lib/load_env/generator.rb +0 -30
 - data/lib/load_env/tasks/install.rake +0 -9
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e354ab062701f908812a8e715610d81a1269ec72ca1eabbc3703e934cbe305f6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 55c32679162e726d050e0d74e74850aae134e272d765633e61373c3080e6f71b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 61df7f0cf93578b31e854a1478cc78b9c1c41352847e193874dd946af2ac02f51e7cdfd25c2f517ebf714cdb4f7e70fe0c8ad8e9a621b4e0cde9813bec35fb39
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 86d64880c3228a5bc03286e748157505a2f82dcea362c3be67ee5c60b194d8bfe0865cc7245497fbd80a44527e956667f41d1d07294522831a4ab87ae4e0905b
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                load_env (0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
                load_env (0.1.3)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  dotenv (~> 2.7.5)
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            GEM
         
     | 
| 
       7 
8 
     | 
    
         
             
              remote: https://rubygems.org/
         
     | 
| 
         @@ -28,7 +29,6 @@ PLATFORMS 
     | 
|
| 
       28 
29 
     | 
    
         | 
| 
       29 
30 
     | 
    
         
             
            DEPENDENCIES
         
     | 
| 
       30 
31 
     | 
    
         
             
              bundler (~> 2.0)
         
     | 
| 
       31 
     | 
    
         
            -
              dotenv (~> 2.7.5)
         
     | 
| 
       32 
32 
     | 
    
         
             
              load_env!
         
     | 
| 
       33 
33 
     | 
    
         
             
              rake (~> 10.0)
         
     | 
| 
       34 
34 
     | 
    
         
             
              rspec (~> 3.0)
         
     | 
    
        data/lib/load_env.rb
    CHANGED
    
    | 
         @@ -1,8 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "load_env/version"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
            require 'load_env/railtie' if defined?(Rails)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "load_env/loader"
         
     | 
| 
       3 
4 
     | 
    
         
             
            module LoadEnv
         
     | 
| 
       4 
5 
     | 
    
         
             
              class Error < StandardError; end
         
     | 
| 
       5 
6 
     | 
    
         
             
              # Your code goes here...
         
     | 
| 
      
 7 
     | 
    
         
            +
              LoadEnv::Loader.load
         
     | 
| 
       6 
8 
     | 
    
         
             
            end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            LoadEnv::Loader.load
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
    
        data/lib/load_env/loader.rb
    CHANGED
    
    | 
         @@ -1,12 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'dotenv'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'pathname'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'generator'
         
     | 
| 
       4 
3 
     | 
    
         
             
            module LoadEnv
         
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
      
 4 
     | 
    
         
            +
              module Loader
         
     | 
| 
       6 
5 
     | 
    
         
             
                def self.load
         
     | 
| 
       7 
6 
     | 
    
         
             
                  base_dir = Pathname.new('config')
         
     | 
| 
       8 
7 
     | 
    
         
             
                  env_var_dir = base_dir.join('.env_vars')
         
     | 
| 
       9 
     | 
    
         
            -
                  env_secrets = File.join(env_var_dir, "#{ENV['RAILS_ENV']} || #{ENV['RACK_ENV']} || 'development' 
     | 
| 
      
 8 
     | 
    
         
            +
                  env_secrets = File.join(env_var_dir, "#{ENV['RAILS_ENV']}" || "#{ENV['RACK_ENV']}" || 'development')
         
     | 
| 
       10 
9 
     | 
    
         
             
                  Dotenv.load(env_secrets)
         
     | 
| 
       11 
10 
     | 
    
         
             
                end
         
     | 
| 
       12 
11 
     | 
    
         
             
              end
         
     | 
    
        data/lib/load_env/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'pathname'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            namespace :load_env do
         
     | 
| 
      
 4 
     | 
    
         
            +
              desc 'Install Env Loader'
         
     | 
| 
      
 5 
     | 
    
         
            +
              task :install do
         
     | 
| 
      
 6 
     | 
    
         
            +
                envs = %w(production development)
         
     | 
| 
      
 7 
     | 
    
         
            +
                base_dir = ENV["BASE_DIR"] || Pathname.new('config/.env_vars')
         
     | 
| 
      
 8 
     | 
    
         
            +
                mkdir_p base_dir
         
     | 
| 
      
 9 
     | 
    
         
            +
                env_files = %w(development production)
         
     | 
| 
      
 10 
     | 
    
         
            +
                env_files.each do |file_name|
         
     | 
| 
      
 11 
     | 
    
         
            +
                  full_path = base_dir.join(file_name)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  if File.exists? full_path
         
     | 
| 
      
 13 
     | 
    
         
            +
                    warn "[skip] #{full_path} already exists"
         
     | 
| 
      
 14 
     | 
    
         
            +
                  else
         
     | 
| 
      
 15 
     | 
    
         
            +
                    File.open(full_path, 'w+') do |f|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      f.write('
         
     | 
| 
      
 17 
     | 
    
         
            +
            # Please export your environment variables in following format \n
         
     | 
| 
      
 18 
     | 
    
         
            +
            # export BASE_URL="someurl"
         
     | 
| 
      
 19 
     | 
    
         
            +
                    ')
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
    
        data/load_env.gemspec
    CHANGED
    
    | 
         @@ -27,5 +27,5 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       27 
27 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 2.0"
         
     | 
| 
       28 
28 
     | 
    
         
             
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
| 
       29 
29 
     | 
    
         
             
              spec.add_development_dependency "rspec", "~> 3.0"
         
     | 
| 
       30 
     | 
    
         
            -
              spec. 
     | 
| 
      
 30 
     | 
    
         
            +
              spec.add_dependency "dotenv", "~> 2.7.5"
         
     | 
| 
       31 
31 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: load_env
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Suman Awal
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-11-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -59,7 +59,7 @@ dependencies: 
     | 
|
| 
       59 
59 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       60 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       61 
61 
     | 
    
         
             
                    version: 2.7.5
         
     | 
| 
       62 
     | 
    
         
            -
              type: : 
     | 
| 
      
 62 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
       63 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       64 
64 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       65 
65 
     | 
    
         
             
                requirements:
         
     | 
| 
         @@ -83,10 +83,10 @@ files: 
     | 
|
| 
       83 
83 
     | 
    
         
             
            - bin/console
         
     | 
| 
       84 
84 
     | 
    
         
             
            - bin/setup
         
     | 
| 
       85 
85 
     | 
    
         
             
            - lib/load_env.rb
         
     | 
| 
       86 
     | 
    
         
            -
            - lib/load_env/generator.rb
         
     | 
| 
       87 
86 
     | 
    
         
             
            - lib/load_env/loader.rb
         
     | 
| 
       88 
     | 
    
         
            -
            - lib/load_env/ 
     | 
| 
      
 87 
     | 
    
         
            +
            - lib/load_env/railtie.rb
         
     | 
| 
       89 
88 
     | 
    
         
             
            - lib/load_env/version.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - lib/tasks/load_env.rake
         
     | 
| 
       90 
90 
     | 
    
         
             
            - load_env.gemspec
         
     | 
| 
       91 
91 
     | 
    
         
             
            homepage: https://github.com/sumanawal/load_env
         
     | 
| 
       92 
92 
     | 
    
         
             
            licenses: []
         
     | 
    
        data/lib/load_env/generator.rb
    DELETED
    
    | 
         @@ -1,30 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            module LoadEnv
         
     | 
| 
       2 
     | 
    
         
            -
              class Generator
         
     | 
| 
       3 
     | 
    
         
            -
                def initialize(env_path)
         
     | 
| 
       4 
     | 
    
         
            -
                  @env_path = env_path
         
     | 
| 
       5 
     | 
    
         
            -
                end
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
                def generate
         
     | 
| 
       8 
     | 
    
         
            -
                  env_files = %w(development production)
         
     | 
| 
       9 
     | 
    
         
            -
                  env_files.each do |file_name|
         
     | 
| 
       10 
     | 
    
         
            -
                    full_path = env_files.join(file_name)
         
     | 
| 
       11 
     | 
    
         
            -
                    if File.exists? full_path
         
     | 
| 
       12 
     | 
    
         
            -
                      warn '[skip] #{file_name} already exists'
         
     | 
| 
       13 
     | 
    
         
            -
                    else
         
     | 
| 
       14 
     | 
    
         
            -
                      File.open(full_path, 'w+') do |f|
         
     | 
| 
       15 
     | 
    
         
            -
                        f.write(env_file_template)
         
     | 
| 
       16 
     | 
    
         
            -
                      end
         
     | 
| 
       17 
     | 
    
         
            -
                    end
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
                end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                private
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                def env_file_template
         
     | 
| 
       24 
     | 
    
         
            -
                  '
         
     | 
| 
       25 
     | 
    
         
            -
                    Please export your environment variables in following format \n
         
     | 
| 
       26 
     | 
    
         
            -
                    # export BASE_URL="someurl"
         
     | 
| 
       27 
     | 
    
         
            -
                  '
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
            end
         
     |