Sha256: 3dc614e9b17197f31f6c3d05acd73e69f094dc77b415d16cf12b6d5f0a342aec

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

require 'filewatcher'

module Coprl
  module Presenters
    module Rails
      class Railtie < ::Rails::Railtie
        BOOT = -> {
          Coprl::Presenters::App.reset!
          Coprl::Presenters::Settings.configure do |config|
            config.presenters.root = ::Rails.root.join('app')
            config.presenters.deep_freeze = false
          end
          Coprl::Presenters::App.boot!
        } unless defined?(BOOT)

        WATCH = -> {
          return unless ::Rails.env.development?
          path = ::Rails.root.join('app', '**', '*.pom')
          puts "Watching #{path} for changes..."
          filewatcher = Filewatcher.new(path)
          Thread.new(filewatcher) do |fw|
            fw.watch do |f|
              puts "Detected updated POM file: #{f}"
              begin
                BOOT.call
              rescue Exception => exc
                puts exc.backtrace
                puts exc.message
              end
            end
          end
        } unless defined?(WATCH)

        config.after_initialize do
          BOOT.call
          WATCH.call
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
coprl-3.0.0.beta.6 lib/coprl/presenters/rails/railtie.rb
coprl-3.0.0.beta.5 lib/coprl/presenters/rails/railtie.rb
coprl-3.0.0.beta.4 lib/coprl/presenters/rails/railtie.rb
coprl-3.0.0.beta.3 lib/coprl/presenters/rails/railtie.rb
coprl-3.0.0.beta.2 lib/coprl/presenters/rails/railtie.rb
coprl-3.0.0.beta.1 lib/coprl/presenters/rails/railtie.rb