Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change pretty much everything.

  • Loading branch information...
commit f2902d047a9756e725b377433146d847bbd7b47c 1 parent 8113959
thedarkone authored
View
5 init.rb
@@ -1,6 +1,11 @@
if Rails.env.development?
if defined?(:ConcernedWith) && defined?(:RailsDevelopmentBoost)
+ RailsDevelopmentBoost::DependenciesPatch.send :include, ConcernedWithDepPatch
ConcernedWith.send :include, RailsDevBoostConcernedWithFix
+ RailsDevelopmentBoost::LoadedFile.class_eval do
+ attr_writer :mtime
+ attr_accessor :concerned_with_parent
+ end
else
Rails.logger.warn "concerned_with_rails_dev_boost needs to be loaded *after* concerned_with and rails-dev-boost plugins."
end
View
17 lib/concerned_with_dep_patch.rb
@@ -0,0 +1,17 @@
+module ConcernedWithDepPatch
+
+ def unload_modified_files_with_concerned_fix
+ file_map.each_value do |file|
+ if file.concerned_with_parent && file.changed?
+ file.mtime = 0 # keep it changed
+ file_map[file.concerned_with_parent].mtime = 0 # propagate concerned_with changed status
+ end
+ end
+ unload_modified_files_without_concerned_fix
+ end
+
+ def self.included(dep_mod)
+ dep_mod.alias_method_chain :unload_modified_files, :concerned_fix
+ end
+
+end
View
12 lib/rails_dev_boost_concerned_with_fix.rb
@@ -3,17 +3,21 @@ module RailsDevBoostConcernedWithFix
def concerned_with_with_dependency_tracking(*args)
concerned_with_without_dependency_tracking(*args)
+ my_file_path_without_rb = ActiveSupport::Dependencies.search_for_file(name.underscore).sub(/\.rb\Z/, '')
args.each do |dependency|
- dep_file_path = ActiveSupport::Dependencies.search_for_file("#{name.underscore}/#{dependency}".to_s)
# Handle the case, when the parent object is changed, i.e. - make sure require_dependency does go through next time
- ActiveSupport::Dependencies.loaded.delete(dep_file_path.sub(/\.rb\Z/, ''))
- # Handle the case, when concerned_with file changes by associating a dummy constant with it and setting the parent object to be its dependency.
+ dep_file_path = ActiveSupport::Dependencies.search_for_file("#{name.underscore}/#{dependency}")
+ dep_file_path_withour_rb = dep_file_path.sub(/\.rb\Z/, '')
+ ActiveSupport::Dependencies.loaded.delete(dep_file_path_withour_rb)
+
+ # Handle the case, when concerned_with file changes by associating a dummy constant with it and setting up changed status propagation
dummy_const_name = "ConcernedWith__#{name.underscore}_#{dependency}"
const_set(dummy_const_name, Module.new)
dummy_const_full_name = "#{name}::#{dummy_const_name}"
# track the concerned_with file
ActiveSupport::Dependencies.associate_constants_to_file([dummy_const_full_name], dep_file_path)
- ActiveSupport::Dependencies.add_explicit_dependency(dummy_const_full_name, name)
+ # set the unload parent trigger
+ ActiveSupport::Dependencies.file_map[dep_file_path_withour_rb].concerned_with_parent = my_file_path_without_rb
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.