dip 3.2.1 → 3.2.2

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
2
  SHA256:
3
- metadata.gz: abbdaa0602b48327279319f97a75b9ca796721a4874474d08ca2920290177658
4
- data.tar.gz: 78a0e91fede2c213845c9a22c3ce25384ac84c5228dba420f1bdb47ac5332146
3
+ metadata.gz: 68471b4b42a417236e46b120ffc1fc1b3fa2b460f20b872f606e485db200f919
4
+ data.tar.gz: bb84c40826d34bd0e5aed8f821d96989255a9657dc66c4d4906af773ab2881e9
5
5
  SHA512:
6
- metadata.gz: f3f12268f1e7f51ba336beb65bf40e0ba50ce6c4ca95551e7b7d394a67500a61df66adba5cd375c8b61d379b964e774c1d126ee0ca42e94b37e4df9a4b03fbeb
7
- data.tar.gz: 62820d8bfe0fb92bf20a6b9f4723c47a6b8cddf005ef20a03cff917744df6fcb2d1a37e0ea460383ba87d72a8db7f13a5658e5baae712f622849406500e847ec
6
+ metadata.gz: b655ab8c4f76cc4efd40b374c2c4e027fa8d8069d49c4f988e106c936f8add208f7ef8266fa662dcccc7febc60ec01eeae7b45149fba802ae0876c9022478817
7
+ data.tar.gz: a5fef124479d47fa6e9b113cfc0355a9284d92c748548d7e5552b04e038e8b7775a2a467ca699c3f6f3309f4cefbe62e5fba70de6c96c6090f1f4b61354c0150
data/exe/dip CHANGED
@@ -6,7 +6,12 @@ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
6
6
 
7
7
  require 'dip'
8
8
  require 'dip/cli'
9
- require 'pry-byebug' if Dip.debug?
9
+
10
+ begin
11
+ require 'pry-byebug' if Dip.debug?
12
+ rescue LoadError
13
+ puts "pry-byebug not found!"
14
+ end
10
15
 
11
16
  Signal.trap('INT') do
12
17
  warn("\n#{caller.join("\n")}: interrupted")
data/lib/dip.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "dip/version"
4
3
  require "dip/config"
5
4
  require "dip/environment"
6
5
 
@@ -8,24 +7,18 @@ module Dip
8
7
  Error = Class.new(StandardError)
9
8
 
10
9
  class << self
11
- def config_path
12
- ENV["DIP_FILE"] || File.join(Dir.pwd, "dip.yml")
13
- end
14
-
15
10
  def config
16
- @config ||= Dip::Config.new(config_path)
11
+ @config ||= Dip::Config.new
17
12
  end
18
13
 
19
14
  def env
20
- @env ||= Dip::Environment.new(config.environment)
21
- end
22
-
23
- def test?
24
- ENV["DIP_ENV"] == "test"
15
+ @env ||= Dip::Environment.new(config.exist? ? config.environment : {})
25
16
  end
26
17
 
27
- def debug?
28
- ENV["DIP_ENV"] == "debug"
18
+ %w(test debug).each do |key|
19
+ define_method("#{key}?") do
20
+ ENV["DIP_ENV"] == key
21
+ end
29
22
  end
30
23
 
31
24
  def reset!
@@ -11,7 +11,7 @@ module Dip
11
11
  def initialize(cmd, argv = [])
12
12
  @cmd = cmd
13
13
  @argv = argv
14
- @config = ::Dip.config.compose
14
+ @config = ::Dip.config.compose || {}
15
15
  end
16
16
 
17
17
  def execute
@@ -5,42 +5,40 @@ require "erb"
5
5
 
6
6
  module Dip
7
7
  class Config
8
- def initialize(config_path)
9
- load_or_default(config_path)
10
- end
8
+ DEFAULT_PATH = "dip.yml"
11
9
 
12
- def merge(config)
13
- @config.merge!(config)
10
+ def initialize
11
+ @path = ENV["DIP_FILE"] || File.join(Dir.pwd, DEFAULT_PATH)
14
12
  end
15
13
 
16
- def environment
17
- @config.fetch(:environment, {})
14
+ def exist?
15
+ File.exist?(@path)
18
16
  end
19
17
 
20
- def compose
21
- @config.fetch(:compose, {})
18
+ %i[environment compose interaction provision].each do |key|
19
+ define_method(key) do
20
+ config[key]
21
+ end
22
22
  end
23
23
 
24
- def interaction
25
- @config.fetch(:interaction, {})
24
+ def to_h
25
+ config
26
26
  end
27
27
 
28
- def provision
29
- @config.fetch(:provision)
28
+ private
29
+
30
+ def config
31
+ @config ||= load
30
32
  end
31
33
 
32
- private
34
+ def load
35
+ raise ArgumentError, "Dip config not found at path '#{@path}'" unless exist?
33
36
 
34
- def load_or_default(config_path)
35
- @config ||= if File.exist?(config_path) && !Dip.test?
36
- YAML.safe_load(
37
- ERB.new(File.read(config_path)).result,
38
- [], [], true,
39
- symbolize_names: true
40
- )
41
- else
42
- {}
43
- end
37
+ @config = YAML.safe_load(
38
+ ERB.new(File.read(@path)).result,
39
+ [], [], true,
40
+ symbolize_names: true
41
+ )
44
42
  end
45
43
  end
46
44
  end
@@ -10,7 +10,7 @@ module Dip
10
10
  def initialize(default_vars)
11
11
  @vars = {}
12
12
 
13
- merge(default_vars)
13
+ merge(default_vars || {})
14
14
  end
15
15
 
16
16
  def merge(new_vars)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dip
4
- VERSION = "3.2.1"
4
+ VERSION = "3.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bibendi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-06 00:00:00.000000000 Z
11
+ date: 2018-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor