Class: Boxen::Postflight::Env

Inherits:
Boxen::Postflight show all
Defined in:
lib/boxen/postflight/env.rb

Constant Summary collapse

CHECKSUM =

The checksum when this file was loaded.

self.checksum

Instance Attribute Summary

Attributes inherited from Check

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Check

#abort, checks, #initialize, register, run, #warn

Constructor Details

This class inherits a constructor from Boxen::Check

Class Method Details

.checksumObject

Calculate an MD5 checksum for the current environment.



7
8
9
10
11
12
13
14
15
16
# File 'lib/boxen/postflight/env.rb', line 7

def self.checksum

  # We can't get this from config 'cause it's static (gotta happen
  # on load), and BOXEN_HOME might not be set.

  home = ENV["BOXEN_HOME"] || "/opt/boxen"
  return unless File.file? "#{home}/env.sh"

  `find #{home}/env* -type f 2>&1 | sort | xargs /sbin/md5 | /sbin/md5 -q`.strip
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/boxen/postflight/env.rb', line 22

def ok?
  self.class.checksum == CHECKSUM
end

#runObject



26
27
28
# File 'lib/boxen/postflight/env.rb', line 26

def run
  warn "Source #{config.envfile} or restart your shell for new stuff!"
end