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
-
#alert_options ⇒ Object
global options.
-
#chdir ⇒ Object
global options.
-
#cron_env ⇒ Object
global options.
-
#log_level ⇒ Object
global options.
-
#systems ⇒ Object
readonly
DSL stuff.
-
#uid ⇒ Object
global options.
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #load_system_defs ⇒ Object
-
#log(msg, level = :info) ⇒ Object
internal utils.
- #makesurefile ⇒ Object
- #send_alert(title, details = "") ⇒ Object
- #system(name) {|s| ... } ⇒ Object
- #system_with_name(name) ⇒ Object
- #warn(msg) ⇒ Object
Instance Attribute Details
#alert_options ⇒ Object
global options
19 20 21 |
# File 'lib/makesure.rb', line 19 def @alert_options end |
#chdir ⇒ Object
global options
19 20 21 |
# File 'lib/makesure.rb', line 19 def chdir @chdir end |
#cron_env ⇒ Object
global options
19 20 21 |
# File 'lib/makesure.rb', line 19 def cron_env @cron_env end |
#log_level ⇒ Object
global options
19 20 21 |
# File 'lib/makesure.rb', line 19 def log_level @log_level end |
#systems ⇒ Object (readonly)
DSL stuff
58 59 60 |
# File 'lib/makesure.rb', line 58 def systems @systems end |
#uid ⇒ Object
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_defs ⇒ Object
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. 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 |
#makesurefile ⇒ Object
25 26 27 |
# File 'lib/makesure.rb', line 25 def makesurefile File.(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.) Makesure.log "Sending alert to #{opts[:to]}: #{title}" msg = Pony.mail(opts.merge(:subject => title, :body => details)) end |
#system(name) {|s| ... } ⇒ Object
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 |