unenviable 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/unenviable +25 -5
  3. data/lib/unenviable.rb +32 -9
  4. metadata +10 -15
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b4ca11bfbd9362708851817f675a59613fa9aca
4
+ data.tar.gz: 999ac1a8fa23b724e604cab78ae327aea47f8b4f
5
+ SHA512:
6
+ metadata.gz: 53033b7681aa86ab1d0539e5269b53a78adb570cc45cb8da8cca03bd76a66fe4279b1d3b22a4a123c6ae8509b9bd8b074e24e5f84b1f792f5e143ac8ef07eb03
7
+ data.tar.gz: 21c2006ae8dbef63921f90221ddec22434ac9afdff1bc010d7d9f80ca89eba0539acf1057921f4176a513f4ded2aa9c894553fd1b9f441737102cf6bc5a050a1
data/bin/unenviable CHANGED
@@ -2,10 +2,30 @@
2
2
  # encoding: utf-8
3
3
  require 'unenviable'
4
4
 
5
- required, optional, forbidden = Unenviable.check
5
+ CHECK_USAGE = 'unenviable check'
6
+ GENERATE_USAGE = 'unenviable generate'
6
7
 
7
- if required.size > 0
8
- puts ""
9
- required.each { |req| }
8
+ def show_errors(errors)
9
+ return if errors.size == 0
10
+ puts 'Usage: ' + errors[0]
11
+ errors[1..-1].each { |e| puts ' ' + e }
12
+ exit 1
13
+ end
10
14
 
11
- forbidden.each
15
+ def check_params(params)
16
+ case params[0]
17
+ when 'check'
18
+ when 'generate'
19
+ else
20
+ show_errors([CHECK_USAGE, GENERATE_USAGE])
21
+ end
22
+ end
23
+
24
+ check_params(ARGV)
25
+
26
+ case ARGV[0]
27
+ when 'check'
28
+ Unenviable.check
29
+ when 'generate'
30
+ Unenviable.generate
31
+ end
data/lib/unenviable.rb CHANGED
@@ -2,9 +2,13 @@
2
2
  require 'dotenv'
3
3
  require 'yaml'
4
4
 
5
+ require 'unenviable/env_wrapper'
6
+
5
7
  # Handles loading a YAML file that will describe what ENV variables
6
8
  # are necessary for a twelve-factor app in a specific environment.
7
9
  module Unenviable
10
+ attr_writer :env_list
11
+
8
12
  def self.check
9
13
  load_env_descriptions unless @env_list
10
14
  Dotenv.load
@@ -19,15 +23,6 @@ module Unenviable
19
23
  discrepancies
20
24
  end
21
25
 
22
- def create_minimum_dotenv
23
- load_env_descriptions unless @env_list
24
- File.new('.env', 'wb') do |f|
25
- @env_list.each do |var, details|
26
- f.write("export #{var}=#{details['initial_value']}") if details[:required]
27
- end
28
- end
29
- end
30
-
31
26
  def self.env_descriptions_file_location
32
27
  'config/unenviable.yml'
33
28
  end
@@ -36,6 +31,34 @@ module Unenviable
36
31
  @env_list = env_list
37
32
  end
38
33
 
34
+ def self.install_wrapper
35
+ wrapper = Unenviable::ENVWrapper.new
36
+ Object.send(:remove_const, :ENV)
37
+ Object.const_set(:ENV, wrapper)
38
+ end
39
+
40
+ def self.described?(key)
41
+ @env_list.include?(key)
42
+ end
43
+
44
+ def self.generate
45
+ load_env_descriptions unless @env_list
46
+ File.new('.env', 'wb') do |f|
47
+ generate_dotenv_lines.each { |l| f.write(l) }
48
+ end
49
+ end
50
+
51
+ def self.generate_dotenv_lines
52
+ lines = []
53
+ @env_list.each do |var, details|
54
+ lines << "# #{details[:description]}"
55
+ lines << "#{var}=#{details[:initial_value]}" if details[:required]
56
+ lines << "##{var}=#{details[:initial_value]}" unless details[:required]
57
+ end
58
+
59
+ lines
60
+ end
61
+
39
62
  private
40
63
 
41
64
  # Load the file that descriptions the required environment variables
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unenviable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - K M Lawrence
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-25 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: dotenv
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.11.1
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.11.1
30
27
  description: Makes ENV vars easier to keep track of in distributed development
@@ -34,32 +31,30 @@ executables:
34
31
  extensions: []
35
32
  extra_rdoc_files: []
36
33
  files:
37
- - lib/unenviable.rb
38
34
  - bin/unenviable
35
+ - lib/unenviable.rb
39
36
  homepage: http://rubygems.org/gems/unenviable
40
37
  licenses:
41
38
  - MIT
39
+ metadata: {}
42
40
  post_install_message:
43
41
  rdoc_options: []
44
42
  require_paths:
45
43
  - lib
46
44
  required_ruby_version: !ruby/object:Gem::Requirement
47
- none: false
48
45
  requirements:
49
- - - ! '>='
46
+ - - ">="
50
47
  - !ruby/object:Gem::Version
51
48
  version: '0'
52
49
  required_rubygems_version: !ruby/object:Gem::Requirement
53
- none: false
54
50
  requirements:
55
- - - ! '>='
51
+ - - ">="
56
52
  - !ruby/object:Gem::Version
57
53
  version: '0'
58
54
  requirements: []
59
55
  rubyforge_project:
60
- rubygems_version: 1.8.24
56
+ rubygems_version: 2.4.2
61
57
  signing_key:
62
- specification_version: 3
58
+ specification_version: 4
63
59
  summary: Unenviable
64
60
  test_files: []
65
- has_rdoc: