Sha256: 2e77e5989e6efce0206268aa186aaff6c43fd5f51e5afb2807154543f47a4638

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 KB

Contents

require 'veewee/config/veewee'
require 'veewee/config/collection'

require 'fileutils'

module Veewee
  class Config

    attr_accessor :veewee
    attr_reader :env

    def initialize(options)
      @env=options[:env]

      # Initialize with defaults
      @veewee=::Veewee::Config::Veewee.new(self)

    end

    def define()
      config=OpenStruct.new

      # Expose the veewee config
      config.veewee=@veewee

      # Process config file
      yield config

    end

    # We put a long name to not clash with any function in the Veewee file itself
    def load_veewee_config()
      veewee_configurator=self
      begin
        filename=File.join(Dir.pwd,"Veeweefile")
        if File.exists?(filename)
          veeweefile=File.read(filename)
          veeweefile["Veewee::Config.run"]="veewee_configurator.define"
          #        http://www.dan-manges.com/blog/ruby-dsls-instance-eval-with-delegation
          instance_eval(veeweefile)
        else
          env.logger.info "No configfile found"
        end
      rescue LoadError => e
        env.ui.error "An error occurred"
        env.ui.error e.message
      rescue NoMethodError => e
        env.ui.error "Some method got an error in the configfile - Sorry"
        env.ui.error $!
        env.ui.error e.message
        raise Veewee::Error "Some method got an error in the configfile - Sorry"
      rescue Error => e
        env.ui.error "Error processing configfile - Sorry"
        env.ui.error e.message
        raise Veewee::Error "Error processing configfile - Sorry"
      end
      return self
    end



  end #End Class
end #End Module

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
veewee-0.3.6 lib/veewee/config.rb
veewee-0.3.5 lib/veewee/config.rb
veewee-0.3.4 lib/veewee/config.rb
veewee-0.3.3 lib/veewee/config.rb
veewee-0.3.2 lib/veewee/config.rb
veewee-0.3.1 lib/veewee/config.rb
veewee-0.3.0.beta2 lib/veewee/config.rb
veewee-0.3.0.beta1 lib/veewee/config.rb
veewee-0.3.0.alpha9 lib/veewee/config.rb