Module: Rip::Commands
- Included in:
- Commands
- Defined in:
- lib/rip/commands.rb,
lib/rip/commands/core.rb,
lib/rip/commands/ruby.rb,
lib/rip/commands/show.rb,
lib/rip/commands/build.rb,
lib/rip/commands/setup.rb,
lib/rip/commands/install.rb,
lib/rip/commands/uninstall.rb
Instance Method Summary collapse
- #build(options = {}, *packages) ⇒ Object
- #check(*args) ⇒ Object
- #env(options = {}, command = nil, *args) ⇒ Object
- #freeze(options = {}, env = nil, *args) ⇒ Object
- #help(options = {}, command = nil, *args) ⇒ Object
- #install(options = {}, source = nil, version = nil, *args) ⇒ Object
- #invoke(args) ⇒ Object
- #list(*args) ⇒ Object
- #load_plugin(file) ⇒ Object
- #public_instance_methods ⇒ Object
- #ruby(options = {}, *args) ⇒ Object
- #setup(options = {}, script = nil) ⇒ Object
- #show(options = {}, name = nil, *args) ⇒ Object
- #uninstall(options = {}, name = nil, *args) ⇒ Object
- #use(options = {}, ripenv = nil, *args) ⇒ Object
- #version(options = {}, *args) ⇒ Object
Methods included from Help
Instance Method Details
#build(options = {}, *packages) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rip/commands/build.rb', line 10 def build(={}, *packages) packages.each do |package_name| package = manager.package(package_name) alerted = false Dir["#{package.cache_path}/**/extconf.rb"].each do |build_file| if !alerted ui.puts "rip: building #{package_name}" alerted = true end build_dir = File.dirname(build_file) Dir.chdir(build_dir) do system "ruby extconf.rb" system "make clean" system "make install sitearchdir=#{manager.dir}/lib" end end if !alerted && ![:quiet] ui.puts "rip: don't know how to build #{package_name}" end end end |
#check(*args) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/rip/commands/install.rb', line 4 def check(*args) Setup.check_installation ui.puts "All systems go." rescue Setup::StaleEnvironmentError, Setup::InstallationError => e ui.puts e. rescue => e ui.puts "Installation failed: #{e.}" end |
#env(options = {}, command = nil, *args) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/rip/commands/core.rb', line 29 def env( = {}, command = nil, *args) if command && Rip::Env.commands.include?(command) args.push() ui.puts 'ripenv: ' + Rip::Env.call(command, *args).to_s else Rip::Env.show_help :env ui.puts '', "current ripenv: #{Rip::Env.active}" end end |
#freeze(options = {}, env = nil, *args) ⇒ Object
48 49 50 51 52 |
# File 'lib/rip/commands/core.rb', line 48 def freeze( = {}, env = nil, *args) manager(env).packages.each do |package| ui.puts "#{package.source} #{package.version}" end end |
#help(options = {}, command = nil, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rip/commands/core.rb', line 13 def help( = {}, command = nil, *args) command = command.to_s if !command.empty? && respond_to?(command) ui.puts "Usage: %s" % (@usage[command] || "rip #{command.downcase}") if @help[command] ui.puts ui.puts(*@help[command]) end else show_general_help end end |
#install(options = {}, source = nil, version = nil, *args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rip/commands/install.rb', line 16 def install( = {}, source = nil, version = nil, *args) if source.to_s.empty? ui.abort "Please tell me what to install." end package = Rip::Package.for(source, version) if !package ui.abort "I don't know how to install #{source}" end installed_package = manager.package(package.name) if [:f] && installed_package Installer.new.uninstall(installed_package) if installed_package.installed? Installer.new.install(package) elsif package.installed? ui.puts "#{package} already installed" else installer = Installer.new installer.install(package) end end |
#invoke(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rip/commands.rb', line 6 def invoke(args) command, , args = parse_args(args) if command.nil? && ([:v] || [:version]) command = :version end if command.nil? || command == '' || [:h] || [:help] command = :help end command = find_command(command) begin send(command, , *args) rescue => e if [:error] raise e else ui.puts "rip: #{command} failed" ui.puts "-> #{e.}" end end end |
#list(*args) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/rip/commands/core.rb', line 4 def list(*args) ui.puts 'ripenv: ' + Rip::Env.active, '' if manager.packages.any? ui.puts manager.packages else ui.puts "nothing installed" end end |
#load_plugin(file) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/rip/commands.rb', line 31 def load_plugin(file) begin require file rescue Exception => e ui.puts "rip: plugin not loaded (#{file})" ui.puts "-> #{e.}", '' end end |
#public_instance_methods ⇒ Object
40 41 42 |
# File 'lib/rip/commands.rb', line 40 def public_instance_methods super - %w( invoke load_plugin public_instance_methods ) end |
#ruby(options = {}, *args) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/rip/commands/ruby.rb', line 5 def ruby(={}, *args) selected_env = File.join(Rip.dir, ARGV.shift, "lib") path = (ENV["RUBYLIB"] || "").split(":") active_env = File.join(Rip.dir, "active", "lib") path -= [active_env] path += [selected_env] ENV["RUBYLIB"] = path.join(":") exec(ENV['RUBYBIN'] || "ruby", *ARGV) end |
#setup(options = {}, script = nil) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rip/commands/setup.rb', line 11 def setup( = {}, script = nil) require "rip/setup" if Setup.setup_startup_script(script) ui.puts "rip: Your #{Setup.startup_script} script has been modified." ui.puts "rip: Please restart your shell or type `source #{Rip::Setup.startup_script}` for the changes to become effective." end end |
#show(options = {}, name = nil, *args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rip/commands/show.rb', line 5 def show( = {}, name = nil, *args) if name.to_s.empty? ui.abort "Please give me the name of a package." end installed_package = manager.package(name) if installed_package.nil? ui.abort "The package '#{name}' doesn't seem to be installed" end ui.puts installed_package ui.puts "Depends on: #{display_package_list(manager.dependencies_for(name))}" ui.puts "Required by: #{display_package_list(manager.packages_that_depend_on(name))}" ui.puts "Files:\n\t#{manager.files(name).join("\n\t")}" if [:f] end |
#uninstall(options = {}, name = nil, *args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rip/commands/uninstall.rb', line 7 def uninstall( = {}, name = nil, *args) if name.to_s.empty? ui.abort "Please tell me what to uninstall." end if name == 'rip' && ![:y] ui.abort "Are you sure you want to uninstall rip? Pass -y if so." elsif name == 'rip' && [:y] require 'rip/setup' return Rip::Setup.uninstall(true) end force = [:y] || [:d] package = manager.package(name) if !package ui.abort "#{name} isn't installed." end dependents = manager.packages_that_depend_on(name) if dependents.any? && !force ui.puts "You have requested to uninstall the package:" ui.puts " #{package}" ui.puts ui.puts "The following packages depend on #{name}:" dependents.each do |dependent| ui.puts " #{dependent}" end ui.puts ui.puts "If you remove this package one or more dependencies will not be met." ui.puts "Pass -y if you really want to remove #{name}" ui.abort "Pass -d if you want to remove #{name} and its dependents." end if force || dependents.empty? Installer.new.uninstall(package, [:d]) ui.puts "Successfully uninstalled #{package}" end end |