Skip to content
Browse files

added 'diff' cmd to show simple diff of which gems are installed; no …

…version number comparison yet
  • Loading branch information...
1 parent cc4f640 commit da87793a572586b172adfb91c4ea269c12c4d1d5 @drnic drnic committed Jun 4, 2008
Showing with 20 additions and 0 deletions.
  1. +1 −0 README.rdoc
  2. +2 −0 bin/gemjour
  3. +17 −0 lib/gemjour.rb
View
1 README.rdoc
@@ -12,6 +12,7 @@ Server and install gems over Bonjour.
alice$ gemjour serve # publishes gems via 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
alice$ gem install blah.gem; gitjour serve
bob$ gemjour install alice blah
View
2 bin/gemjour
@@ -12,6 +12,8 @@ begin
Gemjour.serve(*ARGV)
when "list"
Gemjour.list(*ARGV)
+ when "diff"
+ Gemjour.diff(*ARGV)
when "install"
Gemjour.install(*ARGV)
else
View
17 lib/gemjour.rb
@@ -84,6 +84,23 @@ def self.show(name)
system "gem list -r --source=http://#{host.host}:#{host.port}"
end
+
+ def self.diff(name)
+ host = find(name)
+
+ unless host
+ puts "ERROR: Unable to find server named '#{name}'"
+ return
+ end
+
+ require "tempfile"
+ local_gems, remote_gems = Tempfile.new("local_gems"), Tempfile.new("remote_gems")
+ local_gems.print(`gem list --no-versions`)
+ local_gems.close
+ remote_gems.print(`gem list --no-versions -r --source=http://#{host.host}:#{host.port}`)
+ remote_gems.close
+ system "diff -u #{remote_gems.path} #{local_gems.path}"
+ end
def self.install(name, gem)
host = find(name)

0 comments on commit da87793

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