Module: Megam::Stuff
Instance Method Summary collapse
- #git(args) ⇒ Object
- #has_git? ⇒ Boolean
-
#styled_hash(hash) ⇒ Object
left justified keyed hash with newlines.
Instance Method Details
#git(args) ⇒ Object
9 10 11 12 13 |
# File 'lib/megam/core/stuff.rb', line 9 def git(args) return "" unless has_git? flattened_args = [args].flatten.compact.join(" ") %x{ git #{flattened_args} 2>&1 }.strip end |
#has_git? ⇒ Boolean
4 5 6 7 |
# File 'lib/megam/core/stuff.rb', line 4 def has_git? %x{ git --version } $?.success? end |
#styled_hash(hash) ⇒ Object
left justified keyed hash with newlines.
17 18 19 |
# File 'lib/megam/core/stuff.rb', line 17 def styled_hash(hash) hash.map{|k,v| "#{k.ljust(15)}=#{v}"}.join("\n") end |