Sha256: 282073e3bd67529294fec6afd31857bdca771d8160f3a52319ffcb3ce05921ac

Contents?: true

Size: 940 Bytes

Versions: 6

Compression:

Stored size: 940 Bytes

Contents

require 'filewatcher'

module Voom
  class Railtie < ::Rails::Railtie
    BOOT = -> {
      Voom::Presenters::App.reset!
      Voom::Presenters::Settings.configure do |config|
        config.presenters.root = Rails.root.join('app')
        config.presenters.deep_freeze = false
      end
      Voom::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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-2.1.2 lib/voom/railtie.rb
voom-presenters-2.1.0 lib/voom/railtie.rb
voom-presenters-2.0.3 lib/voom/railtie.rb
voom-presenters-2.0.2 lib/voom/railtie.rb
voom-presenters-2.0.1 lib/voom/railtie.rb
voom-presenters-2.0.0 lib/voom/railtie.rb