lib/picky/internals/extensions/object.rb in picky-1.5.2 vs lib/picky/internals/extensions/object.rb in picky-1.5.3
- old
+ new
@@ -1,22 +1,29 @@
class Object # :nodoc:all
-
+
# Puts a text in the form:
# 12:34:56: text here
#
def timed_exclaim text
exclaim "#{Time.now.strftime("%H:%M:%S")}: #{text}"
end
-
+
# Just puts the given text.
#
def exclaim text
puts text
end
-
+
# Puts a text that informs the user of a missing gem.
#
- def puts_gem_missing gem_name, message
- puts "#{gem_name} gem missing!\nTo use #{message}, you need to:\n 1. Add the following line to Gemfile:\n gem '#{gem_name}'\n 2. Then, run:\n bundle update\n"
+ def warn_gem_missing gem_name, message
+ warn "#{gem_name} gem missing!\nTo use #{message}, you need to:\n 1. Add the following line to Gemfile:\n gem '#{gem_name}'\n 2. Then, run:\n bundle update\n"
end
-
+
+ # Indents each line by <tt>amount=2</tt> spaces.
+ #
+ def indented_to_s amount = 2
+ ary = self.respond_to?(:join) ? self : self.to_s.split("\n")
+ ary.map { |s| "#{" "*amount}#{s}"}.join("\n")
+ end
+
end
\ No newline at end of file