dotenv 2.7.2 → 2.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9da8f2d53f6ac0a52f98d5e5c8ae9a2bf80556737a2a040cb0d21f1e6dd94b5
4
- data.tar.gz: 973029ac871fe3e7880c91a812d2140a570c1298dfced693820ce10f877e40de
3
+ metadata.gz: 32d793ec7a9658f9ba0430a02fd476f59a1419966beb9075f9d98cafcf3a1011
4
+ data.tar.gz: f90ee6fb4800d609d2b45c3e5fbb83deeab5233ed240d05f91653029b75a8bff
5
5
  SHA512:
6
- metadata.gz: 50390ce0eb353dd3baf5c3a42391e57c5f75dc216dc965e5dd07ec508196a75e52fedf15747389a7d403568f127929b62c1d190467c3b60a578270a76e396991
7
- data.tar.gz: 3ea3c50031729d18f21d619f17f7463ceb9a5409415e97b84bd98038dcf2f1ba44f6a9cd884fbc4f3c61cf408b1fd5ebafdf9f4939231acae388e232d28bbfd8
6
+ metadata.gz: 99ecdc886adbb511fca292305f27f9eff8a6035a3ee266a358a61965d611f31fb1a9742b0662ac085d8112a45298b78b662336bc920de97b9da37818487a9417
7
+ data.tar.gz: a0b13a9af84d9870431dc42b1e206581f43dc3e3fe8b9f05ad573b5f5740fdf4844c372f8d96827a3f3b51bbe64bddc19ca7ca50895ff8af4d17abcc28a68d16
data/README.md CHANGED
@@ -218,6 +218,29 @@ If you use this gem to handle env vars for multiple Rails environments (developm
218
218
 
219
219
  Credentials should only be accessible on the machines that need access to them. Never commit sensitive information to a repository that is not needed by every development machine and server.
220
220
 
221
+
222
+ You can use the `-t` or `--template` flag on the dotenv cli to create a template of your `.env` file.
223
+ ```shell
224
+ $ dotenv -t .env
225
+ ```
226
+ A template will be created in your working directory named `{FINAME}.template`. So in the above example, it would create a `.env.template` file.
227
+
228
+ The template will contain all the environment variables in your `.env` file but with their values set to the variable names.
229
+
230
+ ```shell
231
+ # .env
232
+ S3_BUCKET=YOURS3BUCKET
233
+ SECRET_KEY=YOURSECRETKEYGOESHERE
234
+ ```
235
+
236
+ Would become
237
+
238
+ ```shell
239
+ # .env.template
240
+ S3_BUCKET=S3_BUCKET
241
+ SECRET_KEY=SECRET_KEY
242
+ ```
243
+
221
244
  Personally, I prefer to commit the `.env` file with development-only settings. This makes it easy for other developers to get started on the project without compromising credentials for other environments. If you follow this advice, make sure that all the credentials for your development environment are different from your other deployments and that the development credentials do not have access to any confidential data.
222
245
 
223
246
  ### Why is it not overriding existing `ENV` variables?
data/lib/dotenv/cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "dotenv"
2
2
  require "dotenv/version"
3
+ require "dotenv/template"
3
4
  require "optparse"
4
5
 
5
6
  module Dotenv
@@ -39,6 +40,7 @@ module Dotenv
39
40
  add_files_option(parser)
40
41
  add_help_option(parser)
41
42
  add_version_option(parser)
43
+ add_template_option(parser)
42
44
  end
43
45
 
44
46
  def add_files_option(parser)
@@ -61,6 +63,13 @@ module Dotenv
61
63
  end
62
64
  end
63
65
 
66
+ def add_template_option(parser)
67
+ parser.on("-t", "--template=FILE", "Create a template env file") do |file|
68
+ template = Dotenv::EnvTemplate.new(file)
69
+ template.create_template
70
+ end
71
+ end
72
+
64
73
  def create_option_parser
65
74
  OptionParser.new do |parser|
66
75
  parser.banner = "Usage: dotenv [options]"
@@ -0,0 +1,19 @@
1
+ module Dotenv
2
+ # Class for creating a template from a env file
3
+ class EnvTemplate
4
+ def initialize(env_file)
5
+ @env_file = env_file
6
+ end
7
+
8
+ def create_template
9
+ File.open(@env_file, "r") do |env_file|
10
+ File.open("#{@env_file}.template", "w") do |env_template|
11
+ env_file.each do |line|
12
+ variable = line.split("=").first
13
+ env_template.puts "#{variable}=#{variable}"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Dotenv
2
- VERSION = "2.7.2".freeze
2
+ VERSION = "2.7.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -72,6 +72,7 @@ files:
72
72
  - lib/dotenv/substitutions/command.rb
73
73
  - lib/dotenv/substitutions/variable.rb
74
74
  - lib/dotenv/tasks.rb
75
+ - lib/dotenv/template.rb
75
76
  - lib/dotenv/version.rb
76
77
  homepage: https://github.com/bkeepers/dotenv
77
78
  licenses: