Sha256: 00a6524dd3c8b9ace48d8ab0721e7f83a7b1948676dba6a02cdf0de77a144e15

Contents?: true

Size: 978 Bytes

Versions: 3

Compression:

Stored size: 978 Bytes

Contents

require 'rails'
require 'ixtlan/guard'
require 'logger'

module Ixtlan
  module Guard
    class Railtie < Rails::Railtie

      config.before_configuration do |app|
        app.config.guard = 
          Ixtlan::Guard::Guard.new(:guard_dir => File.join(Rails.root, "app", "guards")) 
      end
      
      config.after_initialize do |app|
        logger = app.config.logger || Rails.logger || Logger.new(STDERR)
        app.config.guard.logger = logger unless defined?(Slf4r)
        begin
          app.config.guard.setup
        rescue Ixtlan::Guard::GuardException => e
          logger.warn e.message
        end
      end
      
      config.generators do
        require 'rails/generators'
        require 'rails/generators/rails/controller/controller_generator'
        Rails::Generators::ControllerGenerator.hook_for :guard, :type => :boolean, :default => true do |controller|
          invoke controller, [ class_name, actions ]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ixtlan-guard-0.5.0 lib/ixtlan/guard/railtie.rb
ixtlan-guard-0.4.1 lib/ixtlan/guard/railtie.rb
ixtlan-guard-0.4.0 lib/ixtlan/guard/railtie.rb