The Journal class is used to output simple messages regarding the creation and updating of files when webby applications are run. The output messages will be color coded if the terminal supports the ANSI codes.
Output a create message.
# File lib/webby/journal.rb, line 53 def create( msg ) typed_message('create', msg, (colorize ? :green : nil)) end
Output a “create” message or an “update” message depending on whether the given page already has a generated output file or not.
# File lib/webby/journal.rb, line 43 def create_or_update( page ) if test(e, page.destination) update(page.destination) else create(page.destination) end end
Output an exists message.
# File lib/webby/journal.rb, line 77 def exists( msg ) typed_message('exists', msg, (colorize ? :cyan : nil)) end
Output a force message.
# File lib/webby/journal.rb, line 65 def force( msg ) typed_message('force', msg, (colorize ? :red : nil)) end
Output an identical message.
# File lib/webby/journal.rb, line 83 def identical( msg ) typed_message('identical', msg, (colorize ? :cyan : nil)) end
Output a skip message.
# File lib/webby/journal.rb, line 71 def skip( msg ) typed_message('skip', msg, (colorize ? :yellow : nil)) end
Output a message of the given type using the option color code. The available codes are as follows:
black
red
green
yellow
blue
magenta
cyan
white
The color is specified as a string or a symbol.
# File lib/webby/journal.rb, line 34 def typed_message( type, msg, color = nil ) type = type.to_s.rjust(13) type = self.send(color, type) unless color.nil? logger.info "#{type} #{msg.to_s}" end
Output an update message.
# File lib/webby/journal.rb, line 59 def update( msg ) typed_message('update', msg, (colorize ? :yellow : nil)) end
Create a new journal
# File lib/webby/journal.rb, line 15 def initialize @logger = ::Logging::Logger[self] @colorize = ENV.has_key?('TERM') end