Skip to content
Browse files

new cmd 'install_diff' - installs any gem that target has that local …

…gem cache doesn't
  • Loading branch information...
1 parent b16e943 commit d6841c1fdb399a66a4c655f80a5b2fa0120d8397 @drnic drnic committed Jun 4, 2008
Showing with 19 additions and 4 deletions.
  1. +1 −0 README.rdoc
  2. +2 −0 bin/gemjour
  3. +16 −4 lib/gemjour.rb
View
1 README.rdoc
@@ -13,6 +13,7 @@ Server and install gems over Bonjour.
bob$ gemjour list # finds alice
bob$ gemjour list alice # shows alice's gems
bob$ gemjour diff alice # shows differences between bob and alice gems
+ bob$ gemjour install_diff alice # installs any gem bob doesn't have installed from alice
alice$ gem install blah.gem; gitjour serve
bob$ gemjour install alice blah
View
2 bin/gemjour
@@ -14,6 +14,8 @@ begin
Gemjour.list(*ARGV)
when "diff"
Gemjour.diff(*ARGV)
+ when "install_diff"
+ Gemjour.install_diff(*ARGV)
when "install"
Gemjour.install(*ARGV)
else
View
20 lib/gemjour.rb
@@ -85,7 +85,7 @@ def self.show(name)
system "gem list -r --source=http://#{host.host}:#{host.port}"
end
- def self.diff(name)
+ def self._diff(name)
host = find(name)
unless host
@@ -95,11 +95,23 @@ def self.diff(name)
require "tempfile"
local_gems, remote_gems = Tempfile.new("local_gems"), Tempfile.new("remote_gems")
- local_gems.print(`gem list --no-versions`)
+ local_gems.print(`gem list --no-versions --no-verbose`)
local_gems.close
- remote_gems.print(`gem list --no-versions -r --source=http://#{host.host}:#{host.port}`)
+ remote_gems.print(`gem list --no-versions --no-verbose -r --source=http://#{host.host}:#{host.port}`)
remote_gems.close
- system "diff -u #{local_gems.path} #{remote_gems.path}"
+ `diff -u #{local_gems.path} #{remote_gems.path}`
+ end
+
+ def self.diff(name)
+ puts _diff(name)
+ end
+
+ def self.install_diff(name)
+ gem_diff = _diff(name)
+ return unless gem_diff
+ gem_diff.scan(/^\+([\w_\-]+)/) do |match|
+ install(name, match)
+ end
end
def self.install(name, gem)

0 comments on commit d6841c1

Please sign in to comment.
Something went wrong with that request. Please try again.