Module: Makesure

Extended by:
Makesure
Included in:
Makesure
Defined in:
lib/makesure.rb,
lib/makesure/cmd.rb,
lib/makesure/cron.rb,
lib/makesure/runner.rb,
lib/makesure/system.rb,
lib/makesure/verify.rb,
lib/makesure/version.rb,
lib/makesure/summarize.rb

Defined Under Namespace

Modules: Version Classes: Cmd, Cron, Runner, Summarize, System, Verify

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#alert_optionsObject

global options



19
20
21
# File 'lib/makesure.rb', line 19

def alert_options
  @alert_options
end

#chdirObject

global options



19
20
21
# File 'lib/makesure.rb', line 19

def chdir
  @chdir
end

#cron_envObject

global options



19
20
21
# File 'lib/makesure.rb', line 19

def cron_env
  @cron_env
end

#log_levelObject

global options



19
20
21
# File 'lib/makesure.rb', line 19

def log_level
  @log_level
end

#systemsObject (readonly)

DSL stuff



58
59
60
# File 'lib/makesure.rb', line 58

def systems
  @systems
end

#uidObject

global options



19
20
21
# File 'lib/makesure.rb', line 19

def uid
  @uid
end

Instance Method Details

#debug(msg) ⇒ Object



77
78
79
# File 'lib/makesure.rb', line 77

def debug(msg)
  log(msg, :debug) if log_level == :debug
end

#load_system_defsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/makesure.rb', line 29

def load_system_defs
  file = makesurefile
  Makesure.log("Loading Makesurefile")
  load(file)
  abort "No system specifications found" unless Makesure.systems.size > 0
  Makesure.log "Loaded #{Makesure.systems.size} system specifications"
rescue Exception => e
  if e.instance_of?(SystemExit)
    raise
  else
    Makesure.warn "There was an error loading #{file}"
    Makesure.warn "\t" + e.message
    Makesure.warn "\t" + e.backtrace.join("\n\t")
    abort "Couldn't load your Makesurefile"
  end
end

#log(msg, level = :info) ⇒ Object

internal utils



69
70
71
# File 'lib/makesure.rb', line 69

def log(msg, level = :info)
  puts "[#{Time.now.to_s}] #{level.to_s.upcase}: #{msg}"
end

#makesurefileObject



25
26
27
# File 'lib/makesure.rb', line 25

def makesurefile
  File.expand_path(File.join(Dir.pwd, "Makesurefile"))
end

#send_alert(title, details = "") ⇒ Object



50
51
52
53
54
# File 'lib/makesure.rb', line 50

def send_alert(title, details = "")
  opts = { :from => "makesure@unknown" }.merge(Makesure.alert_options)
  Makesure.log "Sending alert to #{opts[:to]}: #{title}"
  msg = Pony.mail(opts.merge(:subject => title, :body => details))
end

#system(name) {|s| ... } ⇒ Object

Yields:

  • (s)


60
61
62
63
64
65
# File 'lib/makesure.rb', line 60

def system(name)
  Makesure.debug "Reading specification for system '#{name}'"
  s = Makesure::System.new(name)
  yield s
  @systems << s
end

#system_with_name(name) ⇒ Object



46
47
48
# File 'lib/makesure.rb', line 46

def system_with_name(name)
  systems.find { |s| s.name.to_s == name.to_s }
end

#warn(msg) ⇒ Object



73
74
75
# File 'lib/makesure.rb', line 73

def warn(msg)
  log(msg, :warn)
end