magicloader 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/magic_loader.rb CHANGED
@@ -92,10 +92,15 @@ module MagicLoader
92
92
  # previously caused NameErrors until they've all been loaded or no new
93
93
  # files can be loaded, indicating unresolvable dependencies.
94
94
  files.each do |file|
95
+ original_constants = Module.constants
96
+
95
97
  begin
96
98
  require file
97
99
  load_order << file
98
100
  rescue NameError => ex
101
+ new_constants = Module.constants - original_constants
102
+ new_constants.each { |name| Object.send(:remove_const, name) }
103
+
99
104
  failed << file
100
105
  first_name_error ||= ex
101
106
  end
@@ -92,7 +92,7 @@ module MagicLoader
92
92
  data = File.read path
93
93
 
94
94
  # Remove trailing whitespace from the file so it doesn't grow
95
- data.sub!(/\w+$/m, '')
95
+ data.sub!(/\s+$/m, '')
96
96
 
97
97
  magic_matches = data.match(MAGIC_REGEXP)
98
98
  case magic_matches
data/magicloader.gemspec CHANGED
@@ -7,7 +7,7 @@ GEMSPEC = Gem::Specification.new do |s|
7
7
  Painless code dependency management. Think Bundler, but for managing file load
8
8
  ordering dependencies.
9
9
  EOD
10
- s.version = "0.9.1"
10
+ s.version = "0.9.2"
11
11
  s.authors = "Tony Arcieri"
12
12
  s.email = "bascule@gmail.com"
13
13
  s.homepage = "http://github.com/tarcieri/MagicLoader"
@@ -0,0 +1,3 @@
1
+ module Outer
2
+ class Y < Z; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Outer
2
+ class Z < Y; end
3
+ end
@@ -17,6 +17,14 @@ describe MagicLoader do
17
17
  MagicLoader.require_all File.expand_path('../fixtures/unresolvable/*.rb', __FILE__)
18
18
  end.should raise_error(NameError)
19
19
  end
20
+
21
+ it "cleans up after constants if dependencies can't be resolved" do
22
+ proc do
23
+ MagicLoader.require_all File.expand_path('../fixtures/circular/*.rb', __FILE__)
24
+ end.should raise_error(NameError)
25
+
26
+ defined?(Outer).should be_false
27
+ end
20
28
  end
21
29
 
22
30
  describe "syntactic sugar" do
data/spec/tmp/example.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # OMFG IMPORTANT CRAP DON'T DELETE THIS
2
-
3
2
  #-----BEGIN MAGICLOADER MAGIC BLOCK-----
4
3
  # Automagically generated by MagicLoader. Editing may
5
4
  # result in bad juju. Edit at your own risk!
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magicloader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 1
10
- version: 0.9.1
9
+ - 2
10
+ version: 0.9.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Arcieri
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-03 00:00:00 -06:00
18
+ date: 2010-10-25 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -32,6 +32,8 @@ extra_rdoc_files:
32
32
  files:
33
33
  - lib/magic_loader/tasks.rb
34
34
  - lib/magic_loader.rb
35
+ - spec/fixtures/circular/y.rb
36
+ - spec/fixtures/circular/z.rb
35
37
  - spec/fixtures/resolvable/a.rb
36
38
  - spec/fixtures/resolvable/b.rb
37
39
  - spec/fixtures/resolvable/c.rb