dotenv 2.7.2 → 2.7.3

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: b740f417d40477078789125a03eafd06c1c8398a014f5760e609238d661c7a24
4
+ data.tar.gz: c7a53ef47fb24998a9ed63bb4ef7565d4f10040d187827f23ccb4e9e162168d9
5
5
  SHA512:
6
- metadata.gz: 50390ce0eb353dd3baf5c3a42391e57c5f75dc216dc965e5dd07ec508196a75e52fedf15747389a7d403568f127929b62c1d190467c3b60a578270a76e396991
7
- data.tar.gz: 3ea3c50031729d18f21d619f17f7463ceb9a5409415e97b84bd98038dcf2f1ba44f6a9cd884fbc4f3c61cf408b1fd5ebafdf9f4939231acae388e232d28bbfd8
6
+ metadata.gz: dc1efb88938da1dca0bd4f7d50296177b23bb349f0c3aa566b284fff950e83bfd1827e9c9fd6bab008ea4e5811d91777920445ecc4b59312b42ac62e2898cde4
7
+ data.tar.gz: ca8827d32698f274232af990871b7e8396d9a6c0c7b9887fe28ab0af10d3ec1fb7c9ccefe6d228436103c03e5a7a3f259a2bf9ced2e8523699befecc3de4936b
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?
@@ -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
@@ -21,7 +22,7 @@ module Dotenv
21
22
  rescue Errno::ENOENT => e
22
23
  abort e.message
23
24
  else
24
- exec(*@argv) unless @argv.empty?
25
+ exec(*@argv) if @argv.present?
25
26
  end
26
27
  end
27
28
 
@@ -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.3".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.3
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-22 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: