class Webby::Journal
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.
Attributes
colorize[RW]
logger[R]
Public Class Methods
new()
click to toggle source
Create a new journal
# File lib/webby/journal.rb, line 15 def initialize @logger = ::Logging::Logger[self] @colorize = ENV.has_key?('TERM') end
Public Instance Methods
create( msg )
click to toggle source
Output a create message.
# File lib/webby/journal.rb, line 53 def create( msg ) typed_message('create', msg, (colorize ? :green : nil)) end
create_or_update( page )
click to toggle source
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
exists( msg )
click to toggle source
Output an exists message.
# File lib/webby/journal.rb, line 77 def exists( msg ) typed_message('exists', msg, (colorize ? :cyan : nil)) end
force( msg )
click to toggle source
Output a force message.
# File lib/webby/journal.rb, line 65 def force( msg ) typed_message('force', msg, (colorize ? :red : nil)) end
identical( msg )
click to toggle source
Output an identical message.
# File lib/webby/journal.rb, line 83 def identical( msg ) typed_message('identical', msg, (colorize ? :cyan : nil)) end
skip( msg )
click to toggle source
Output a skip message.
# File lib/webby/journal.rb, line 71 def skip( msg ) typed_message('skip', msg, (colorize ? :yellow : nil)) end
typed_message( type, msg, color = nil )
click to toggle source
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
update( msg )
click to toggle source
Output an update message.
# File lib/webby/journal.rb, line 59 def update( msg ) typed_message('update', msg, (colorize ? :yellow : nil)) end