Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ PATH
dry-configurable (> 0.1, <= 7.0)
dry-container (~> 0.6)
dry-inflector (~> 0.1)
filewatcher (~> 1.1.1)
ice_nine (~> 0.11)
redcarpet (~> 3.4)
sinatra (>= 1.4, < 3.0)
Expand All @@ -111,8 +110,6 @@ GEM
dry-core (0.6.0)
concurrent-ruby (~> 1.0)
dry-inflector (0.2.0)
filewatcher (1.1.1)
optimist (~> 3.0)
ice_nine (0.11.2)
json (2.3.1)
method_source (0.9.0)
Expand All @@ -125,7 +122,6 @@ GEM
racc (~> 1.4)
nokogiri (1.11.7-x86_64-darwin)
racc (~> 1.4)
optimist (3.0.1)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
Expand Down
1 change: 0 additions & 1 deletion coprl.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'tzinfo', '>=1.1', '< 3.0'
spec.add_runtime_dependency 'tzinfo-data', '~>1.2018'
spec.add_runtime_dependency 'redcarpet', '~>3.4'
spec.add_runtime_dependency 'filewatcher', '~> 1.1.1'
spec.add_runtime_dependency 'zeitwerk', '~> 2.1'

spec.add_development_dependency 'thor', '~> 1.1.0'
Expand Down
20 changes: 6 additions & 14 deletions lib/coprl/presenters/rails/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'filewatcher'

module Coprl
module Presenters
module Rails
Expand All @@ -15,20 +13,14 @@ class Railtie < ::Rails::Railtie

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
file_watcher = ActiveSupport::FileUpdateChecker.new(Dir[path]) do
BOOT.call
end

::Rails.application.reloaders << Reloader.new(file_watcher)

} unless defined?(WATCH)

config.after_initialize do
Expand Down
15 changes: 15 additions & 0 deletions lib/coprl/presenters/rails/reloader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module Coprl
module Presenters
module Rails
class Reloader
def initialize(file_watcher)
@file_watcher = file_watcher
end

def updated?
@file_watcher.execute_if_updated
end
end
end
end
end