Class: OSX

Inherits:
Object
  • Object
show all
Defined in:
lib/osx.rb

Class Method Summary collapse

Class Method Details

.check_mac_store_updatesObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/osx.rb', line 47

def check_mac_store_updates
  check_update_message('Mac App Store')
  if run?
    Open3.popen3('softwareupdate -l') do |_stdin, stdout, stderr|
      output = stdout.read
      error = stderr.read
      updates = output.split(/\r\n|\r|\n/, 5).last

      puts updates if output.include?('Software Update found')
      puts '  - No new software updates available.' if error.include?('No new software available')
    end
  else
    puts '  - Skipped.'.colorize(:red)
  end
  break_output
end

.introObject



7
8
9
10
11
12
13
14
# File 'lib/osx.rb', line 7

def intro
  puts <<-EOS.undent
  -------------------
  # OSX Maintenance #
  -------------------
  EOS
  break_output
end

.system_infoObject



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
42
43
44
45
# File 'lib/osx.rb', line 16

def system_info
  cpu = %x(sysctl -n machdep.cpu.brand_string).delete!("\n")
  osx = %x(sw_vers | awk -F':\t' '{print $2}' | paste -d ' ' - - -).delete!("\n")
  hostname = %x(scutil --get ComputerName).delete!("\n")
  ram = %x(sysctl -n hw.memsize | awk '{print $0/1073741824" GB"}').delete!("\n")
  ruby = %x(ruby -e 'puts RUBY_DESCRIPTION').delete!("\n")

  break_output

  puts <<-EOS.undent.bold
    Mac OSX updater version: #{DevOsxUpdater::VERSION}
    ------------------------------

    System information:
      - CPU:   #{cpu}
      - OSX:   #{osx}
      - Host:  #{hostname}
      - RAM:   #{ram}

    Ruby:
      - Ruby version:     #{ruby}
      - RubyGems version: #{Ruby.rubygems_version}
      - Bundler version:  #{Ruby.bundler_version}

    Homebrew:
      - Usage: #{Brew.info if Brew.installed?}
  EOS

  break_output
end