class_loader 3.0.7 → 3.0.8

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.
@@ -2,6 +2,10 @@ require 'class_loader/support'
2
2
  require 'monitor'
3
3
 
4
4
  module ClassLoader
5
+ # Sometimes other libraries try to load some const to check if
6
+ # it exist, and we don't want ClassLoader automatically load it.
7
+ SKIP = %w(Test RSpec)
8
+
5
9
  @loaded_classes, @after_callbacks = {}, {}
6
10
  @monitor = Monitor.new
7
11
  class << self
@@ -31,6 +35,9 @@ module ClassLoader
31
35
  binding = namespace || Object
32
36
  hierarchy[class_file_name] = binding
33
37
 
38
+ # Skip some constants.
39
+ return nil if SKIP.any?{|c| class_name == c or class_name.include?("#{c}::")}
40
+
34
41
  # Trying to load class file, if its exist.
35
42
  loaded = begin
36
43
  require class_file_name
@@ -54,7 +61,7 @@ module ClassLoader
54
61
 
55
62
  # Checking that class defined in correct namespace, not the another one.
56
63
  unless binding.const_defined? const, false
57
- msg = "class name '#{class_name}' doesn't correspond to file name '#{class_file_name}'!"
64
+ msg = "class name #{class_name} doesn't correspond to file name '#{class_file_name}'!"
58
65
  raise NameError, msg, filter_backtrace(caller)
59
66
  end
60
67
 
@@ -71,7 +71,7 @@ describe 'Autoloading classes' do
71
71
 
72
72
  it "should recognize infinity loop" do
73
73
  with_load_path "#{spec_dir}/infinity_loop" do
74
- -> {SomeClass}.should raise_error(/class name 'SomeClass' doesn't correspond to file name 'some_class'/)
74
+ -> {SomeClass}.should raise_error(/class name SomeClass doesn't correspond to file name 'some_class'/)
75
75
  end
76
76
  end
77
77
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: class_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-31 00:00:00.000000000Z
12
+ date: 2011-12-19 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -23,7 +23,6 @@ files:
23
23
  - lib/class_loader/support.rb
24
24
  - lib/class_loader/watcher.rb
25
25
  - lib/class_loader.rb
26
- - spec/another_spec.rb
27
26
  - spec/class_loader_spec/after/some_class.rb
28
27
  - spec/class_loader_spec/anonymous_class/some_namespace/some_class.rb
29
28
  - spec/class_loader_spec/another_namespace/some_namespace/namespace_a.rb
@@ -63,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
62
  version: '0'
64
63
  requirements: []
65
64
  rubyforge_project:
66
- rubygems_version: 1.8.6
65
+ rubygems_version: 1.8.10
67
66
  signing_key:
68
67
  specification_version: 3
69
68
  summary: Automatically finds, loads and reloads classes
@@ -1,15 +0,0 @@
1
- require 'rspec_ext'
2
- require "class_loader"
3
-
4
- describe 'Autoloading classes' do
5
- it do
6
- with_load_path "/Users/alex/projects/class_loader/spec/class_loader_spec/after" do
7
- exp = mock
8
- exp.should_receive :callback_fired
9
- ClassLoader.after 'SomeClass' do |klass|
10
- exp.callback_fired
11
- end
12
- SomeClass
13
- end
14
- end
15
- end