class_loader 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. data/Rakefile +1 -1
  2. data/spec/{class_loader_spec_data → class_loader_spec}/anonymous_class/AnonymousSpec/ClassInsideOfAnonymousClass.rb +0 -0
  3. data/spec/{class_loader_spec_data → class_loader_spec}/another_namespace/AnotherNamespace/NamespaceA.rb +0 -0
  4. data/spec/{class_loader_spec_data → class_loader_spec}/another_namespace/AnotherNamespace/NamespaceB.rb +0 -0
  5. data/spec/{class_loader_spec_data → class_loader_spec}/basic/BasicSpec/SomeNamespace/SomeClass.rb +0 -0
  6. data/spec/{class_loader_spec_data → class_loader_spec}/basic/BasicSpec.rb +0 -0
  7. data/spec/{class_loader_spec_data → class_loader_spec}/infinity_loop/InfinityLoop.rb +0 -0
  8. data/spec/{class_loader_spec_data → class_loader_spec}/namespace_type_resolving/NamespaceIsAlreadyDefinedAsClass/SomeClass.rb +0 -0
  9. data/spec/{class_loader_spec_data → class_loader_spec}/namespace_type_resolving/NamespaceTypeResolving/SomeClass.rb +0 -0
  10. data/spec/{class_loader_spec_data → class_loader_spec}/namespace_type_resolving/NamespaceTypeResolving.rb +0 -0
  11. data/spec/{class_loader_spec_data → class_loader_spec}/only_once/OnlyOnceSpec.rb +0 -0
  12. data/spec/{class_loader_spec_data → class_loader_spec}/preloading/PreloadingSpec.rb +0 -0
  13. data/spec/{class_loader_spec_data → class_loader_spec}/underscored/underscored_namespace/underscored_class.rb +0 -0
  14. data/spec/{class_loader_spec_data → class_loader_spec}/unload_old_class/UnloadOldClass.rb +0 -0
  15. data/spec/class_loader_spec.rb +13 -17
  16. data/spec/{file_system_adapter_spec_data → file_system_adapter_spec}/common/SomeNamespace/SomeClass.rb +0 -0
  17. data/spec/{file_system_adapter_spec_data → file_system_adapter_spec}/multiple_class_paths/path_a/ClassInPathA.rb +0 -0
  18. data/spec/{file_system_adapter_spec_data → file_system_adapter_spec}/multiple_class_paths/path_b/ClassInPathB.rb +0 -0
  19. data/spec/{file_system_adapter_spec_data → file_system_adapter_spec}/shouldnt_mess/CamelCaseClass.rb +0 -0
  20. data/spec/{file_system_adapter_spec_data → file_system_adapter_spec}/shouldnt_mess/underscored_class.rb +0 -0
  21. data/spec/file_system_adapter_spec.rb +16 -22
  22. metadata +22 -22
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake_ext'
2
2
 
3
3
  project(
4
4
  :name => "class_loader",
5
- :version => "0.3.8",
5
+ :version => "0.3.9",
6
6
  :summary => "Automatically finds and loads classes",
7
7
 
8
8
  :author => "Alexey Petrushin",
@@ -2,13 +2,9 @@ require 'rspec_ext'
2
2
  require "class_loader"
3
3
 
4
4
  describe ClassLoader do
5
- before :all do
6
- @dir = prepare_spec_data __FILE__
7
- end
5
+ with_tmp_spec_dir
8
6
 
9
7
  after :all do
10
- clean_spec_data __FILE__
11
-
12
8
  remove_constants %w(
13
9
  BasicSpec
14
10
  OnlyOnceSpec
@@ -28,14 +24,14 @@ describe ClassLoader do
28
24
  end
29
25
 
30
26
  it "should load classes from class path" do
31
- autoload_dir "#{@dir}/basic"
27
+ autoload_dir "#{spec_dir}/basic"
32
28
 
33
29
  BasicSpec
34
30
  BasicSpec::SomeNamespace::SomeClass
35
31
  end
36
32
 
37
33
  it "should load classes only once" do
38
- autoload_dir "#{@dir}/only_once"
34
+ autoload_dir "#{spec_dir}/only_once"
39
35
 
40
36
  check = mock
41
37
  check.should_receive(:loaded).once
@@ -49,7 +45,7 @@ describe ClassLoader do
49
45
  end
50
46
 
51
47
  it "should resolve is namespace a class or module" do
52
- autoload_dir "#{@dir}/namespace_type_resolving"
48
+ autoload_dir "#{spec_dir}/namespace_type_resolving"
53
49
 
54
50
  NamespaceTypeResolving.class.should == Class
55
51
  NamespaceTypeResolving::SomeClass
@@ -59,13 +55,13 @@ describe ClassLoader do
59
55
  end
60
56
 
61
57
  it "should recognize infinity loop" do
62
- autoload_dir "#{@dir}/infinity_loop"
58
+ autoload_dir "#{spec_dir}/infinity_loop"
63
59
 
64
60
  lambda{InfinityLoop}.should raise_error(/Class Name .+ doesn't correspond to File Name/)
65
61
  end
66
62
 
67
63
  it "should correctly works inside of anonymous class" do
68
- autoload_dir "#{@dir}/anonymous_class"
64
+ autoload_dir "#{spec_dir}/anonymous_class"
69
65
 
70
66
  module ::AnonymousSpec
71
67
  class << self
@@ -79,7 +75,7 @@ describe ClassLoader do
79
75
  end
80
76
 
81
77
  it "should raise exception if class defined in another namespace" do
82
- autoload_dir "#{@dir}/another_namespace"
78
+ autoload_dir "#{spec_dir}/another_namespace"
83
79
 
84
80
  AnotherNamespace::NamespaceA
85
81
  ClassLoader.error_on_defined_constant = true
@@ -90,9 +86,9 @@ describe ClassLoader do
90
86
 
91
87
  describe "reloading" do
92
88
  it "should reload class files" do
93
- spec_dir = "#{@dir}/class_reloading"
94
- fname = "#{spec_dir}/ClassReloadingSpec.rb"
95
- autoload_dir spec_dir
89
+ class_reloading_dir = "#{spec_dir}/class_reloading"
90
+ fname = "#{class_reloading_dir}/ClassReloadingSpec.rb"
91
+ autoload_dir class_reloading_dir
96
92
 
97
93
  code = <<-RUBY
98
94
  class ClassReloadingSpec
@@ -118,7 +114,7 @@ RUBY
118
114
 
119
115
  # Outdated
120
116
  # it "should unload old classes before reloading" do
121
- # autoload_dir "#{@dir}/unload_old_class"
117
+ # autoload_dir "#{spec_dir}/unload_old_class"
122
118
  # UnloadOldClass.instance_variable_set "@value", :value
123
119
  # ClassLoader.reload_class(UnloadOldClass.name)
124
120
  # UnloadOldClass.instance_variable_get("@value").should == nil
@@ -126,14 +122,14 @@ RUBY
126
122
  end
127
123
 
128
124
  it "should be able to preload all classes in production" do
129
- autoload_dir "#{@dir}/preloading"
125
+ autoload_dir "#{spec_dir}/preloading"
130
126
  Object.const_defined?(:PreloadingSpec).should be_false
131
127
  ClassLoader.preload!
132
128
  Object.const_defined?(:PreloadingSpec).should be_true
133
129
  end
134
130
 
135
131
  it "underscored smoke test" do
136
- autoload_dir "#{@dir}/underscored"
132
+ autoload_dir "#{spec_dir}/underscored"
137
133
 
138
134
  UnderscoredNamespace::UnderscoredClass
139
135
  end
@@ -2,9 +2,7 @@ require "rspec_ext"
2
2
  require "class_loader"
3
3
 
4
4
  describe ClassLoader::FileSystemAdapter do
5
- before :all do
6
- @dir = prepare_spec_data __FILE__
7
- end
5
+ with_tmp_spec_dir
8
6
 
9
7
  before :each do
10
8
  @fs_adapter = ClassLoader::FileSystemAdapter.new(ClassLoader::CamelCaseTranslator)
@@ -13,15 +11,11 @@ describe ClassLoader::FileSystemAdapter do
13
11
  @adapter = ClassLoader::ChainedAdapter.new
14
12
  @adapter.adapters << @fs_adapter
15
13
 
16
- @adapter.add_path "#{@dir}/common"
17
- end
18
-
19
- after :all do
20
- clean_spec_data __FILE__
14
+ @adapter.add_path "#{spec_dir}/common"
21
15
  end
22
16
 
23
17
  def write_file path, klass
24
- File.open("#{@dir}/#{path}", 'w'){|f| f.write "class #{klass}; end"}
18
+ File.open("#{spec_dir}/#{path}", 'w'){|f| f.write "class #{klass}; end"}
25
19
  end
26
20
 
27
21
  it "exist?" do
@@ -31,8 +25,8 @@ describe ClassLoader::FileSystemAdapter do
31
25
  end
32
26
 
33
27
  it "should works with multiple class paths" do
34
- @adapter.add_path "#{@dir}/multiple_class_paths/path_a"
35
- @adapter.add_path "#{@dir}/multiple_class_paths/path_b"
28
+ @adapter.add_path "#{spec_dir}/multiple_class_paths/path_a"
29
+ @adapter.add_path "#{spec_dir}/multiple_class_paths/path_b"
36
30
 
37
31
  @adapter.exist?("ClassInPathA").should be_true
38
32
  @adapter.exist?("ClassInPathB").should be_true
@@ -48,15 +42,15 @@ describe ClassLoader::FileSystemAdapter do
48
42
  end
49
43
 
50
44
  it "to_class_name" do
51
- @adapter.to_class_name("#{@dir}/non_existing_path").should be_nil
52
- @adapter.to_class_name("#{@dir}/common/SomeNamespace").should == "SomeNamespace"
53
- @adapter.to_class_name("#{@dir}/common/SomeNamespace/SomeClass").should == "SomeNamespace::SomeClass"
45
+ @adapter.to_class_name("#{spec_dir}/non_existing_path").should be_nil
46
+ @adapter.to_class_name("#{spec_dir}/common/SomeNamespace").should == "SomeNamespace"
47
+ @adapter.to_class_name("#{spec_dir}/common/SomeNamespace/SomeClass").should == "SomeNamespace::SomeClass"
54
48
  end
55
49
 
56
50
  it "shouldn't allow to add path twice" do
57
51
  @adapter.clear
58
- @adapter.add_path "#{@dir}/common"
59
- lambda{@adapter.add_path "#{@dir}/common"}.should raise_error(/already added/)
52
+ @adapter.add_path "#{spec_dir}/common"
53
+ lambda{@adapter.add_path "#{spec_dir}/common"}.should raise_error(/already added/)
60
54
  end
61
55
 
62
56
  describe "file watching" do
@@ -67,7 +61,7 @@ describe ClassLoader::FileSystemAdapter do
67
61
  end
68
62
 
69
63
  it "each_changed_class shouldn't affect paths not specified for watching" do
70
- @adapter.add_path "#{@dir}/search_only_watched", false
64
+ @adapter.add_path "#{spec_dir}/search_only_watched", false
71
65
  changed_classes.should == []
72
66
 
73
67
  sleep(1) && write_file("watching/SomeClass.rb", "SomeClass")
@@ -75,7 +69,7 @@ describe ClassLoader::FileSystemAdapter do
75
69
  end
76
70
 
77
71
  it "each_changed_class" do
78
- @adapter.add_path "#{@dir}/watching", true
72
+ @adapter.add_path "#{spec_dir}/watching", true
79
73
 
80
74
  changed_classes.should == []
81
75
 
@@ -90,12 +84,12 @@ describe ClassLoader::FileSystemAdapter do
90
84
  describe "Underscored shouldn't mess with CamelCase" do
91
85
  before :each do
92
86
  @camel_case_adapter = ClassLoader::FileSystemAdapter.new(ClassLoader::CamelCaseTranslator)
93
- @camel_case_adapter.add_path "#{@dir}/shouldnt_mess", true
94
- @camel_case_file_path = "#{@dir}/shouldnt_mess/CamelCaseClass.rb"
87
+ @camel_case_adapter.add_path "#{spec_dir}/shouldnt_mess", true
88
+ @camel_case_file_path = "#{spec_dir}/shouldnt_mess/CamelCaseClass.rb"
95
89
 
96
90
  @underscored_adapter = ClassLoader::FileSystemAdapter.new(ClassLoader::UnderscoredTranslator)
97
- @underscored_adapter.add_path "#{@dir}/shouldnt_mess", true
98
- @underscored_file_path = "#{@dir}/shouldnt_mess/underscored_class.rb"
91
+ @underscored_adapter.add_path "#{spec_dir}/shouldnt_mess", true
92
+ @underscored_file_path = "#{spec_dir}/shouldnt_mess/underscored_class.rb"
99
93
  end
100
94
 
101
95
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: class_loader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 8
10
- version: 0.3.8
9
+ - 9
10
+ version: 0.3.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alexey Petrushin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-22 00:00:00 +04:00
18
+ date: 2010-10-25 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -37,26 +37,26 @@ files:
37
37
  - lib/class_loader/file_system_adapter.rb
38
38
  - lib/class_loader/support.rb
39
39
  - lib/class_loader.rb
40
+ - spec/class_loader_spec/anonymous_class/AnonymousSpec/ClassInsideOfAnonymousClass.rb
41
+ - spec/class_loader_spec/another_namespace/AnotherNamespace/NamespaceA.rb
42
+ - spec/class_loader_spec/another_namespace/AnotherNamespace/NamespaceB.rb
43
+ - spec/class_loader_spec/basic/BasicSpec/SomeNamespace/SomeClass.rb
44
+ - spec/class_loader_spec/basic/BasicSpec.rb
45
+ - spec/class_loader_spec/infinity_loop/InfinityLoop.rb
46
+ - spec/class_loader_spec/namespace_type_resolving/NamespaceIsAlreadyDefinedAsClass/SomeClass.rb
47
+ - spec/class_loader_spec/namespace_type_resolving/NamespaceTypeResolving/SomeClass.rb
48
+ - spec/class_loader_spec/namespace_type_resolving/NamespaceTypeResolving.rb
49
+ - spec/class_loader_spec/only_once/OnlyOnceSpec.rb
50
+ - spec/class_loader_spec/preloading/PreloadingSpec.rb
51
+ - spec/class_loader_spec/underscored/underscored_namespace/underscored_class.rb
52
+ - spec/class_loader_spec/unload_old_class/UnloadOldClass.rb
40
53
  - spec/class_loader_spec.rb
41
- - spec/class_loader_spec_data/anonymous_class/AnonymousSpec/ClassInsideOfAnonymousClass.rb
42
- - spec/class_loader_spec_data/another_namespace/AnotherNamespace/NamespaceA.rb
43
- - spec/class_loader_spec_data/another_namespace/AnotherNamespace/NamespaceB.rb
44
- - spec/class_loader_spec_data/basic/BasicSpec/SomeNamespace/SomeClass.rb
45
- - spec/class_loader_spec_data/basic/BasicSpec.rb
46
- - spec/class_loader_spec_data/infinity_loop/InfinityLoop.rb
47
- - spec/class_loader_spec_data/namespace_type_resolving/NamespaceIsAlreadyDefinedAsClass/SomeClass.rb
48
- - spec/class_loader_spec_data/namespace_type_resolving/NamespaceTypeResolving/SomeClass.rb
49
- - spec/class_loader_spec_data/namespace_type_resolving/NamespaceTypeResolving.rb
50
- - spec/class_loader_spec_data/only_once/OnlyOnceSpec.rb
51
- - spec/class_loader_spec_data/preloading/PreloadingSpec.rb
52
- - spec/class_loader_spec_data/underscored/underscored_namespace/underscored_class.rb
53
- - spec/class_loader_spec_data/unload_old_class/UnloadOldClass.rb
54
+ - spec/file_system_adapter_spec/common/SomeNamespace/SomeClass.rb
55
+ - spec/file_system_adapter_spec/multiple_class_paths/path_a/ClassInPathA.rb
56
+ - spec/file_system_adapter_spec/multiple_class_paths/path_b/ClassInPathB.rb
57
+ - spec/file_system_adapter_spec/shouldnt_mess/CamelCaseClass.rb
58
+ - spec/file_system_adapter_spec/shouldnt_mess/underscored_class.rb
54
59
  - spec/file_system_adapter_spec.rb
55
- - spec/file_system_adapter_spec_data/common/SomeNamespace/SomeClass.rb
56
- - spec/file_system_adapter_spec_data/multiple_class_paths/path_a/ClassInPathA.rb
57
- - spec/file_system_adapter_spec_data/multiple_class_paths/path_b/ClassInPathB.rb
58
- - spec/file_system_adapter_spec_data/shouldnt_mess/CamelCaseClass.rb
59
- - spec/file_system_adapter_spec_data/shouldnt_mess/underscored_class.rb
60
60
  - spec/translators_spec.rb
61
61
  has_rdoc: true
62
62
  homepage: http://github.com/alexeypetrushin/class_loader