update 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,21 @@
1
1
  module Rainbow
2
- RESET = "tput sgr0"
3
-
4
- def rainbow_puts color, message
5
- system color
6
- puts message
7
- system RESET
2
+ def default text
3
+ rainbow "tput sgr0", text
8
4
  end
9
5
 
10
- def green message
11
- rainbow_puts "tput setaf 2", message
6
+ def green text
7
+ rainbow "tput setaf 2", text
8
+ end
9
+
10
+ def red text
11
+ rainbow "tput setaf 1", text
12
12
  end
13
13
 
14
- def red message
15
- rainbow_puts "tput setaf 1", message
14
+ private
15
+
16
+ def rainbow color, text
17
+ system color
18
+ puts text
19
+ system "tput sgr0" #set text color back to default
16
20
  end
17
21
  end
@@ -1,3 +1,3 @@
1
1
  module Update
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
data/lib/update.rb CHANGED
@@ -8,29 +8,35 @@ module Update
8
8
  class << self
9
9
  def run
10
10
  Update::COMMANDS.each do |together|
11
- together.each do |run_together|
12
- @commands = run_together
13
- @fiber = Fiber.new { run_commands }.resume
11
+ together.each do |commands|
12
+ @commands = commands
13
+ run_together
14
14
  end
15
15
  end
16
16
  end
17
17
 
18
18
  private
19
19
 
20
+ def run_together
21
+ Thread.new do
22
+ run_commands
23
+ end.run.join { report_final_status }
24
+ end
25
+
20
26
  def run_commands
21
27
  @commands.each do |command, description|
22
28
  @command, @description = command, description
23
- green description
24
- puts run_command
25
- check_exit_status
29
+ run_command
30
+ take_note_of_failures
26
31
  end
27
32
  end
28
33
 
29
34
  def run_command
30
- `#{@command}`
35
+ green @description
36
+ puts `#{@command}`
31
37
  end
32
38
 
33
- def check_exit_status
39
+ def take_note_of_failures
34
40
  unless $?.success?
35
41
  @failed ||= []
36
42
  @failed << @command
@@ -39,7 +45,7 @@ module Update
39
45
  end
40
46
  end
41
47
 
42
- def report_status
48
+ def report_final_status
43
49
  if @failed
44
50
  red "Update process completed with failures.\a" #chirp
45
51
  @failed.each { |this_failed| puts "Command failed: '#{this_failed}'" }
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.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop
16
- requirement: &70123939626800 !ruby/object:Gem::Requirement
16
+ requirement: &70120676494360 !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: *70123939626800
24
+ version_requirements: *70120676494360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: slop
27
- requirement: &70123939626060 !ruby/object:Gem::Requirement
27
+ requirement: &70120676493860 !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: *70123939626060
35
+ version_requirements: *70120676493860
36
36
  description: A Ruby Gem for running a list of update commands from command line.
37
37
  email:
38
38
  - shannonskipper@gmail.com