populate-env 0.1.0 → 0.1.1

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
- SHA1:
3
- metadata.gz: c899bcaa6bfb1b2ee92df5f11510b8769410b55f
4
- data.tar.gz: f316c621e3ed6846f317f57f9ad326ef202c55d7
2
+ SHA256:
3
+ metadata.gz: c52ba2e454dad8b543ac962ed672561bae13c48f2565cde305813af01cd1b567
4
+ data.tar.gz: c3d316ed975b6ab0a28f1b5bc8035e3ce1d5b2418d47d1dd8bd4d8ade3fca757
5
5
  SHA512:
6
- metadata.gz: e559cca288de0ff277aafcb670531025da96f2330226976efdd8b213cd84aff6a7a28a1a3025f1384b5a165b12f7c27618213ce6e6d5d3b708c50e7d673b934a
7
- data.tar.gz: 125991f277d55a000e684e9247917bf67bab418a0c5f18c3fa05f722d052877d0a7fb47c16930885eb347f277612db20b71c1661c9a6914d1db9d045920cc1a2
6
+ metadata.gz: 804912c25cd36c104f9ebf0922aebb2488bf8c0f88dfc2d22bb05da2193c803fbffdad5af02d1f607dca52120fd3ce8a6c0707b328be868717ef8c3ae3773bdb
7
+ data.tar.gz: dde38e0bca6d7b6a343849409a6b2b0c92a5280eb70db211aaf5656c460f3a2cc203de30dff1b0eec7c25072267da7747359d8ee8426c7f1de72eb5cb0ddcfd4
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # populate-env
2
2
 
3
- A command-line tool for populating environment variables.
3
+ [![Build Status](https://travis-ci.org/Aupajo/populate-env.svg?branch=master)](https://travis-ci.org/Aupajo/populate-env)
4
4
 
5
+ A command-line tool for populating environment variables.
5
6
 
6
7
  ## Installation
7
8
 
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "populate/env"
4
+ require "populate_env"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -57,6 +57,11 @@ module PopulateEnv
57
57
  options.prompt_missing = value
58
58
  end
59
59
 
60
+ description = "Prefix variable declarations in output with export (defaults to #{options.skip_local_env})"
61
+ parser.on("--[no-]export", description) do |value|
62
+ options.export = value
63
+ end
64
+
60
65
  parser.parse!(argv)
61
66
 
62
67
  options
@@ -28,14 +28,14 @@ module PopulateEnv
28
28
 
29
29
  def option_parser
30
30
  @option_parser ||= OptionParser.new do |parser|
31
- parser.banner = <<~BANNER
32
- Usage:
33
- #{executable} COMMAND [options]
34
-
35
- Commands:
36
- heroku
37
-
38
- Options:
31
+ parser.banner = <<-BANNER
32
+ Usage:
33
+ #{executable} COMMAND [options]
34
+
35
+ Commands:
36
+ heroku
37
+
38
+ Options:
39
39
  BANNER
40
40
 
41
41
  description = 'Show the help (combine with a command for full options)'
@@ -1,10 +1,15 @@
1
1
  module PopulateEnv
2
2
  module Formatters
3
3
  class EnvShellSection
4
- attr_reader :attribute
4
+ attr_reader :attribute, :export
5
5
 
6
- def initialize(attribute)
6
+ def initialize(attribute, export: false)
7
7
  @attribute = attribute
8
+ @export = export
9
+ end
10
+
11
+ def prefix
12
+ export ? "export " : ""
8
13
  end
9
14
 
10
15
  def to_s
@@ -20,7 +25,7 @@ module PopulateEnv
20
25
  output << "# "
21
26
  end
22
27
 
23
- output << "#{attribute.name}=#{attribute.value}\n"
28
+ output << "#{prefix}#{attribute.name}=#{attribute.value}\n"
24
29
  end
25
30
  end
26
31
  end
@@ -24,7 +24,7 @@ module PopulateEnv
24
24
  private
25
25
 
26
26
  def attempt_to_populate_value
27
- if !options.skip_local_env && options.local_env[definition.name]
27
+ if options.skip_local_env && options.local_env[definition.name]
28
28
  skip_due_to_local_env_var
29
29
  return
30
30
  end
@@ -22,7 +22,7 @@ module PopulateEnv
22
22
  def sections
23
23
  attribute_definitions.map do |definition|
24
24
  attribute = AttributeCompilation.new(definition, options, remote_config).perform
25
- Formatters::EnvShellSection.new(attribute) if attribute
25
+ Formatters::EnvShellSection.new(attribute, export: options.export) if attribute
26
26
  end
27
27
  end
28
28
 
@@ -11,7 +11,11 @@ module PopulateEnv
11
11
  begin
12
12
  data = JSON.parse(@path.read, symbolize_names: true)
13
13
  env_vars = data.fetch(:env, {})
14
- env_vars.merge!(data.dig(:environments, environment.to_sym, :env) || {})
14
+ env_vars.merge!(
15
+ data.fetch(:environments, {})
16
+ .fetch(environment.to_sym, {})
17
+ .fetch(:env, {})
18
+ )
15
19
 
16
20
  env_vars.map do |key, value|
17
21
  if value.is_a?(Hash)
@@ -12,8 +12,9 @@ module PopulateEnv
12
12
  use_heroku_config: true,
13
13
  heroku_app: nil,
14
14
  heroku_remote: nil,
15
- skip_local_env: false,
15
+ skip_local_env: true,
16
16
  prompt_missing: true,
17
+ export: false,
17
18
  output: $stdout,
18
19
  input: $stdin,
19
20
  local_env: ENV
@@ -1,3 +1,3 @@
1
1
  module PopulateEnv
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/populate-env.gemspec CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
+ spec.required_ruby_version = '~> 2.3'
24
+
23
25
  spec.add_development_dependency "bundler", "~> 1.15"
24
26
  spec.add_development_dependency "rake", "~> 10.0"
25
27
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: populate-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Nicholls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-12 00:00:00.000000000 Z
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,9 +98,9 @@ require_paths:
98
98
  - lib
99
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '2.3'
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.6.11
111
+ rubygems_version: 2.7.6
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: A command-line tool for populating environment variables