Sha256: 2a5562d3529f086125ce0c5ecef2561a233e3b8f22b1190ad315fbd4c76ed84d

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# config.rb contains classes, methods and extends existing Ginsu classes 
# to provide easy configuration facilities.

module Ginsu
  # Represents global configuration for Ginsu::Knife.
  # Can override the following configuration options:
  # * <tt>source</tt> - the source directory of the static web site.  Defaults to 'static'.
  class Config
    @@ATTRIBUTES = [
      :source,
      :slices,
      :links
    ]
    attr_accessor *@@ATTRIBUTES

    def initialize(params = {})
      params.each do |key,val|
        self.send("#{key}=", val) if self.respond_to? key
      end
      self.send(:init) if self.respond_to? :init
    end
    
  end

  class Knife
    @@defaults = { 
      :source => 'static',
      :slices => [],
      :links => []
    }
    @@config = Ginsu::Config.new(@@defaults)

    class << self
      # Yields to given <tt>block</tt> to configure the Ginsu.
      def configure(&block)
        raise ArgumentError, "Block must be provided to configure" unless block_given?
        yield @@config
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
endymion-ginsu-0.1.0 lib/ginsu/config.rb
endymion-ginsu-0.1.1 lib/ginsu/config.rb