update 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/update/commands.rb +18 -10
- data/lib/update/rainbow.rb +17 -0
- data/lib/update/version.rb +1 -1
- data/lib/update.rb +28 -22
- metadata +6 -6
- data/lib/update/red-green.rb +0 -16
data/lib/update/commands.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
module Update
|
2
|
-
COMMANDS = [{
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
COMMANDS = [{
|
3
|
+
"brew update" => "Checking for updated Brew packages...",
|
4
|
+
"brew upgrade" => "Installing updated Brew packages...",
|
5
|
+
"brew cleanup --force" => "Cleaning up outdated packages..." },{
|
6
|
+
|
7
|
+
##
|
8
|
+
# Create additional command-groups by uncommenting the following-ish:
|
9
|
+
|
10
|
+
# "ls -la" => "Look around...",
|
11
|
+
# "uname -a" => "Whatchamacallit..." },{
|
12
|
+
|
13
|
+
"rvm get head --auto" => "Get the latest RVM...",
|
14
|
+
"rvm 1.9.3-head do gem update --system" => "Update 1.9.3's RubyGems version...",
|
15
|
+
"rvm 1.9.3-head do gem update" => "Update 1.9.3 gems...",
|
16
|
+
"rvm 1.9.3-head do gem cleanup -d" => "Show 1.9.3 gem cleanup dry-run...",
|
17
|
+
"rvm rbx-head do gem update --system" => "Update Rubinius' RubyGems version...",
|
18
|
+
"rvm rbx-head do gem update" => "Update Rubinius gems...",
|
19
|
+
"rvm rbx-head do gem cleanup -d" => "Show Rubinius gem cleanup dry-run..." }]
|
12
20
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rainbow
|
2
|
+
RESET = "tput sgr0"
|
3
|
+
|
4
|
+
def rainbow_puts color, message
|
5
|
+
system color
|
6
|
+
puts message
|
7
|
+
system RESET
|
8
|
+
end
|
9
|
+
|
10
|
+
def green message
|
11
|
+
rainbow_puts "tput setaf 2", message
|
12
|
+
end
|
13
|
+
|
14
|
+
def red message
|
15
|
+
rainbow_puts "tput setaf 1", message
|
16
|
+
end
|
17
|
+
end
|
data/lib/update/version.rb
CHANGED
data/lib/update.rb
CHANGED
@@ -1,39 +1,39 @@
|
|
1
1
|
require "update/commands"
|
2
|
-
require "update/
|
2
|
+
require "update/rainbow"
|
3
3
|
require "update/version"
|
4
4
|
|
5
5
|
module Update
|
6
|
-
extend
|
6
|
+
extend Rainbow
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def run
|
10
|
-
|
11
|
-
|
10
|
+
Update::COMMANDS.each do |together|
|
11
|
+
together.each do |run_together|
|
12
|
+
@commands = run_together
|
13
|
+
run_in_new_thread
|
14
|
+
end.join { report_status }
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
private
|
15
19
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
`#{command}`; command_output = _
|
25
|
-
check_for_failures
|
26
|
-
|
27
|
-
green description
|
28
|
-
puts command_output
|
29
|
-
red @failure_report if @failure_report
|
30
|
-
end
|
31
|
-
end
|
20
|
+
def run_in_new_thread
|
21
|
+
Thread.new do
|
22
|
+
@commands.each do |command, description|
|
23
|
+
@command, @description = command, description
|
24
|
+
run_command
|
25
|
+
check_exit_status
|
26
|
+
printout
|
32
27
|
end
|
33
|
-
end
|
28
|
+
end.run
|
29
|
+
end
|
30
|
+
|
31
|
+
def run_command
|
32
|
+
`#{command}`
|
33
|
+
@command_output = _
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def check_exit_status
|
37
37
|
unless $?.success?
|
38
38
|
@failed ||= []
|
39
39
|
@failed << @command
|
@@ -41,6 +41,12 @@ module Update
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def printout
|
45
|
+
green @description
|
46
|
+
puts @command_output
|
47
|
+
red @failure_report if @failure_report
|
48
|
+
end
|
49
|
+
|
44
50
|
def report_status
|
45
51
|
if @failed
|
46
52
|
red "Update process completed with failures.\a" #chirp
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: update
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: slop
|
16
|
-
requirement: &
|
16
|
+
requirement: &70162938403820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.4'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70162938403820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: slop
|
27
|
-
requirement: &
|
27
|
+
requirement: &70162938403280 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.4'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70162938403280
|
36
36
|
description: A Ruby Gem for running a list of update commands from command line.
|
37
37
|
email:
|
38
38
|
- shannonskipper@gmail.com
|
@@ -47,7 +47,7 @@ files:
|
|
47
47
|
- bin/update
|
48
48
|
- lib/update.rb
|
49
49
|
- lib/update/commands.rb
|
50
|
-
- lib/update/
|
50
|
+
- lib/update/rainbow.rb
|
51
51
|
- lib/update/version.rb
|
52
52
|
- update.gemspec
|
53
53
|
homepage: https://github.com/havenwood/update
|
data/lib/update/red-green.rb
DELETED