Class: RegenerateBinstubsCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/executable-hooks/regenerate_binstubs_command.rb

Instance Method Summary collapse

Constructor Details

#initializeRegenerateBinstubsCommand

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

#argumentsObject

: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_strObject

:nodoc:



19
20
21
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 19

def defaults_str # :nodoc:
  ""
end

#descriptionObject

: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

#executeObject



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_wrapperObject



40
41
42
43
44
45
46
47
48
49
50
51
# 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?
      try_to_fix_binstubs(spec) or
      try_to_install_binstubs(spec) or
      $stderr.puts "##{spec.name} #{spec.version} not found in GEM_PATH"
    end
  end
end

#usageObject

:nodoc:



15
16
17
# File 'lib/executable-hooks/regenerate_binstubs_command.rb', line 15

def usage # :nodoc:
  "#{program_name} [STRING]"
end