require_all 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +20 -13
- data/LICENSE +58 -58
- data/README.textile +129 -83
- data/Rakefile +11 -11
- data/lib/require_all.rb +277 -125
- data/require_all.gemspec +22 -26
- data/spec/autoload_shared.rb +78 -0
- data/spec/autoload_spec.rb +59 -0
- data/spec/fixtures/autoloaded/module1/a.rb +6 -0
- data/spec/fixtures/autoloaded/module2/longer_name.rb +6 -0
- data/spec/fixtures/autoloaded/module2/module3/b.rb +8 -0
- data/spec/fixtures/autoloaded/with_wrong_module.rb +4 -0
- data/spec/fixtures/autoloaded_rel/modules/module1/first.rb +6 -0
- data/spec/fixtures/autoloaded_rel/modules/module2/second.rb +6 -0
- data/spec/fixtures/autoloaded_rel/modules/zero.rb +6 -0
- data/spec/fixtures/relative/a.rb +1 -1
- data/spec/fixtures/relative/b/b.rb +4 -4
- data/spec/fixtures/relative/c/c.rb +1 -1
- data/spec/fixtures/relative/d/d.rb +8 -0
- data/spec/fixtures/resolvable/c.rb +5 -1
- data/spec/load_spec.rb +50 -0
- data/spec/require_shared.rb +68 -0
- data/spec/require_spec.rb +39 -0
- data/spec/spec_helper.rb +29 -0
- metadata +35 -9
- data/spec/require_all_spec.rb +0 -57
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../lib/require_all.rb'
|
2
|
+
|
3
|
+
module SpecHelper
|
4
|
+
def unload_all
|
5
|
+
%w{A B C D WrongModule Autoloaded Modules
|
6
|
+
RelativeA RelativeB RelativeC RelativeD}.each do |const|
|
7
|
+
Object.send(:remove_const, const) rescue nil
|
8
|
+
end
|
9
|
+
$LOADED_FEATURES.delete_if {|f| f =~ /autoloaded|relative|resolvable/}
|
10
|
+
end
|
11
|
+
|
12
|
+
def loaded?(*klazzes)
|
13
|
+
klazzes.all? {|klazz| Object.class_eval(klazz) rescue nil}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Spec::Runner.configure do |config|
|
18
|
+
config.include(SpecHelper)
|
19
|
+
|
20
|
+
config.before(:each) do
|
21
|
+
unload_all
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module Spec
|
26
|
+
class ExampleGroup
|
27
|
+
subject {self}
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: require_all
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
13
|
+
- Jarmo Pertman
|
7
14
|
- Tony Arcieri
|
8
15
|
autorequire:
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
19
|
+
date: 2010-09-14 00:00:00 +03:00
|
13
20
|
default_executable:
|
14
21
|
dependencies: []
|
15
22
|
|
16
23
|
description:
|
17
|
-
email:
|
24
|
+
email: jarmo.p@gmail.com
|
18
25
|
executables: []
|
19
26
|
|
20
27
|
extensions: []
|
@@ -25,9 +32,19 @@ extra_rdoc_files:
|
|
25
32
|
- CHANGES
|
26
33
|
files:
|
27
34
|
- lib/require_all.rb
|
35
|
+
- spec/autoload_shared.rb
|
36
|
+
- spec/autoload_spec.rb
|
37
|
+
- spec/fixtures/autoloaded/module1/a.rb
|
38
|
+
- spec/fixtures/autoloaded/module2/longer_name.rb
|
39
|
+
- spec/fixtures/autoloaded/module2/module3/b.rb
|
40
|
+
- spec/fixtures/autoloaded/with_wrong_module.rb
|
41
|
+
- spec/fixtures/autoloaded_rel/modules/module1/first.rb
|
42
|
+
- spec/fixtures/autoloaded_rel/modules/module2/second.rb
|
43
|
+
- spec/fixtures/autoloaded_rel/modules/zero.rb
|
28
44
|
- spec/fixtures/relative/a.rb
|
29
45
|
- spec/fixtures/relative/b/b.rb
|
30
46
|
- spec/fixtures/relative/c/c.rb
|
47
|
+
- spec/fixtures/relative/d/d.rb
|
31
48
|
- spec/fixtures/resolvable/a.rb
|
32
49
|
- spec/fixtures/resolvable/b.rb
|
33
50
|
- spec/fixtures/resolvable/c.rb
|
@@ -36,14 +53,17 @@ files:
|
|
36
53
|
- spec/fixtures/unresolvable/b.rb
|
37
54
|
- spec/fixtures/unresolvable/c.rb
|
38
55
|
- spec/fixtures/unresolvable/d.rb
|
39
|
-
- spec/
|
56
|
+
- spec/load_spec.rb
|
57
|
+
- spec/require_shared.rb
|
58
|
+
- spec/require_spec.rb
|
59
|
+
- spec/spec_helper.rb
|
40
60
|
- Rakefile
|
41
61
|
- require_all.gemspec
|
42
62
|
- LICENSE
|
43
63
|
- README.textile
|
44
64
|
- CHANGES
|
45
65
|
has_rdoc: true
|
46
|
-
homepage: http://github.com/
|
66
|
+
homepage: http://github.com/jarmo/require_all
|
47
67
|
licenses: []
|
48
68
|
|
49
69
|
post_install_message:
|
@@ -56,21 +76,27 @@ rdoc_options:
|
|
56
76
|
require_paths:
|
57
77
|
- lib
|
58
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
59
80
|
requirements:
|
60
81
|
- - ">="
|
61
82
|
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
62
86
|
version: "0"
|
63
|
-
version:
|
64
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
65
89
|
requirements:
|
66
90
|
- - ">="
|
67
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
93
|
+
segments:
|
94
|
+
- 0
|
68
95
|
version: "0"
|
69
|
-
version:
|
70
96
|
requirements: []
|
71
97
|
|
72
|
-
rubyforge_project:
|
73
|
-
rubygems_version: 1.3.
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.3.7
|
74
100
|
signing_key:
|
75
101
|
specification_version: 3
|
76
102
|
summary: A wonderfully simple way to load your code
|
data/spec/require_all_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/require_all.rb'
|
2
|
-
|
3
|
-
describe "require_all" do
|
4
|
-
describe "dependency resolution" do
|
5
|
-
it "handles load ordering when dependencies are resolvable" do
|
6
|
-
require_all File.dirname(__FILE__) + '/fixtures/resolvable/*.rb'
|
7
|
-
|
8
|
-
defined?(A).should == "constant"
|
9
|
-
defined?(B).should == "constant"
|
10
|
-
defined?(C).should == "constant"
|
11
|
-
defined?(D).should == "constant"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "raises NameError if dependencies can't be resolved" do
|
15
|
-
proc do
|
16
|
-
require_all File.dirname(__FILE__) + '/fixtures/unresolvable/*.rb'
|
17
|
-
end.should raise_error(NameError)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "syntactic sugar" do
|
22
|
-
before :each do
|
23
|
-
@base_dir = File.dirname(__FILE__) + '/fixtures/resolvable'
|
24
|
-
@file_list = ['b.rb', 'c.rb', 'a.rb', 'd.rb'].map { |f| "#{@base_dir}/#{f}" }
|
25
|
-
end
|
26
|
-
|
27
|
-
it "works like a drop-in require replacement" do
|
28
|
-
require_all(@base_dir + '/c').should be_true
|
29
|
-
end
|
30
|
-
|
31
|
-
it "accepts lists of files" do
|
32
|
-
require_all(@file_list).should be_true
|
33
|
-
end
|
34
|
-
|
35
|
-
it "is totally cool with a splatted list of arguments" do
|
36
|
-
require_all(*@file_list).should be_true
|
37
|
-
end
|
38
|
-
|
39
|
-
it "will load all .rb files under a directory without a trailing slash" do
|
40
|
-
require_all(@base_dir).should be_true
|
41
|
-
end
|
42
|
-
|
43
|
-
it "will load all .rb files under a directory with a trailing slash" do
|
44
|
-
require_all("#{@base_dir}/").should be_true
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "require_rel" do
|
50
|
-
it "provides require_all functionality relative to the current file" do
|
51
|
-
require File.dirname(__FILE__) + '/fixtures/relative/b/b'
|
52
|
-
|
53
|
-
defined?(RelativeA).should == "constant"
|
54
|
-
defined?(RelativeB).should == "constant"
|
55
|
-
defined?(RelativeC).should == "constant"
|
56
|
-
end
|
57
|
-
end
|