Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Respect Gem.configuration.verbose, stop overwriting VERSION

  • Loading branch information...
commit b1d9a91ec9d0e3190331095e000e115f48f63fad 1 parent d279525
@indirect authored
Showing with 52 additions and 51 deletions.
  1. +46 −0 lib/brewbygems.rb
  2. +6 −51 lib/rubygems_plugin.rb
View
46 lib/brewbygems.rb
@@ -0,0 +1,46 @@
+module Brewbygems
+ class << self
+ attr_accessor :loaded_version
+
+ def link
+ puts "brewbygems: running command `brew link gems`" if Gem.configuration.verbose == 1
+ system("brew link gems #{silence}")
+ end
+
+ def prune
+ puts "brewbygems: running command `brew prune`" if Gem.configuration.verbose == 1
+ system("brew prune #{silence}")
+ end
+
+ private
+
+ def silence
+ Gem.configuration.verbose == 1 ? "" : "> /dev/null"
+ end
+
+ end
+end
+
+Gem::post_install do |installer|
+ cellar = File.join(`brew --prefix`.chomp, "Cellar")
+ # Augh RubyGems why is installer.gem_home a String here
+ installing_to_cellar = installer.gem_home.to_s.include?(cellar)
+ has_binary = installer.spec.executables.any?
+
+ if has_binary && installing_to_cellar
+ success = Brewbygems.link
+ puts "brewbygems: Sorry, you don't seem to have Homebrew installed." unless success
+ end
+end
+
+Gem::post_uninstall do |installer|
+ cellar = File.join(`brew --prefix`.chomp, "Cellar")
+ # Augh RubyGems why is installer.gem_home a String here
+ installing_to_cellar = installer.gem_home.to_s.include?(cellar)
+ has_binary = installer.spec.executables.any?
+
+ if has_binary && installing_to_cellar
+ success = Brewbygems.prune
+ puts "brewbygems: Sorry, you don't seem to have Homebrew installed." unless success
+ end
+end
View
57 lib/rubygems_plugin.rb
@@ -1,52 +1,7 @@
-loaded_already = defined?(Brewbygems::VERSION)
-loaded_is_older = loaded_already && Gem::Version.new(Brewbygems::VERSION) < Gem::Version.new("0.3.0")
+this_version = "0.4.0"
+loaded_version = defined?(Brewbygems) && Gem::Version.new(Brewbygems.loaded_version)
-if !loaded_already || loaded_is_older
- module Brewbygems
- VERSION = "0.3.0"
-
- class << self
-
- def prune
- puts "brewbygems: running command `brew prune #{silence}`" if $VERBOSE
- system("brew prune #{silence}")
- end
-
- def link
- puts "brewbygems: running command `brew link gems #{silence}`" if $VERBOSE
- system("brew link gems #{silence}")
- end
-
- private
-
- def silence
- $VERBOSE ? "" : "> /dev/null"
- end
-
- end
- end
-
- Gem::post_install do |installer|
- cellar = File.join(`brew --prefix`.chomp, "Cellar")
- # Augh RubyGems why is installer.gem_home a String here
- installing_to_cellar = installer.gem_home.to_s.include?(cellar)
- has_binary = installer.spec.executables.any?
-
- if has_binary && installing_to_cellar
- success = Brewbygems.link
- puts "brewbygems: Sorry, you don't seem to have Homebrew installed." unless success
- end
- end
-
- Gem::post_uninstall do |installer|
- cellar = File.join(`brew --prefix`.chomp, "Cellar")
- # Augh RubyGems why is installer.gem_home a String here
- installing_to_cellar = installer.gem_home.to_s.include?(cellar)
- has_binary = installer.spec.executables.any?
-
- if has_binary && installing_to_cellar
- success = Brewbygems.prune
- puts "brewbygems: Sorry, you don't seem to have Homebrew installed." unless success
- end
- end
-end
+unless loaded_version && loaded_version > Gem::Version.new(this_version)
+ require File.expand_path('../brewbygems', __FILE__)
+ Brewbygems.loaded_version = this_version
+end
Please sign in to comment.
Something went wrong with that request. Please try again.