Module: Rip::Commands
- Extended by:
- Commands
- Included in:
- Commands
- Defined in:
- lib/rip/commands.rb,
lib/rip/commands/core.rb,
lib/rip/commands/build.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
- #public_instance_methods ⇒ Object
- #uninstall(options = {}, name = nil, *args) ⇒ Object
- #version(options = {}, *args) ⇒ Object (also: #-v, #--version)
Instance Method Details
#build(options = {}, *packages) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rip/commands/build.rb', line 8 def build(={}, *packages) packages.each do |package_name| ui.puts "rip: building package: #{package_name}" package = manager.package(package_name) Dir["#{package.cache_path}/**/extconf.rb"].each do |build_file| build_dir = File.dirname(build_file) Dir.chdir(build_dir) { system "ruby extconf.rb" system "make install RUBYARCHDIR=#{manager.dir}/lib" } end end end |
#check(*args) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/rip/commands/install.rb', line 4 def check(*args) Setup.check_installation ui.puts "All systems go." rescue => e ui.abort "Installation failed: #{e.}" end |
#env(options = {}, command = nil, *args) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/rip/commands/core.rb', line 29 def env( = {}, command = nil, *args) if command && Rip::Env.respond_to?(command) ui.puts 'ripenv: ' + Rip::Env.call(command, *args).to_s else show_help :env, Rip::Env.commands ui.puts '', "current ripenv: #{Rip::Env.active}" end end |
#freeze(options = {}, env = nil, *args) ⇒ Object
41 42 43 44 45 |
# File 'lib/rip/commands/core.rb', line 41 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
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rip/commands/install.rb', line 14 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 if [:f] Installer.new.uninstall(package) if package.installed? Installer.new.install(package) elsif package.installed? ui.puts "#{package} already installed" else installer = Installer.new installer.install(package) # puts "#{installer.installed.size.to_i} packages installed" end end |
#invoke(args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rip/commands.rb', line 5 def invoke(args) command, , args = parse_args(args) if command.nil? || command == '' 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 |
#public_instance_methods ⇒ Object
26 27 28 |
# File 'lib/rip/commands.rb', line 26 def public_instance_methods super - %w( invoke public_instance_methods ) 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 |
# 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 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 |