Class: RegenerateBinstubsCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- RegenerateBinstubsCommand
- Defined in:
- lib/executable-hooks/regenerate_binstubs_command.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
- #execute_no_wrapper ⇒ Object
-
#initialize ⇒ RegenerateBinstubsCommand
constructor
A new instance of RegenerateBinstubsCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ RegenerateBinstubsCommand
Returns a new instance of RegenerateBinstubsCommand.
7 8 9 |
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 7 def initialize super 'regenerate_binstubs', 'Re run generation of executable wrappers for gems.' end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
11 12 13 |
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 11 def arguments # :nodoc: "STRING start of gem name to regenerate binstubs" end |
#defaults_str ⇒ Object
:nodoc:
19 20 21 |
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 19 def defaults_str # :nodoc: "" end |
#description ⇒ Object
:nodoc:
23 24 25 26 27 28 29 |
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 23 def description # :nodoc: 'Re run generation of executable wrappers for all gems. '+ 'Wrappers will be compatible with both rubygems and bundler. '+ 'The switcher is BUNDLE_GEMFILE environment variable, '+ 'when set it switches to bundler mode, when not set, '+ 'then the command will work as it was with pure rubygems.' end |
#execute ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 31 def execute if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('2.0.0') then # https://github.com/rubygems/rubygems/issues/326 puts "try also: gem pristine --binstubs" end ExecutableHooks::Wrapper.install execute_no_wrapper end |
#execute_no_wrapper ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 40 def execute_no_wrapper require 'executable-hooks/installer' name = get_one_optional_argument || '' specs = installed_gems.select{|spec| spec.name =~ /^#{name}/i } specs.each do |spec| unless spec.executables.empty? org_gem_path = Gem.path.find{|path| File.exists? File.join path, 'gems', spec.full_name } || Gem.dir cache_gem = File.join(org_gem_path, 'cache', spec.file_name) if File.exist? cache_gem puts "#{spec.name} #{spec.version}" inst = Gem::Installer.new Dir[cache_gem].first, :wrappers => true, :force => true, :install_dir => org_gem_path ExecutableHooksInstaller.bundler_generate_bin(inst) else $stderr.puts "##{spec.name} #{spec.version} not found in GEM_PATH" end end end end |
#usage ⇒ Object
:nodoc:
15 16 17 |
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 15 def usage # :nodoc: "#{program_name} [STRING]" end |