fagin 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fagin.rb +26 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f1aca3358735598f0ab92cfd300cef33388cbfb270da2697793d89bbb85b4b7
|
4
|
+
data.tar.gz: f0e3dfd4ba73e37ff06399e43765dcdb2f23c401d8867e07ecc8705cc60bfca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4fa83afccb891d13ebe4050b8791bed7ef504b17e21353b780696f6830ac7501a1ea4e6b1028df4a84ef1c409747dad7a76301ad9c282f7a40acda16a2a781f
|
7
|
+
data.tar.gz: c2caf479c844d08978c5f04e4261c38665aecce5f65b89fdd863a189f0a0f1032aa9b617fb580adf2b083eaccc61ee11170662b68895d732aecc99d220fd61e9
|
data/lib/fagin.rb
CHANGED
@@ -9,18 +9,20 @@ class Fagin
|
|
9
9
|
%x(
|
10
10
|
\grep -EHos "^class +.+ *< *#{parent}" #{path}/*.rb
|
11
11
|
).each_line do |line|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
line.match(/^([^:]+\.rb).+class\s+(\S+)\s*</) do |match|
|
13
|
+
file = match[1]
|
14
|
+
next if (file.nil? || file.empty?)
|
15
|
+
clas = match[2]
|
16
|
+
next if (clas.nil? || clas.empty?)
|
17
|
+
begin
|
18
|
+
require_relative file
|
19
|
+
child = clas.split("::").inject(Object) do |m, c|
|
20
|
+
m.const_get(c)
|
21
|
+
end
|
22
|
+
children[clas] = child
|
23
|
+
rescue NameError
|
24
|
+
raise Error::UnknownChildClassError.new(clas)
|
20
25
|
end
|
21
|
-
children[clas] = child
|
22
|
-
rescue NameError
|
23
|
-
raise Error::UnknownChildClassError.new(clas)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -35,18 +37,20 @@ class Fagin
|
|
35
37
|
%x(
|
36
38
|
\grep -EHors "^class +.+ *< *#{parent}" #{path}
|
37
39
|
).each_line do |line|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
line.match(/^([^:]+\.rb).+class\s+(\S+)\s*</) do |match|
|
41
|
+
file = match[1]
|
42
|
+
next if (file.nil? || file.empty?)
|
43
|
+
clas = match[2]
|
44
|
+
next if (clas.nil? || clas.empty?)
|
45
|
+
begin
|
46
|
+
require_relative file
|
47
|
+
child = clas.split("::").inject(Object) do |m, c|
|
48
|
+
m.const_get(c)
|
49
|
+
end
|
50
|
+
children[clas] = child
|
51
|
+
rescue NameError
|
52
|
+
raise Error::UnknownChildClassError.new(clas)
|
46
53
|
end
|
47
|
-
children[clas] = child
|
48
|
-
rescue NameError
|
49
|
-
raise Error::UnknownChildClassError.new(clas)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|