module Marmara::Config

Attributes

options[R]

Public Instance Methods

get_report_filename(uri) click to toggle source
# File lib/marmara/config.rb, line 50
def get_report_filename(uri)
  if options && options[:rewrite]
    rewrite_rules = options[:rewrite]
    rewrite_rules = [rewrite_rules] unless rewrite_rules.is_a?(Array)
    rewrite_rules.each do |rule|
      return uri.gsub(rule[:from], rule[:to]) if uri =~ rule[:from]
    end
  end

  return File.basename(uri).gsub(/^(.*?)\?.*$/, '\1')
end
ignore?(file) click to toggle source
# File lib/marmara/config.rb, line 36
def ignore?(file)
  return false unless options

  [*options[:ignore]].each do |matcher|
    if matcher.is_a?(Regexp)
      return true if file =~ matcher
    else
      return true if file.start_with?(matcher)
    end
  end

  return false
end
log(str, method = :info) click to toggle source
# File lib/marmara/config.rb, line 28
def log(str, method = :info)
  if @logger
    @logger.send(method, str)
  elsif @logger.nil?
    puts str
  end
end
logger=(logger) click to toggle source
# File lib/marmara/config.rb, line 24
def logger=(logger)
  @logger = logger
end
options=(opts) click to toggle source
# File lib/marmara/config.rb, line 5
def options=(opts)
  if @options
    if @options[:output_directory]
      opts[:output_directory] ||= @options[:output_directory]
    end
  end

  @options = opts
end
output_directory() click to toggle source
# File lib/marmara/config.rb, line 15
def output_directory
  (options || {})[:output_directory] || 'log/css'
end
output_directory=(dir) click to toggle source
# File lib/marmara/config.rb, line 19
def output_directory=(dir)
  @options ||= {}
  @options[:output_directory] = dir
end