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)


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

def bsd?;   system == :bsd end

#cpu_typeObject



33
34
35
36
37
38
39
# File 'lib/babushka/system_profile.rb', line 33

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



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

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

#descriptionObject



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

def description
  [
    (flavour_str unless flavour_str == system_str),
    system_str,
    version,
    ("(#{name_str})" unless name_str.nil?)
  ].compact.join(' ')
end

#differentiator_for(specs) ⇒ Object



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

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

#library_extObject

The extension that dynamic libraries are given on this system. On linux libraries are named like ‘libssl.so’; on OS X, ‘libssl.bundle’.



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

def library_ext; 'so' end

#linux?Boolean

Returns:

  • (Boolean)


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

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, name, 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

#nameObject



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

def name
  (SystemDefinitions.names[system][flavour] || {})[release]
end

#name_strObject



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

def name_str
  (SystemDefinitions.descriptions[system][flavour] || {})[release]
end

#osx?Boolean

Returns:

  • (Boolean)


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

def osx?;   system == :osx end

#pkg_helperObject



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

def pkg_helper; UnknownPkgHelper end

#pkg_helper_keyObject



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

def pkg_helper_key; pkg_helper.try(:manager_key) end

#pkg_helper_strObject



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

def pkg_helper_str; pkg_helper_key.to_s.capitalize end

#public_ipObject



49
50
51
# File 'lib/babushka/system_profile.rb', line 49

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

#total_memoryObject



45
46
47
# File 'lib/babushka/system_profile.rb', line 45

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

#version_infoObject



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

def version_info
  @_version_info ||= get_version_info
end