dory 0.2.2 → 0.2.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
  SHA1:
3
- metadata.gz: 044e607a99a4f25539f2cc21b25bdd44967dbbb3
4
- data.tar.gz: bb755b5e86eacfd5d50d4b2e689cd9899e09cd0e
3
+ metadata.gz: 32c9e4b0eaede749e6fb0ab53d184ca331a74d80
4
+ data.tar.gz: 4db9c23f23df1b83eca58c423dfea1e6ef5a1d92
5
5
  SHA512:
6
- metadata.gz: 33a1572f8e8d9d7602f131d87dd950c590b82975ba719c079707161864de56af9f9fbe1e7b6b2c74b9b1527e575ec252ed423d9710d4e9f07e16e289a646d71e
7
- data.tar.gz: c614e5556ec5ae284334ac52dea2cc067f7a73a88aaf5a075602eda509ca7ad28cee0224faeaecc2cee633a700f5bedd86ac61afe43f11e1385da875e7314daa
6
+ metadata.gz: 282ca8afe16ac103b1a134a5c2a4fb834d60e7bc70f589e81e7b07cd24e7839b8925b03fd3eefa0065e3d7bd553fdae495ec2ab88348422ac1c61944ac25ffb3
7
+ data.tar.gz: 7daa417f20874fcfee2f9bbba23adeada9cc7a30c15353c259f749dd11efb21c1b5348627a3a30a23bb7b27d0d6de2529fd332429c1ef541fa59b9b3f0a400be
data/bin/dory CHANGED
@@ -8,6 +8,22 @@ require 'dory'
8
8
  class DoryBin < Thor
9
9
  class_option :verbose, type: :boolean, aliases: 'v', default: false
10
10
 
11
+ desc 'upgrade', 'Upgrade dory to the latest version'
12
+ long_desc <<-LONGDESC
13
+ Upgrades dory to the latest version. Old versions are cleaned up
14
+
15
+ If dory was installed with sudo, this may not work. You will
16
+ have to do it manually:
17
+
18
+ sudo gem install dory # install the latest versions
19
+ sudo gem cleanup dory # cleanup old versions
20
+
21
+ > $ dory upgrade
22
+ LONGDESC
23
+ def upgrade
24
+ exec_upgrade(options)
25
+ end
26
+
11
27
  desc 'up', 'Bring up dory services (nginx-proxy, dnsmasq, resolv)'
12
28
  long_desc <<-LONGDESC
13
29
  Bring up dory services (nginx-proxy, dnsmasq, resolv)
@@ -77,6 +93,42 @@ class DoryBin < Thor
77
93
 
78
94
  private
79
95
 
96
+ def exec_upgrade(_options)
97
+ puts "Checking if dory has updates available...".green
98
+ new_version = Dory::Upgrade.new_version
99
+ if new_version
100
+ if Dory::Upgrade.outdated?(new_version)
101
+ puts "New version #{new_version} is available. You currently have #{Dory::VERSION}.".yellow
102
+ print "Would you like to install the update? (Y/N): ".yellow
103
+ if STDIN.gets.chomp =~ /y/i
104
+ puts "Upgrading dory...".green
105
+ if Dory::Upgrade.install.success?
106
+ if Dory::Upgrade.cleanup.success?
107
+ puts "New version installed successfully!\n" \
108
+ "You may want to upgrade your config file with:\n\n" \
109
+ " dory config-file --upgrade".green
110
+ else
111
+ puts "Failure cleaning up old versions of dory. You may want " \
112
+ "to run 'gem cleanup dory' manually.".red
113
+ end
114
+ else
115
+ puts "Failure installing new version of dory. If you are " \
116
+ "installing into a system ruby, this could be because " \
117
+ "you need to use sudo. Please try 'gem install dory' " \
118
+ "manually, and then 'gem cleanup dory' to remove old " \
119
+ "versions.".red
120
+ end
121
+ else
122
+ puts "Not upgrading. User declined.".red
123
+ end
124
+ else
125
+ puts "Dory is up to date! Nothing to do".green
126
+ end
127
+ else
128
+ puts "Encountered an error checking the latest version from Rubygems".red
129
+ end
130
+ end
131
+
80
132
  def config_file_action(options)
81
133
  if options[:upgrade]
82
134
  'u'
@@ -251,8 +303,9 @@ class DoryBin < Thor
251
303
  end
252
304
 
253
305
  aliases = {
254
- 'start' => 'up',
255
- 'stop' => 'down',
306
+ 'start' => 'up',
307
+ 'stop' => 'down',
308
+ 'update' => 'upgrade'
256
309
  }
257
310
 
258
311
  if !ARGV.empty? && %w[-v --version].include?(ARGV.first)
@@ -0,0 +1,23 @@
1
+ module Dory
2
+ module Upgrade
3
+ def self.new_version
4
+ res = Dory::Sh.run_command('gem search -q dory')
5
+ return false unless res.success?
6
+ newver = /dory\s+\((.*)\)/.match(res.stdout)
7
+ return false if !newver || newver.length != 2
8
+ newver[1]
9
+ end
10
+
11
+ def self.outdated?(new_version = self.new_version)
12
+ return Dory::VERSION != new_version
13
+ end
14
+
15
+ def self.install
16
+ Dory::Sh.run_command('gem install dory')
17
+ end
18
+
19
+ def self.cleanup
20
+ Dory::Sh.run_command('gem cleanup dory')
21
+ end
22
+ end
23
+ end
@@ -1,4 +1,4 @@
1
1
  module Dory
2
- VERSION = '0.2.2'
3
- DATE = '2016-06-23'
2
+ VERSION = '0.2.3'
3
+ DATE = '2016-06-24'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-23 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -140,11 +140,11 @@ files:
140
140
  - lib/dory/config.rb
141
141
  - lib/dory/dnsmasq.rb
142
142
  - lib/dory/docker_service.rb
143
- - lib/dory/inst_vars_to_hash.rb
144
143
  - lib/dory/linux.rb
145
144
  - lib/dory/proxy.rb
146
145
  - lib/dory/resolv.rb
147
146
  - lib/dory/shell.rb
147
+ - lib/dory/upgrade.rb
148
148
  - lib/dory/version.rb
149
149
  homepage: https://github.com/FreedomBen/dory
150
150
  licenses:
@@ -1,33 +0,0 @@
1
- module InstVarsToHash
2
- def to_s
3
- to_h.to_s
4
- end
5
-
6
- def to_h
7
- retval = {}
8
- instance_variables.each do |iv|
9
- retval[iv.to_s.delete('@').to_sym] = elem_to_h(instance_variable_get(iv))
10
- end
11
- retval
12
- end
13
-
14
- private
15
-
16
- def expandable_classes
17
- [ InstVarsToHash ]
18
- end
19
-
20
- def expandable_to_hash(klass)
21
- expandable_classes.any?{ |k| klass == k || klass < k }
22
- end
23
-
24
- def elem_to_h(elem)
25
- if elem.class == Array
26
- elem.map { |el| elem_to_h(el) }
27
- elsif expandable_to_hash(elem.class)
28
- elem.to_h
29
- else
30
- elem
31
- end
32
- end
33
- end