update 0.8.7 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ update.sub*
data/bin/update CHANGED
@@ -2,7 +2,8 @@
2
2
  require "update"
3
3
  require "slop"
4
4
  require "ap"
5
+ require 'em-synchrony'
6
+ require 'em-synchrony/fiber_iterator'
5
7
 
6
8
  Update.parse_options
7
-
8
9
  Update.run
@@ -1,40 +1,5 @@
1
1
  require "update/commands"
2
2
  require "update/red-green"
3
+ require "update/run-updates"
3
4
  require "update/options"
4
- require "update/version"
5
-
6
- module Update
7
- extend RedGreen
8
-
9
- class << self
10
- def run
11
- Update::COMMANDS.each do |command, description|
12
- @command = command
13
- green description
14
- puts `#@command`
15
- take_note_if_command_fails
16
- end
17
- report_final_status
18
- end
19
-
20
- private
21
-
22
- def take_note_if_command_fails
23
- unless $?.success?
24
- @failed ||= []
25
- @failed << @command
26
- red "Command failed: '#@command'"
27
- end
28
- end
29
-
30
- def report_final_status
31
- if @failed
32
- red "Update process completed with failures.\a" #chirp
33
- @failed.each { |this_failed| puts "Command failed: '#{this_failed}'" }
34
- exit 1
35
- else
36
- green "Update process completed successfully."
37
- end
38
- end
39
- end
40
- end
5
+ require "update/version"
@@ -1,11 +1,13 @@
1
1
  module Update
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
- "rvm get head --auto" => "Get the latest RVM...",
7
- "gem update --system" => "Get the latest RubyGems...",
8
- "gem update" => "Update gems...",
9
- "gem cleanup --dryrun" => "Show gem cleanup dry-run..."
10
- }
2
+ COMMAND_GROUPS = [
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
+ {"rvm get head --auto" => "Get the latest RVM..."},
8
+
9
+ {"gem update --system" => "Get the latest RubyGems...",
10
+ "gem update" => "Update gems...",
11
+ "gem cleanup --dryrun" => "Show gem cleanup dry-run..."}
12
+ ]
11
13
  end
@@ -9,7 +9,7 @@ module Update
9
9
  end
10
10
 
11
11
  on :l, :list, "Print list of commands" do
12
- ap Update::COMMANDS
12
+ ap Update::COMMAND_GROUPS
13
13
  exit
14
14
  end
15
15
 
@@ -1,15 +1,15 @@
1
1
  module RedGreen
2
- private
3
-
4
- def red text
5
- system "tput setaf 1" #red text
6
- STDERR.puts text
7
- system "tput sgr0" #default text
8
- end
9
-
10
- def green text
11
- system "tput setaf 2" #green text
12
- puts text
13
- system "tput sgr0" #default text
14
- end
2
+ private
3
+
4
+ def red text
5
+ system "tput setaf 1" #red text
6
+ STDERR.puts text
7
+ system "tput sgr0" #default text
8
+ end
9
+
10
+ def green text
11
+ system "tput setaf 2" #green text
12
+ puts text
13
+ system "tput sgr0" #default text
14
+ end
15
15
  end
@@ -0,0 +1,50 @@
1
+ module Update
2
+ extend RedGreen
3
+
4
+ class << self
5
+ def run
6
+ Update::COMMAND_GROUPS.each do |commands|
7
+ @commands = commands
8
+
9
+ EM.synchrony do
10
+ EM::Synchrony::FiberIterator.new(@commands).each do |command, description|
11
+ @command = command
12
+
13
+ @results ||= {}
14
+ @results["#{description}"] = `#@command`
15
+
16
+ take_note_if_command_fails #TODO: make this work with EM
17
+ end
18
+
19
+ @results.each do |description, result|
20
+ green description
21
+ puts result
22
+ end
23
+
24
+ EventMachine.stop
25
+ end
26
+ end
27
+
28
+ report_final_status
29
+ end
30
+
31
+ private
32
+
33
+ def take_note_if_command_fails
34
+ unless $?.success?
35
+ @failed ||= []
36
+ @failed << @command
37
+ end
38
+ end
39
+
40
+ def report_final_status
41
+ if @failed
42
+ red "Update process completed with failures.\a" #chirp
43
+ @failed.each { |this_failed| puts "Command failed: '#{this_failed}'" }
44
+ exit 1
45
+ else
46
+ green "Update process completed successfully."
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Update
2
- VERSION = "0.8.7"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_development_dependency "slop", "~> 2.4"
22
22
  s.add_development_dependency "awesome_print", "~> 1.0"
23
+ s.add_development_dependency "em-synchrony", "~> 1.0"
23
24
  s.add_runtime_dependency "slop", "~> 2.4"
24
25
  s.add_runtime_dependency "awesome_print", "~> 1.0"
26
+ s.add_runtime_dependency "em-synchrony", "~> 1.0"
25
27
  end
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.8.7
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-24 00:00:00.000000000 Z
12
+ date: 2012-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop
16
- requirement: &70170132196300 !ruby/object:Gem::Requirement
16
+ requirement: &70199739049840 !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: *70170132196300
24
+ version_requirements: *70199739049840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: awesome_print
27
- requirement: &70170132195220 !ruby/object:Gem::Requirement
27
+ requirement: &70199739048600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: '1.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70170132195220
35
+ version_requirements: *70199739048600
36
+ - !ruby/object:Gem::Dependency
37
+ name: em-synchrony
38
+ requirement: &70199739047060 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70199739047060
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: slop
38
- requirement: &70170132194520 !ruby/object:Gem::Requirement
49
+ requirement: &70199739046100 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
@@ -43,10 +54,21 @@ dependencies:
43
54
  version: '2.4'
44
55
  type: :runtime
45
56
  prerelease: false
46
- version_requirements: *70170132194520
57
+ version_requirements: *70199739046100
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: awesome_print
49
- requirement: &70170132193620 !ruby/object:Gem::Requirement
60
+ requirement: &70199739045020 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '1.0'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: *70199739045020
69
+ - !ruby/object:Gem::Dependency
70
+ name: em-synchrony
71
+ requirement: &70199739043820 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ~>
@@ -54,7 +76,7 @@ dependencies:
54
76
  version: '1.0'
55
77
  type: :runtime
56
78
  prerelease: false
57
- version_requirements: *70170132193620
79
+ version_requirements: *70199739043820
58
80
  description: A Ruby Gem for running a list of update commands from command line.
59
81
  email:
60
82
  - shannonskipper@gmail.com
@@ -71,6 +93,7 @@ files:
71
93
  - lib/update/commands.rb
72
94
  - lib/update/options.rb
73
95
  - lib/update/red-green.rb
96
+ - lib/update/run-updates.rb
74
97
  - lib/update/version.rb
75
98
  - update.gemspec
76
99
  homepage: https://github.com/havenwood/update