polyglot 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/polyglot.rb +19 -6
- data/lib/polyglot/version.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/lib/polyglot.rb
CHANGED
@@ -4,8 +4,15 @@ require 'pathname'
|
|
4
4
|
module Polyglot
|
5
5
|
@registrations ||= {} # Guard against reloading
|
6
6
|
@loaded ||= {}
|
7
|
-
|
8
|
-
class
|
7
|
+
|
8
|
+
class NestedLoadError < LoadError
|
9
|
+
def initialize le
|
10
|
+
@le = le
|
11
|
+
end
|
12
|
+
def reraise
|
13
|
+
raise @le
|
14
|
+
end
|
15
|
+
end
|
9
16
|
|
10
17
|
def self.register(extension, klass)
|
11
18
|
extension = [extension] unless Enumerable === extension
|
@@ -36,14 +43,18 @@ module Polyglot
|
|
36
43
|
begin
|
37
44
|
source_file, loader = Polyglot.find(file, *a[1..-1], &b)
|
38
45
|
if (loader)
|
39
|
-
|
40
|
-
|
46
|
+
begin
|
47
|
+
loader.load(source_file)
|
48
|
+
@loaded[file] = true
|
49
|
+
rescue LoadError => e
|
50
|
+
raise Polyglot::NestedLoadError.new(e)
|
51
|
+
end
|
41
52
|
else
|
42
53
|
msg = "Failed to load #{file} using extensions #{(@registrations.keys+["rb"]).sort*", "}"
|
43
54
|
if defined?(MissingSourceFile)
|
44
55
|
raise MissingSourceFile.new(msg, file)
|
45
56
|
else
|
46
|
-
raise
|
57
|
+
raise LoadError.new(msg)
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
@@ -58,7 +69,9 @@ module Kernel
|
|
58
69
|
rescue LoadError => load_error
|
59
70
|
begin
|
60
71
|
Polyglot.load(*a, &b)
|
61
|
-
rescue Polyglot::
|
72
|
+
rescue Polyglot::NestedLoadError => e
|
73
|
+
e.reraise
|
74
|
+
rescue LoadError
|
62
75
|
# Raise the original exception, possibly a MissingSourceFile with a path
|
63
76
|
raise load_error
|
64
77
|
end
|
data/lib/polyglot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyglot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clifford Heath
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-18 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|