update 0.3.3 → 0.4.0

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.
@@ -1,12 +1,20 @@
1
1
  module Update
2
- COMMANDS = [{ "brew update" => "Checking for updated Brew packages...",
3
- "brew upgrade" => "Installing updated Brew packages...",
4
- "brew cleanup --force" => "Cleaning up outdated packages..."},
5
- { "rvm get head --auto" => "Get the latest RVM...",
6
- "rvm 1.9.3-head do gem update --system" => "Update 1.9.3's RubyGems version...",
7
- "rvm 1.9.3-head do gem update" => "Update 1.9.3 gems...",
8
- "rvm 1.9.3-head do gem cleanup -d" => "Show 1.9.3 gem cleanup dry-run...",
9
- "rvm rbx-head do gem update --system" => "Update Rubinius' RubyGems version...",
10
- "rvm rbx-head do gem update" => "Update Rubinius gems...",
11
- "rvm rbx-head do gem cleanup -d" => "Show Rubinius gem cleanup dry-run..."}]
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
@@ -1,3 +1,3 @@
1
1
  module Update
2
- VERSION = "0.3.3"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/update.rb CHANGED
@@ -1,39 +1,39 @@
1
1
  require "update/commands"
2
- require "update/red-green"
2
+ require "update/rainbow"
3
3
  require "update/version"
4
4
 
5
5
  module Update
6
- extend RedGreen
6
+ extend Rainbow
7
7
 
8
8
  class << self
9
9
  def run
10
- run_commands
11
- report_status
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 run_commands
17
- Update::COMMANDS.each do |command_group|
18
- command_group.each do |run_together|
19
- @run_together = run_together
20
- Thread.new do
21
- @run_together.each do |command, description|
22
- @command = command
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 check_for_failures
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.3.3
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: &70292203133080 !ruby/object:Gem::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: *70292203133080
24
+ version_requirements: *70162938403820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: slop
27
- requirement: &70292203132400 !ruby/object:Gem::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: *70292203132400
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/red-green.rb
50
+ - lib/update/rainbow.rb
51
51
  - lib/update/version.rb
52
52
  - update.gemspec
53
53
  homepage: https://github.com/havenwood/update
@@ -1,16 +0,0 @@
1
- module RedGreen
2
- RED, GREEN = "tput setaf 1", "tput setaf 2"
3
- RESET = "tput sgr0"
4
-
5
- def green message
6
- system GREEN
7
- puts message
8
- system RESET
9
- end
10
-
11
- def red message
12
- system RED
13
- puts message
14
- system RESET
15
- end
16
- end