Permalink
Browse files

Initial commit.

  • Loading branch information...
thedarkone
thedarkone committed Jan 27, 2009
0 parents commit 81139595705c1cb5bb7afc3e3c081661b5734fd8
@@ -0,0 +1,20 @@
+Copyright (c) 2009 [name of plugin creator]
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 README
@@ -0,0 +1,10 @@
+RailsDevBoostConcernedWithFix
+==========================
+
+Fixes an incompatibility between a concerned_with[http://github.com/jakehow/concerned_with] and rails-dev-boost[http://github.com/thedarkone/rails-dev-boost] plugins.
+
+Usage
+=======
+
+The plugin needs to be loaded after both the concerned_with and rails-dev-boost plugins (that is what Rails will do by default).
+
@@ -0,0 +1,23 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the rails_dev_boost_concerned_with_fix plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the rails_dev_boost_concerned_with_fix plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'RailsDevBoostConcernedWithFix'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1,7 @@
+if Rails.env.development?
+ if defined?(:ConcernedWith) && defined?(:RailsDevelopmentBoost)
+ ConcernedWith.send :include, RailsDevBoostConcernedWithFix
+ else
+ Rails.logger.warn "concerned_with_rails_dev_boost needs to be loaded *after* concerned_with and rails-dev-boost plugins."
+ end
+end
@@ -0,0 +1 @@
+# Install hook code here
@@ -0,0 +1,24 @@
+# ConcernedWithRailsDevBoost
+module RailsDevBoostConcernedWithFix
+
+ def concerned_with_with_dependency_tracking(*args)
+ concerned_with_without_dependency_tracking(*args)
+ 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.
+ 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)
+ end
+ end
+
+ def self.included(base)
+ base.alias_method_chain :concerned_with, :dependency_tracking
+ end
+
+end
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class RailsDevBoostConcernedWithFix < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
@@ -0,0 +1,3 @@
+require 'rubygems'
+require 'active_support'
+require 'active_support/test_case'
@@ -0,0 +1 @@
+# Uninstall hook code here

0 comments on commit 8113959

Please sign in to comment.