Sha256: 28c2cb4cd4cc51ce90dd08d9e197f04bef87545acf77eaf5170eb7a6c62a6672

Contents?: true

Size: 933 Bytes

Versions: 3

Compression:

Stored size: 933 Bytes

Contents

module RouteDog
  class Railtie < Rails::Railtie
    attr_reader :route_dog_config

    rake_tasks do
      load "tasks/tasks.rake"
    end

    initializer "route_dog.configure_rails_initialization" do |app|
      load_route_dog_configuration
      setup_middlewares(app)
    end

  private

    def setup_middlewares(app)
      app.config.middleware.use RouteDog::Middleware::Watcher  if route_dog_config.has_key?("watcher") && route_dog_config["watcher"]["env"].include?(Rails.env)
      app.config.middleware.use RouteDog::Middleware::Notifier if route_dog_config.has_key?("notifier") && route_dog_config["notifier"]["env"].include?(Rails.env)
    end

    def load_route_dog_configuration
      @route_dog_config ||= YAML.load_file(File.join(Rails.root, 'config', 'route_dog.yml'))
    rescue Errno::ENOENT
      @route_dog_config = {"watcher" => {"env" => ["test"]}, "notifier" => {"env" => ["development"]}}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
route_dog-2.3.1 lib/route_dog/railtie.rb
route_dog-2.3.0 lib/route_dog/railtie.rb
route_dog-2.2.0 lib/route_dog/railtie.rb