rails-dev-boost 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ module RailsDevelopmentBoost
2
+ module ObservablePatch
3
+ extend self
4
+
5
+ def self.apply!
6
+ patch = self
7
+
8
+ if non_ruby_lib_implementation?
9
+ ActiveModel::Observing::ClassMethods # post c2ca73c9 compatibility
10
+ else
11
+ require 'observer'
12
+ Observable
13
+ end.class_eval do
14
+ include patch
15
+ alias_method_chain :add_observer, :unloading
16
+ end
17
+ end
18
+
19
+ def self.non_ruby_lib_implementation?
20
+ defined?(ActiveModel::Observing::ClassMethods) && ActiveModel::Observing::ClassMethods.public_instance_methods(false).map(&:to_s).include?('add_observer')
21
+ end
22
+
23
+ def add_observer_with_unloading(*args)
24
+ if kind_of?(Module)
25
+ my_module, observer_module = ObservablePatch._get_module(self), ObservablePatch._get_module(args.first)
26
+
27
+ ActiveSupport::Dependencies.add_explicit_dependency(my_module, observer_module)
28
+ ActiveSupport::Dependencies.add_explicit_dependency(observer_module, my_module)
29
+ end
30
+
31
+ add_observer_without_unloading(*args)
32
+ end
33
+
34
+ def _get_module(object)
35
+ object.kind_of?(Module) ? object : object.class
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ module RailsDevelopmentBoost
2
+ module ReferenceCleanupPatch
3
+ def self.apply!
4
+ Module.send :include, self
5
+ Module.alias_method_chain :remove_const, :reference_cleanup
6
+ end
7
+
8
+ def remove_const_with_reference_cleanup(const_name)
9
+ ActiveSupport::Dependencies::Reference.loose!(self == Object ? const_name : "#{_mod_name}::#{const_name}")
10
+ ActiveSupport::DescendantsTracker.delete(const_get(const_name))
11
+ remove_const_without_reference_cleanup(const_name)
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,5 @@
1
+ require 'active_support/dependencies'
2
+
1
3
  module RailsDevelopmentBoost
2
4
  module ReferencePatch
3
5
  if defined?(ActiveSupport::Dependencies::ClassCache) # post Rails' f345e2380cac2560f3bb
@@ -7,6 +9,7 @@ module RailsDevelopmentBoost
7
9
 
8
10
  def loose!(const_name)
9
11
  @store.delete(const_name)
12
+ @store.delete("::#{const_name}") # constantize is sometimes weird like that
10
13
  end
11
14
  else
12
15
  def self.apply!
@@ -17,6 +20,7 @@ module RailsDevelopmentBoost
17
20
  module ClassMethods
18
21
  def loose!(const_name)
19
22
  constants.delete(const_name)
23
+ constants.delete("::#{const_name}") # constantize is sometimes weird like that
20
24
  end
21
25
  end
22
26
  end
@@ -0,0 +1,51 @@
1
+ module RailsDevelopmentBoost
2
+ module Reloader # replacement for the Rails' post fa1d9a file_update_checker
3
+ extend self
4
+
5
+ def hook_in!
6
+ Rails.application.reloaders.unshift(self)
7
+ ActionDispatch::Reloader.to_prepare(:prepend => true) { RailsDevelopmentBoost::Reloader.execute_if_updated }
8
+ end
9
+
10
+ def execute
11
+ init unless @inited
12
+ @last_run_result = ActiveSupport::Dependencies.unload_modified_files!
13
+ end
14
+
15
+ def execute_if_updated
16
+ @last_run_result.nil? ? execute : @last_run_result
17
+ ensure
18
+ @last_run_result = nil
19
+ end
20
+
21
+ alias_method :updated?, :execute
22
+
23
+ private
24
+ def init
25
+ Rails.application.reloaders.delete_if do |reloader|
26
+ if rails_file_checker?(reloader)
27
+ pacify_rails_file_checker(reloader) # the checker's methods are still being called in AD::Reloader's to_prepare callback
28
+ true # remove the Rails' default file_checker
29
+ end
30
+ end
31
+ @inited = true
32
+ end
33
+
34
+ def pacify_rails_file_checker(file_checker)
35
+ file_checker.singleton_class.class_eval do
36
+ def updated?; false; end
37
+ def execute; false; end
38
+ def execute_if_updated; false; end
39
+ end
40
+ end
41
+
42
+ def rails_file_checker?(reloader)
43
+ if (dir_glob = reloader.instance_variable_get(:@glob)).kind_of?(String)
44
+ autoload_paths = ActiveSupport::Dependencies.autoload_paths
45
+ dir_glob.sub(/\A\{/, '').sub(/\}\Z/, '').split(',').all? do |glob_path|
46
+ autoload_paths.any? {|autoload_path| glob_path.starts_with?(autoload_path)}
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,36 @@
1
+ module RailsDevelopmentBoost
2
+ class RequiredDependency < Array
3
+ def initialize(currently_loading)
4
+ super(caller)
5
+ @currently_loading = currently_loading
6
+ end
7
+
8
+ def related_files
9
+ files = []
10
+ each_autoloaded_file do |file_path|
11
+ if @currently_loading == file_path
12
+ files << @currently_loading
13
+ break
14
+ elsif LoadedFile.loaded?(file_path)
15
+ files << file_path
16
+ end
17
+ end
18
+ files.uniq
19
+ end
20
+
21
+ private
22
+ def each_autoloaded_file
23
+ each do |stack_line|
24
+ if file_path = extract_file_path(stack_line)
25
+ yield file_path
26
+ end
27
+ end
28
+ end
29
+
30
+ def extract_file_path(stack_line)
31
+ if m = stack_line.match(/\A(.*):[0-9]+(?::in `[^']+')?\Z/)
32
+ m[1]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -6,7 +6,11 @@ module RailsDevelopmentBoost
6
6
 
7
7
  # we need to explicitly associate helpers to their including controllers/mailers
8
8
  def add_template_helper_with_const_association_tracking(helper_module)
9
- ActiveSupport::Dependencies.add_explicit_dependency(helper_module, self)
9
+ if DependenciesPatch::Util.anonymous_const?(helper_module)
10
+ helper_module.ancestors.each {|ancestor| ActiveSupport::Dependencies.add_explicit_dependency(ancestor, self)}
11
+ else
12
+ ActiveSupport::Dependencies.add_explicit_dependency(helper_module, self)
13
+ end
10
14
  add_template_helper_without_const_association_tracking(helper_module)
11
15
  end
12
16
 
metadata CHANGED
@@ -1,22 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-dev-boost
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
- - "Roman Le N\xC3\xA9grate"
13
+ - Roman Le Negrate
14
14
  - thedarkone
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-11 00:00:00 +03:00
19
+ date: 2012-10-02 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -30,43 +30,42 @@ extra_rdoc_files:
30
30
  - LICENSE
31
31
  - README.markdown
32
32
  files:
33
- - .gitignore
34
- - LICENSE
35
- - README.markdown
36
- - Rakefile
37
- - TODO.txt
38
- - VERSION
39
- - init.rb
40
- - lib/rails_development_boost.rb
33
+ - lib/rails-dev-boost.rb
34
+ - lib/rails_development_boost/async.rb
35
+ - lib/rails_development_boost/dependencies_patch/instrumentation_patch.rb
41
36
  - lib/rails_development_boost/dependencies_patch.rb
42
37
  - lib/rails_development_boost/descendants_tracker_patch.rb
38
+ - lib/rails_development_boost/loadable_patch.rb
43
39
  - lib/rails_development_boost/loaded_file.rb
40
+ - lib/rails_development_boost/observable_patch.rb
41
+ - lib/rails_development_boost/reference_cleanup_patch.rb
44
42
  - lib/rails_development_boost/reference_patch.rb
43
+ - lib/rails_development_boost/reloader.rb
44
+ - lib/rails_development_boost/required_dependency.rb
45
45
  - lib/rails_development_boost/view_helpers_patch.rb
46
- - rails-dev-boost.gemspec
47
- - test/constants/.DS_Store
46
+ - lib/rails_development_boost.rb
48
47
  - test/constants/active_record/comment.rb
49
48
  - test/constants/active_record/message.rb
50
49
  - test/constants/active_record/other.rb
51
50
  - test/constants/active_record/post.rb
52
- - test/constants/deep_nesting/a.rb
53
- - test/constants/deep_nesting/a/b.rb
54
- - test/constants/deep_nesting/a/b/c.rb
55
51
  - test/constants/deep_nesting/a/b/c/d.rb
56
- - test/constants/double_removal/ns.rb
52
+ - test/constants/deep_nesting/a/b/c.rb
53
+ - test/constants/deep_nesting/a/b.rb
54
+ - test/constants/deep_nesting/a.rb
57
55
  - test/constants/double_removal/ns/c.rb
58
56
  - test/constants/double_removal/ns/m.rb
57
+ - test/constants/double_removal/ns.rb
59
58
  - test/constants/mixins/client.rb
60
59
  - test/constants/mixins/mixin.rb
61
60
  - test/constants/mixins/update/mixin.rb
62
- - test/constants/nested_mixins/b.rb
63
61
  - test/constants/nested_mixins/b/c.rb
64
- - test/constants/nested_mixins/ma.rb
65
- - test/constants/nested_mixins/ma/mb.rb
62
+ - test/constants/nested_mixins/b.rb
66
63
  - test/constants/nested_mixins/ma/mb/mc.rb
67
- - test/constants/nested_mixins/oa.rb
68
- - test/constants/nested_mixins/oa/ob.rb
64
+ - test/constants/nested_mixins/ma/mb.rb
65
+ - test/constants/nested_mixins/ma.rb
69
66
  - test/constants/nested_mixins/oa/ob/oc.rb
67
+ - test/constants/nested_mixins/oa/ob.rb
68
+ - test/constants/nested_mixins/oa.rb
70
69
  - test/constants/single_removal/a.rb
71
70
  - test/constants/single_removal/b.rb
72
71
  - test/constants/singleton_mixins/a.rb
@@ -76,6 +75,9 @@ files:
76
75
  - test/constants/subclass/c.rb
77
76
  - test/rails_development_boost_test.rb
78
77
  - test/stub_environment.rb
78
+ - LICENSE
79
+ - README.markdown
80
+ - VERSION
79
81
  has_rdoc: true
80
82
  homepage: http://github.com/thedarkone/rails-dev-boost
81
83
  licenses: []
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  requirements: []
107
109
 
108
110
  rubyforge_project:
109
- rubygems_version: 1.4.2
111
+ rubygems_version: 1.5.2
110
112
  signing_key:
111
113
  specification_version: 3
112
114
  summary: Speeds up Rails development mode
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- .DS_Store
data/Rakefile DELETED
@@ -1,52 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "rails-dev-boost"
8
- gem.summary = %Q{Speeds up Rails development mode}
9
- gem.description = %Q{Make your Rails app 10 times faster in development mode}
10
- gem.email = "roman.lenegrate@gmail.com"
11
- gem.homepage = "http://github.com/thedarkone/rails-dev-boost"
12
- gem.authors = ["Roman Le Négrate","thedarkone"]
13
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
- end
15
- Jeweler::GemcutterTasks.new
16
- rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
- end
19
-
20
- require 'rake/testtask'
21
- Rake::TestTask.new(:test) do |test|
22
- test.libs << 'lib' << 'test'
23
- test.pattern = 'test/**/test_*.rb'
24
- test.verbose = true
25
- end
26
-
27
- begin
28
- require 'rcov/rcovtask'
29
- Rcov::RcovTask.new do |test|
30
- test.libs << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
33
- end
34
- rescue LoadError
35
- task :rcov do
36
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
- end
38
- end
39
-
40
- task :test => :check_dependencies
41
-
42
- task :default => :test
43
-
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
-
48
- rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "thing #{version}"
50
- rdoc.rdoc_files.include('README*')
51
- rdoc.rdoc_files.include('lib/**/*.rb')
52
- end
data/TODO.txt DELETED
@@ -1,2 +0,0 @@
1
- * Update ActiveRecord reflections for which the module passed as the :extend option has been unloaded.
2
- - update reference: MacroReflection#@options[:extend]
data/init.rb DELETED
@@ -1,3 +0,0 @@
1
- if !$rails_rake_task && (Rails.env.development? || (config.respond_to?(:soft_reload) && config.soft_reload))
2
- require 'rails_development_boost'
3
- end
@@ -1,116 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{rails-dev-boost}
8
- s.version = "0.1.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Roman Le N\303\251grate", "thedarkone"]
12
- s.date = %q{2010-11-11}
13
- s.description = %q{Make your Rails app 10 times faster in development mode}
14
- s.email = %q{roman.lenegrate@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".gitignore",
21
- "LICENSE",
22
- "README.markdown",
23
- "Rakefile",
24
- "TODO.txt",
25
- "VERSION",
26
- "init.rb",
27
- "lib/rails_development_boost.rb",
28
- "lib/rails_development_boost/dependencies_patch.rb",
29
- "lib/rails_development_boost/descendants_tracker_patch.rb",
30
- "lib/rails_development_boost/loaded_file.rb",
31
- "lib/rails_development_boost/reference_patch.rb",
32
- "lib/rails_development_boost/view_helpers_patch.rb",
33
- "rails-dev-boost.gemspec",
34
- "test/constants/.DS_Store",
35
- "test/constants/active_record/comment.rb",
36
- "test/constants/active_record/message.rb",
37
- "test/constants/active_record/other.rb",
38
- "test/constants/active_record/post.rb",
39
- "test/constants/deep_nesting/a.rb",
40
- "test/constants/deep_nesting/a/b.rb",
41
- "test/constants/deep_nesting/a/b/c.rb",
42
- "test/constants/deep_nesting/a/b/c/d.rb",
43
- "test/constants/double_removal/ns.rb",
44
- "test/constants/double_removal/ns/c.rb",
45
- "test/constants/double_removal/ns/m.rb",
46
- "test/constants/mixins/client.rb",
47
- "test/constants/mixins/mixin.rb",
48
- "test/constants/mixins/update/mixin.rb",
49
- "test/constants/nested_mixins/b.rb",
50
- "test/constants/nested_mixins/b/c.rb",
51
- "test/constants/nested_mixins/ma.rb",
52
- "test/constants/nested_mixins/ma/mb.rb",
53
- "test/constants/nested_mixins/ma/mb/mc.rb",
54
- "test/constants/nested_mixins/oa.rb",
55
- "test/constants/nested_mixins/oa/ob.rb",
56
- "test/constants/nested_mixins/oa/ob/oc.rb",
57
- "test/constants/single_removal/a.rb",
58
- "test/constants/single_removal/b.rb",
59
- "test/constants/singleton_mixins/a.rb",
60
- "test/constants/singleton_mixins/b.rb",
61
- "test/constants/subclass/a.rb",
62
- "test/constants/subclass/b.rb",
63
- "test/constants/subclass/c.rb",
64
- "test/rails_development_boost_test.rb",
65
- "test/stub_environment.rb"
66
- ]
67
- s.homepage = %q{http://github.com/thedarkone/rails-dev-boost}
68
- s.rdoc_options = ["--charset=UTF-8"]
69
- s.require_paths = ["lib"]
70
- s.rubygems_version = %q{1.3.7}
71
- s.summary = %q{Speeds up Rails development mode}
72
- s.test_files = [
73
- "test/constants/active_record/comment.rb",
74
- "test/constants/active_record/message.rb",
75
- "test/constants/active_record/other.rb",
76
- "test/constants/active_record/post.rb",
77
- "test/constants/deep_nesting/a/b/c/d.rb",
78
- "test/constants/deep_nesting/a/b/c.rb",
79
- "test/constants/deep_nesting/a/b.rb",
80
- "test/constants/deep_nesting/a.rb",
81
- "test/constants/double_removal/ns/c.rb",
82
- "test/constants/double_removal/ns/m.rb",
83
- "test/constants/double_removal/ns.rb",
84
- "test/constants/mixins/client.rb",
85
- "test/constants/mixins/mixin.rb",
86
- "test/constants/mixins/update/mixin.rb",
87
- "test/constants/nested_mixins/b/c.rb",
88
- "test/constants/nested_mixins/b.rb",
89
- "test/constants/nested_mixins/ma/mb/mc.rb",
90
- "test/constants/nested_mixins/ma/mb.rb",
91
- "test/constants/nested_mixins/ma.rb",
92
- "test/constants/nested_mixins/oa/ob/oc.rb",
93
- "test/constants/nested_mixins/oa/ob.rb",
94
- "test/constants/nested_mixins/oa.rb",
95
- "test/constants/single_removal/a.rb",
96
- "test/constants/single_removal/b.rb",
97
- "test/constants/singleton_mixins/a.rb",
98
- "test/constants/singleton_mixins/b.rb",
99
- "test/constants/subclass/a.rb",
100
- "test/constants/subclass/b.rb",
101
- "test/constants/subclass/c.rb",
102
- "test/rails_development_boost_test.rb",
103
- "test/stub_environment.rb"
104
- ]
105
-
106
- if s.respond_to? :specification_version then
107
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
108
- s.specification_version = 3
109
-
110
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
111
- else
112
- end
113
- else
114
- end
115
- end
116
-