Module: Koch::Helpers
- Defined in:
- lib/koch/helpers.rb
Overview
A random collection of helpers
Constant Summary collapse
- @@dry_run =
true
Instance Method Summary collapse
Instance Method Details
#debian? ⇒ Boolean
27 28 29 |
# File 'lib/koch/helpers.rb', line 27 def debian? !File.read("/etc/issue").match(/Debian/).nil? end |
#diff(old, new) ⇒ Object
23 24 25 |
# File 'lib/koch/helpers.rb', line 23 def diff(old, new) Diffy::Diff.new(old, new, include_diff_info: true, context: 3).to_s(:color).lines[2..].join end |
#maybe(msg_or_cmd) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/koch/helpers.rb', line 10 def maybe(msg_or_cmd) if @@dry_run info "DRY RUN: #{msg_or_cmd}" else info msg_or_cmd if block_given? yield else system msg_or_cmd, exception: true, err: :out end end end |
#ubuntu? ⇒ Boolean
31 32 33 |
# File 'lib/koch/helpers.rb', line 31 def ubuntu? !File.read("/etc/issue").match(/Ubuntu/).nil? end |