Class: LibGems::Commands::InstallCommand
- Inherits:
-
LibGems::Command
- Object
- LibGems::Command
- LibGems::Commands::InstallCommand
- Includes:
- InstallUpdateOptions, LocalRemoteOptions, VersionOption
- Defined in:
- lib/libgems/commands/install_command.rb
Overview
LibGems installer command line tool
See ‘gem help install`
Instance Attribute Summary
Attributes inherited from LibGems::Command
#command, #defaults, #options, #program_name, #summary
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#defaults_str ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ InstallCommand
constructor
A new instance of InstallCommand.
-
#usage ⇒ Object
:nodoc:.
Methods included from InstallUpdateOptions
#add_install_update_options, #install_update_defaults_str
Methods included from LocalRemoteOptions
#accept_uri_http, #add_bulk_threshold_option, #add_local_remote_options, #add_proxy_option, #add_source_option, #add_update_sources_option, #both?, #local?, #remote?
Methods included from VersionOption
#add_platform_option, #add_prerelease_option, #add_version_option
Methods inherited from LibGems::Command
add_common_option, #add_extra_args, #add_option, add_specific_extra_args, #begins?, build_args, build_args=, common_options, extra_args, extra_args=, #get_all_gem_names, #get_one_gem_name, #get_one_optional_argument, #handle_options, #handles?, #invoke, #merge_options, #remove_option, #show_help, #show_lookup_failure, specific_extra_args, specific_extra_args_hash, #when_invoked
Methods included from UserInteraction
Methods included from DefaultUserInteraction
ui, #ui, ui=, #ui=, use_ui, #use_ui
Constructor Details
#initialize ⇒ InstallCommand
Returns a new instance of InstallCommand.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/libgems/commands/install_command.rb', line 20 def initialize defaults = LibGems::DependencyInstaller::DEFAULT_OPTIONS.merge({ :generate_rdoc => true, :generate_ri => true, :format_executable => false, :test => false, :version => LibGems::Requirement.default, }) super 'install', 'Install a gem into the local repository', defaults add_platform_option add_version_option add_prerelease_option "to be installed. (Only for listed gems)" end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/libgems/commands/install_command.rb', line 38 def arguments # :nodoc: "GEMNAME name of gem to install" end |
#defaults_str ⇒ Object
:nodoc:
42 43 44 45 |
# File 'lib/libgems/commands/install_command.rb', line 42 def defaults_str # :nodoc: "--both --version '#{LibGems::Requirement.default}' --rdoc --ri --no-force\n" \ "--no-test --install-dir #{LibGems.dir}" end |
#description ⇒ Object
:nodoc:
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/libgems/commands/install_command.rb', line 47 def description # :nodoc: <<-EOF The install command installs local or remote gem into a gem repository. For gems with executables ruby installs a wrapper file into the executable directory by default. This can be overridden with the --no-wrappers option. The wrapper allows you to choose among alternate gem versions using _version_. For example `rake _0.7.3_ --version` will run rake version 0.7.3 if a newer version is also installed. If an extension fails to compile during gem installation the gem specification is not written out, but the gem remains unpacked in the repository. You may need to specify the path to the library's headers and libraries to continue. You can do this by adding a -- between #{LibGems::NAME}' options and the extension's build options: $ gem install some_extension_gem [build fails] LibGems files will remain installed in \\ /path/to/gems/some_extension_gem-1.0 for inspection. Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out $ gem install some_extension_gem -- --with-extension-lib=/path/to/lib [build succeeds] $ gem list some_extension_gem *** LOCAL GEMS *** some_extension_gem (1.0) $ If you correct the compilation errors by editing the gem files you will need to write the specification by hand. For example: $ gem install some_extension_gem [build fails] LibGems files will remain installed in \\ /path/to/gems/some_extension_gem-1.0 for inspection. Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out $ [cd /path/to/gems/some_extension_gem-1.0] $ [edit files or what-have-you and run make] $ gem spec ../../cache/some_extension_gem-1.0.gem --ruby > \\ ../../specifications/some_extension_gem-1.0.gemspec $ gem list some_extension_gem *** LOCAL GEMS *** some_extension_gem (1.0) $ EOF end |
#execute ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/libgems/commands/install_command.rb', line 104 def execute if [:include_dependencies] then alert "`gem install -y` is now default and will be removed" alert "use --ignore-dependencies to install only the gems you list" end installed_gems = [] ENV.delete 'GEM_PATH' if [:install_dir].nil? and RUBY_VERSION > '1.9' exit_code = 0 get_all_gem_names.each do |gem_name| begin next if [:conservative] && LibGems.available?(gem_name, [:version]) inst = LibGems::DependencyInstaller.new inst.install gem_name, [:version] inst.installed_gems.each do |spec| say "Successfully installed #{spec.full_name}" end installed_gems.push(*inst.installed_gems) rescue LibGems::InstallError => e alert_error "Error installing #{gem_name}:\n\t#{e.}" exit_code |= 1 rescue LibGems::GemNotFoundException => e show_lookup_failure e.name, e.version, e.errors, [:domain] exit_code |= 2 end end unless installed_gems.empty? then gems = installed_gems.length == 1 ? 'gem' : 'gems' say "#{installed_gems.length} #{gems} installed" # NOTE: *All* of the RI documents must be generated first. For some # reason, RI docs cannot be generated after any RDoc documents are # generated. if [:generate_ri] then installed_gems.each do |gem| LibGems::DocManager.new(gem, [:rdoc_args]).generate_ri end LibGems::DocManager.update_ri_cache end if [:generate_rdoc] then installed_gems.each do |gem| LibGems::DocManager.new(gem, [:rdoc_args]).generate_rdoc end end if [:test] then installed_gems.each do |spec| gem_spec = LibGems::SourceIndex.from_installed_gems.find_name(spec.name, spec.version.version).first result = LibGems::Validator.new.unit_test(gem_spec) if result and not result.passed? unless ask_yes_no("...keep LibGems?", true) require 'libgems/uninstaller' LibGems::Uninstaller.new(spec.name, :version => spec.version.version).uninstall end end end end end raise LibGems::SystemExitException, exit_code end |
#usage ⇒ Object
:nodoc:
100 101 102 |
# File 'lib/libgems/commands/install_command.rb', line 100 def usage # :nodoc: "#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags" end |