Class: Babushka::SystemProfile

Inherits:
Object
  • Object
show all
Extended by:
ShellHelpers
Includes:
ShellHelpers
Defined in:
lib/babushka/system_profile.rb

Instance Method Summary collapse

Methods included from ShellHelpers

cmd_dir, current_username, log_shell, login_shell, raw_shell, shell, shell!, shell?, shell_cmd, sudo, which

Methods included from LogHelpers

debug, deprecated!, log, log_block, log_error, log_ok, log_stderr, log_warn, removed!

Instance Method Details

#bsd?Boolean

Returns:

  • (Boolean)

34
# File 'lib/babushka/system_profile.rb', line 34

def bsd?;   system == :bsd end

#codenameObject


20
# File 'lib/babushka/system_profile.rb', line 20

def codename; definition.codename end

#codename_strObject


21
# File 'lib/babushka/system_profile.rb', line 21

def codename_str; definition.codename_str end

#cpu_typeObject


43
44
45
46
47
48
49
# File 'lib/babushka/system_profile.rb', line 43

def cpu_type
  shell('uname -m').tap {|result|
    # These replacements are taken from PhusionPassenger::PlatformInfo.cpu_architectures
    result.replace 'x86' if result[/^i.86$/]
    result.replace 'x86_64' if result == 'amd64'
  }
end

#cpusObject


65
# File 'lib/babushka/system_profile.rb', line 65

def cpus; raise "#{self.class}#cpus is unimplemented." end

#definitionObject


13
14
15
# File 'lib/babushka/system_profile.rb', line 13

def definition
  @definition ||= SystemDefinition.new(system, flavour, release)
end

#descriptionObject


55
56
57
58
59
60
61
# File 'lib/babushka/system_profile.rb', line 55

def description
  [
    system_description,
    version,
    ("(#{codename_str})" unless codename_str.nil?)
  ].compact.join(' ')
end

#differentiator_for(specs) ⇒ Object


23
24
25
26
# File 'lib/babushka/system_profile.rb', line 23

def differentiator_for specs
  differentiator = matcher.differentiator_for(specs)
  send("#{differentiator}_str") unless differentiator.nil?
end

#flavourObject


18
# File 'lib/babushka/system_profile.rb', line 18

def flavour; flavour_str.gsub(/[^\w]/, '').downcase.to_sym end

#hostnameObject


36
37
38
# File 'lib/babushka/system_profile.rb', line 36

def hostname
  ShellHelpers.shell('hostname -f')
end

#library_extObject

libblah.so on linux, libblah.bundle on OS X, etc.


64
# File 'lib/babushka/system_profile.rb', line 64

def library_ext; 'so' end

#linux?Boolean

Returns:

  • (Boolean)

32
# File 'lib/babushka/system_profile.rb', line 32

def linux?; system == :linux end

#match_listObject


11
# File 'lib/babushka/system_profile.rb', line 11

def match_list()    matcher.list end

#matcherObject


6
7
8
# File 'lib/babushka/system_profile.rb', line 6

def matcher
  @matcher ||= SystemMatcher.new(system, flavour, codename, pkg_helper_key)
end

#matches?(specs) ⇒ Boolean

Returns:

  • (Boolean)

10
# File 'lib/babushka/system_profile.rb', line 10

def matches?(specs) matcher.matches?(specs) end

#osx?Boolean

Returns:

  • (Boolean)

33
# File 'lib/babushka/system_profile.rb', line 33

def osx?;   system == :osx end

#pkg_helperObject


63
# File 'lib/babushka/system_profile.rb', line 63

def pkg_helper; UnknownPkgHelper end

#pkg_helper_keyObject


40
# File 'lib/babushka/system_profile.rb', line 40

def pkg_helper_key; pkg_helper.manager_key end

#pkg_helper_strObject


41
# File 'lib/babushka/system_profile.rb', line 41

def pkg_helper_str; pkg_helper_key.to_s.capitalize end

#public_ipObject


67
# File 'lib/babushka/system_profile.rb', line 67

def public_ip; raise "#{self.class}#public_ip is unimplemented." end

#systemObject


17
# File 'lib/babushka/system_profile.rb', line 17

def system; system_str.gsub(/[^\w]/, '').downcase.to_sym end

#system_descriptionObject


51
52
53
# File 'lib/babushka/system_profile.rb', line 51

def system_description
  [flavour_str, system_str].uniq.join(' ')
end

#total_memoryObject


66
# File 'lib/babushka/system_profile.rb', line 66

def total_memory; raise "#{self.class}#total_memory is unimplemented." end

#version_infoObject


28
29
30
# File 'lib/babushka/system_profile.rb', line 28

def version_info
  @_version_info ||= get_version_info
end