Class Webby::Journal
In: lib/webby/journal.rb
Parent: Object

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.

Methods

create   create_or_update   exists   force   identical   new   skip   typed_message   update  

Attributes

colorize  [RW] 
logger  [R] 

Public Class methods

Create a new journal

[Source]

# File lib/webby/journal.rb, line 15
  def initialize
    @logger = ::Logging::Logger[self]
    @colorize = ENV.has_key?('TERM')
  end

Public Instance methods

Output a create message.

[Source]

# 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.

[Source]

# 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.

[Source]

# File lib/webby/journal.rb, line 77
  def exists( msg )
    typed_message('exists', msg, (colorize ? :cyan : nil))
  end

Output a force message.

[Source]

# File lib/webby/journal.rb, line 65
  def force( msg )
    typed_message('force', msg, (colorize ? :red : nil))
  end

Output an identical message.

[Source]

# File lib/webby/journal.rb, line 83
  def identical( msg )
    typed_message('identical', msg, (colorize ? :cyan : nil))
  end

Output a skip message.

[Source]

# 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.

[Source]

# 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.

[Source]

# File lib/webby/journal.rb, line 59
  def update( msg )
    typed_message('update', msg, (colorize ? :yellow : nil))
  end

[Validate]