Class: Specinfra::Command::Base::Package

Inherits:
Specinfra::Command::Base show all
Defined in:
lib/specinfra/command/base/package.rb

Class Method Summary collapse

Methods inherited from Specinfra::Command::Base

create, escape

Class Method Details

.check_is_installed_by_cpan(name, version = nil) ⇒ Object



44
45
46
47
48
49
# File 'lib/specinfra/command/base/package.rb', line 44

def check_is_installed_by_cpan(name, version=nil)
  regexp = "^#{name}"
  cmd = "cpan -l | grep -iw -- #{escape(regexp)}"
  cmd = "#{cmd} | grep -w -- #{escape(version)}" if version
  cmd
end

.check_is_installed_by_gem(name, version = nil) ⇒ Object



3
4
5
6
7
8
# File 'lib/specinfra/command/base/package.rb', line 3

def check_is_installed_by_gem(name, version=nil)
  regexp = "^#{name}"
  cmd = "gem list --local | grep -iw -- #{escape(regexp)}"
  cmd = %Q!#{cmd} | grep -w -- "[( ]#{escape(version)}[,)]"! if version
  cmd
end

.check_is_installed_by_npm(name, version = nil) ⇒ Object



17
18
19
20
21
# File 'lib/specinfra/command/base/package.rb', line 17

def check_is_installed_by_npm(name, version=nil)
  cmd = "npm ls #{escape(name)} -g"
  cmd = "#{cmd} | grep -w -- #{escape(version)}" if version
  cmd
end

.check_is_installed_by_pear(name, version = nil) ⇒ Object



30
31
32
33
34
35
# File 'lib/specinfra/command/base/package.rb', line 30

def check_is_installed_by_pear(name, version=nil)
  regexp = "^#{name}"
  cmd = "pear list -a | grep -iw -- #{escape(regexp)}"
  cmd = "#{cmd} | grep -w -- #{escape(version)}" if version
  cmd
end

.check_is_installed_by_pecl(name, version = nil) ⇒ Object



23
24
25
26
27
28
# File 'lib/specinfra/command/base/package.rb', line 23

def check_is_installed_by_pecl(name, version=nil)
  regexp = "^#{name}"
  cmd = "pecl list | grep -iw -- #{escape(regexp)}"
  cmd = "#{cmd} | grep -w -- #{escape(version)}" if version
  cmd
end

.check_is_installed_by_pip(name, version = nil) ⇒ Object



37
38
39
40
41
42
# File 'lib/specinfra/command/base/package.rb', line 37

def check_is_installed_by_pip(name, version=nil)
  regexp = "^#{name}"
  cmd = "pip list | grep -iw -- #{escape(regexp)}"
  cmd = "#{cmd} | grep -w -- #{escape(version)}" if version
  cmd
end

.check_is_installed_by_rvm(name, version = nil) ⇒ Object



10
11
12
13
14
15
# File 'lib/specinfra/command/base/package.rb', line 10

def check_is_installed_by_rvm(name, version=nil)
  regexp = "^#{name}"
  cmd = "rvm list strings | grep -iw -- #{escape(regexp)}"
  cmd = "#{cmd} | grep -w -- #{escape(version)}" if version
  cmd
end