Module: Polygon::Script
- Defined in:
- lib/polygon/script.rb,
lib/polygon/script/gsub.rb,
lib/polygon/script/open.rb
Defined Under Namespace
Constant Summary collapse
- Launch =
class Open
Open
Instance Attribute Summary collapse
-
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
Instance Method Summary collapse
- #debug(message, &block) ⇒ Object
- #error(message, &block) ⇒ Object
- #fatal(message, &block) ⇒ Object
- #flush_logs ⇒ Object
- #info(message, &block) ⇒ Object
- #log(message, severity) ⇒ Object
- #log_io ⇒ Object
- #root ⇒ Object
- #spawn(command) ⇒ Object
- #warn(message, &block) ⇒ Object
Instance Attribute Details
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
7 8 9 |
# File 'lib/polygon/script.rb', line 7 def enable_logging @enable_logging end |
Instance Method Details
#debug(message, &block) ⇒ Object
23 |
# File 'lib/polygon/script.rb', line 23 def debug(, &block); log(, :debug, &block); end |
#error(message, &block) ⇒ Object
26 |
# File 'lib/polygon/script.rb', line 26 def error(, &block); log(, :error, &block); end |
#fatal(message, &block) ⇒ Object
27 |
# File 'lib/polygon/script.rb', line 27 def fatal(, &block); log(, :fatal, &block); end |
#flush_logs ⇒ Object
29 30 31 |
# File 'lib/polygon/script.rb', line 29 def flush_logs @log_io.close if @log_io end |
#info(message, &block) ⇒ Object
24 |
# File 'lib/polygon/script.rb', line 24 def info(, &block); log(, :info, &block); end |
#log(message, severity) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/polygon/script.rb', line 17 def log(, severity) puts log_io.puts("#{severity}: #{}") if enable_logging log_io.flush yield if block_given? end |
#log_io ⇒ Object
13 14 15 |
# File 'lib/polygon/script.rb', line 13 def log_io @log_io ||= File.open(root/:logs/"#{Quickl.command_name(self)}.log".to_s, "w") end |
#root ⇒ Object
9 10 11 |
# File 'lib/polygon/script.rb', line 9 def root Path($0).backfind('.[config.ru]') || Path.pwd.backfind('.[config.ru]') end |
#spawn(command) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/polygon/script.rb', line 33 def spawn(command) if enable_logging Kernel.spawn(command, [:out, :err] => log_io) else Kernel.spawn(command) end end |
#warn(message, &block) ⇒ Object
25 |
# File 'lib/polygon/script.rb', line 25 def warn(, &block); log(, :warn, &block); end |