├── .gitignore ├── COPYING ├── README.md ├── Rakefile ├── lib └── rubygems_plugin.rb └── rbenv-rehash.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | pkg/ 2 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 by Ryan Souza 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | rbenv-rehash 2 | ======== 3 | 4 | Rubygems plugin, automatically runs `rbenv rehash` after un/installing gems. 5 | 6 | Install with `gem install rbenv-rehash` on each installed ruby version for optimal results 7 | 8 | * **Author**: [Ryan Souza](http://github.com/scoz) 9 | * **Copyright**: Copyright © 2011 Ryan Souza: See COPYING for details 10 | * **License**: MIT License 11 | * **Git Repo**: [github](http://github.com/scoz/rbenv-rehash) -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Borrowed from http://github.com/cldwalker/gem_grep 2 | 3 | require 'rake' 4 | require 'fileutils' 5 | 6 | def gemspec 7 | @gemspec ||= eval(File.read('rbenv-rehash.gemspec'), binding, 'rbenv-rehash.gemspec') 8 | end 9 | 10 | desc "Build the gem" 11 | task :gem=>:gemspec do 12 | sh "gem build rbenv-rehash.gemspec" 13 | FileUtils.mkdir_p 'pkg' 14 | FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg' 15 | end 16 | 17 | desc "Install the gem locally" 18 | task :install => :gem do 19 | sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}} 20 | end 21 | 22 | desc "Generate the gemspec" 23 | task :generate do 24 | puts gemspec.to_ruby 25 | end 26 | 27 | desc "Validate the gemspec" 28 | task :gemspec do 29 | gemspec.validate 30 | end 31 | 32 | task :default => :gemspec 33 | -------------------------------------------------------------------------------- /lib/rubygems_plugin.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | module RbenvRehash 4 | @do_rehash = false 5 | 6 | def self.queue_rehash 7 | @do_rehash = true 8 | end 9 | 10 | def self.rehash? 11 | if @do_rehash 12 | system("rbenv rehash") 13 | @do_rehash = false 14 | return true 15 | end 16 | 17 | return false 18 | end 19 | end 20 | 21 | Gem.post_install { |inst| 22 | RbenvRehash.queue_rehash unless inst.spec.executables.empty? 23 | } 24 | 25 | Gem.post_uninstall { |uninst| 26 | RbenvRehash.queue_rehash unless uninst.spec.executables.empty? 27 | } 28 | 29 | at_exit { RbenvRehash.rehash? } 30 | -------------------------------------------------------------------------------- /rbenv-rehash.gemspec: -------------------------------------------------------------------------------- 1 | require 'rubygems' unless Object.const_defined?(:Gem) 2 | 3 | Gem::Specification.new do |s| 4 | s.name = "rbenv-rehash" 5 | s.version = '0.3' 6 | s.authors = ["Ryan Souza"] 7 | s.license = 'MIT' 8 | s.email = "ryan@ryansouza.net" 9 | s.summary = "Rubygems plugin to automatically rehash rbenv" 10 | s.description = "Rubygems plugin to automatically run 'rbenv rehash' after (un)installing gems with executables. For optimal results, install within each installed ruby version." 11 | s.homepage = "http://github.com/ryansouza/rbenv-rehash" 12 | s.files = Dir.glob(%w[ {lib,test}/**/*.rb ]) + %w{rbenv-rehash.gemspec README.md COPYING} 13 | end 14 | --------------------------------------------------------------------------------