Class: Gem::Commands::ExefyCommand

Inherits:
Gem::Command
  • Object
show all
Defined in:
lib/rubygems/commands/exefy_command.rb

Instance Method Summary collapse

Constructor Details

#initializeExefyCommand



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rubygems/commands/exefy_command.rb', line 6

def initialize
  super 'exefy', "Replaces a Gem's batch script with a Windows executable"

  add_option('--all', 'Replaces batch files with executable file',
         'for all installed gems') do |value, options|
    options[:process_all_gems] = value
  end

  add_option('--revert', 'Restores batch files for given gem',
         'or all gems if --all option is used') do |value, options|
    options[:revert] = value
  end
end

Instance Method Details

#argumentsObject



20
21
22
# File 'lib/rubygems/commands/exefy_command.rb', line 20

def arguments
  "GEMNAME       name of gem to exefy (unless --all)"
end

#descriptionObject

:nodoc:



28
29
30
31
32
33
34
35
36
37
# File 'lib/rubygems/commands/exefy_command.rb', line 28

def description # :nodoc:

  "The exefy command replaces the default gem batch(.bat) script runner with\na Windows executable(.exe) stub. Exefy also includes hooks that will\nautomatically do this for all new Gem installs and will remove the\nexecutable with a Gem uninstall.\n\nRequires a RubyInstaller Ruby installation and the RubyInstaller DevKit.\n  EOS\nend\n"

#executeObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rubygems/commands/exefy_command.rb', line 39

def execute
  unless RUBY_PLATFORM =~ /mingw/
    say "This command can be executed only on RubyInstaller Windows OS installation"
    return
  end

  begin
    require "exefy"
    require "devkit" if !options[:revert] && Exefy.devkit_needed?
  rescue ::LoadError => load_error
    say "You must have DevKit installed in order to exefy gems"
    return
  end

  gem_specs = if options[:process_all_gems] then
                Gem::Specification
              else
                begin
                  gem_name = get_one_gem_name
                  Gem::Specification.find_all_by_name(gem_name)
                rescue Gem::LoadError => e
                  say "Cannot exefy. Gem #{name} not found"
                end
              end

  gem_specs.each do |gem_spec|
    Exefy.process_existing_gem(gem_spec, options[:revert])
  end
end

#usageObject

:nodoc:



24
25
26
# File 'lib/rubygems/commands/exefy_command.rb', line 24

def usage # :nodoc:

  "#{program_name} [GEMNAME]"
end