Module: Depend::PackageProvider::Common
Instance Method Summary collapse
-
#command ⇒ Object
command for package_provider.
-
#display_name ⇒ Object
display_name for package_provider.
-
#exec_install(dep) ⇒ Object
exec install command.
-
#exist? ⇒ Boolean
Check package_provider exist in this system.
-
#install(spec, dep) ⇒ Object
Install dep for spec.
-
#installed?(dep) ⇒ Boolean
check dep installed in this system.
Instance Method Details
#command ⇒ Object
command for package_provider
26 27 28 |
# File 'lib/depend/package_provider/common.rb', line 26 def command fail NotImplementedError, "Implement #command in subclass" end |
#display_name ⇒ Object
display_name for package_provider
48 49 50 |
# File 'lib/depend/package_provider/common.rb', line 48 def display_name self.class.to_s.split("::").last.capitalize end |
#exec_install(dep) ⇒ Object
exec install command
command: command for package_provider dep: library need installed
19 20 21 22 |
# File 'lib/depend/package_provider/common.rb', line 19 def exec_install(dep) puts "Run: #{command} install #{dep}" `#{command} install #{dep}` end |
#exist? ⇒ Boolean
Check package_provider exist in this system
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/depend/package_provider/common.rb', line 32 def exist? paths = ( ENV['PATH'].split(::File::PATH_SEPARATOR) + %w(/bin /usr/bin /sbin /usr/sbin /opt/local/bin) ) paths.each do |path| possible = File.join(path, command) return possible if File.executable?(possible) end false end |
#install(spec, dep) ⇒ Object
Install dep for spec
6 7 8 9 10 11 12 13 |
# File 'lib/depend/package_provider/common.rb', line 6 def install(spec, dep) unless installed?(dep) print "#{spec} need #{dep} installed, Install it with #{display_name} now? y(y/n)" y = STDIN.getc exec_install(dep) unless y.downcase == 'n' end installed?(dep) end |
#installed?(dep) ⇒ Boolean
check dep installed in this system
53 54 55 |
# File 'lib/depend/package_provider/common.rb', line 53 def installed?(dep) fail NotImplementedError, "Implement #installed in subclass" end |