dory 0.2.0 → 0.2.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
2
  SHA1:
3
- metadata.gz: dd130b3cf0b939ac79261dced4f91430d1c391ba
4
- data.tar.gz: 2f7465a0c96d42c3a13f2d725f8b8f8e0c931a9d
3
+ metadata.gz: 32d77f426394ec85bbbe2bab82c51827a606b5f3
4
+ data.tar.gz: 3c1f263e12aeb27daa447956eafd76cb8d2784af
5
5
  SHA512:
6
- metadata.gz: 2efd954506347e634028b6c5f7aebd0305736eba68921d3e415574bc5922def0bc4a17639054e60cfdf4796dda0b8b23b5ecd32f1e3e453a107a6f3b731e4ea5
7
- data.tar.gz: 2393eac90e2b129a9cc60d77c1f6f35fe3bd63771d7454d129ad75769e6ce8dbeb4a1e920588f650a23f335a2f7114c5cc267643a029f17dc1e291154de12508
6
+ metadata.gz: 4b6628655fa991c06bf885fac5e5e51a9e8529d0cf2e7ab89e9ac71d0ce4770f37e34ace70b03697f5c909b707e84bab711305387a31c62d2a62c6fe857fcb93
7
+ data.tar.gz: 32bcb7f13b507fb798f6e4882f4a4640edd31630e5a3b7578a3416273650001ffbe9d9f57850bcf56566f9a8e66e001158bcb74c558190b7540453daeb4fea26
data/bin/dory CHANGED
@@ -69,23 +69,45 @@ class DoryBin < Thor
69
69
  containing the default settings. This can then be configured
70
70
  as preferred.
71
71
  LONGDESC
72
+ option :upgrade, type: :boolean, aliases: 'u', default: false
73
+ option :force, type: :boolean, aliases: 'f', default: false
72
74
  def config_file
73
75
  exec_config_file(options)
74
76
  end
75
77
 
76
78
  private
77
79
 
78
- def exec_config_file(_options)
80
+ def config_file_action(options)
81
+ if options[:upgrade]
82
+ 'u'
83
+ elsif options[:force]
84
+ 'o'
85
+ else
86
+ print "A config file already exists at #{Dory::Config.filename}. [U]pgrade, [O]verwrite with default settings, or do [N]othing? (U/O/N): ".yellow
87
+ STDIN.gets.chomp
88
+ end
89
+ end
90
+
91
+ def take_action(action)
92
+ if action =~ /u/i
93
+ puts "Upgrading config file at #{Dory::Config.filename}".green
94
+ Dory::Config.upgrade_settings_file
95
+ elsif action =~ /o/i
96
+ puts "Overwriting config file with new version at #{Dory::Config.filename}".green
97
+ Dory::Config.write_default_settings_file
98
+ else
99
+ puts "User declined. Not writing config file".red
100
+ return
101
+ end
102
+ end
103
+
104
+ def exec_config_file(options)
79
105
  if File.exist?(Dory::Config.filename)
80
- print "A config file already exists at #{Dory::Config.filename}. Overwrite with default settings? (Y/N): ".yellow
81
- conf = STDIN.gets.chomp
82
- unless conf =~ /y/i
83
- puts "User declined over-writing. Not writing config file".red
84
- return
85
- end
106
+ take_action(config_file_action(options))
107
+ else
108
+ puts "Writing new config file to #{Dory::Config.filename}".green
109
+ Dory::Config.write_default_settings_file
86
110
  end
87
- puts "Writing config file to #{Dory::Config.filename}".green
88
- Dory::Config.write_default_settings_file
89
111
  end
90
112
 
91
113
  def exec_up(options)
data/lib/dory/config.rb CHANGED
@@ -57,6 +57,7 @@ module Dory
57
57
 
58
58
  def self.write_settings(settings, filename = self.filename, is_yaml: false)
59
59
  settings = settings.to_yaml unless is_yaml
60
+ settings.gsub!(/\s*!ruby\/hash:ActiveSupport::HashWithIndifferentAccess/, '')
60
61
  File.write(filename, settings)
61
62
  end
62
63
 
@@ -13,21 +13,19 @@ module Dory
13
13
  end
14
14
 
15
15
  def start(handle_error: true)
16
- unless self.running?
16
+ if self.running?
17
+ puts "Container '#{self.container_name}' is already running"
18
+ else
17
19
  self.run_preconditions
18
- status = if self.container_exists?
19
- if Dory::Config.debug?
20
- puts "[DEBUG] Container '#{self.container_name}' already exists. " \
21
- "Starting with '#{self.start_cmd}'"
22
- end
23
- Sh.run_command(self.start_cmd)
24
- else
25
- if Dory::Config.debug?
26
- puts "[DEBUG] Container '#{self.container_name}' does not exist. " \
27
- "Creating/starting with '#{self.run_command}'"
28
- end
29
- Sh.run_command(self.run_command)
30
- end
20
+ if self.container_exists?
21
+ puts "[DEBUG] Container '#{self.container_name}' exists. Deleting"
22
+ self.delete
23
+ end
24
+ if Dory::Config.debug?
25
+ puts "[DEBUG] does not exist. Creating/starting " \
26
+ "'#{self.container_name}' with '#{self.run_command}'"
27
+ end
28
+ status = Sh.run_command(self.run_command)
31
29
  unless status.success?
32
30
  if !handle_error || !self.handle_error(status)
33
31
  raise RuntimeError.new(
data/lib/dory/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Dory
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  DATE = '2016-06-09'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Porter