fagin 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fagin.rb +30 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 341dd1040e22d1cd15e631a07e8a4d513ce9cacf337de9497e95d194cd6375b2
|
4
|
+
data.tar.gz: 96ba74cbd13ee8248e3cadda9fe3aa3ea0bb904463f8f5b0968f9087ffc44f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d752c5e24b90cfeb21e1bf40f107612fd680ad6762363a7652b8542d054f132b145c3de685cdcaa3ff104f27b058842cf9490ab75467f1e2d4afafafede99ac
|
7
|
+
data.tar.gz: '019a92d36b3d2f3d4284e7c7a876cf4baa30b8c0287716b0dbb09af5f28738cc13f944d8b6fc120c209c2ccc666f7db13b908843f0ee111073851b2edf332661'
|
data/lib/fagin.rb
CHANGED
@@ -4,17 +4,43 @@ class Fagin
|
|
4
4
|
def self.find_children(parent, dir)
|
5
5
|
children = Hash.new
|
6
6
|
path = Pathname.new(dir).expand_path
|
7
|
+
return children if (!path.exist?)
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
%x(
|
10
|
+
\grep -EHos "^class +.+ *< *#{parent}" #{path}/*.rb
|
11
|
+
).each_line do |line|
|
12
|
+
clas = line.match(/class\s+(\S+)\s*</)[1]
|
13
|
+
next if (clas.nil? || clas.empty?)
|
14
|
+
file = line.match(/^([^:]+\.rb)/)[1]
|
15
|
+
next if (file.nil? || file.empty?)
|
16
|
+
begin
|
17
|
+
require_relative file
|
18
|
+
child = clas.split("::").inject(Object) do |m, c|
|
19
|
+
m.const_get(c)
|
20
|
+
end
|
21
|
+
children[clas] = child
|
22
|
+
rescue NameError
|
23
|
+
raise Error::UnknownChildClassError.new(clas)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
return children
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.find_children_recursively(parent, dir)
|
31
|
+
children = Hash.new
|
32
|
+
path = Pathname.new(dir).expand_path
|
33
|
+
return children if (!path.exist?)
|
10
34
|
|
11
35
|
%x(
|
12
|
-
\grep -
|
36
|
+
\grep -EHors "^class +.+ *< *#{parent}" #{path}
|
13
37
|
).each_line do |line|
|
14
38
|
clas = line.match(/class\s+(\S+)\s*</)[1]
|
15
39
|
next if (clas.nil? || clas.empty?)
|
40
|
+
file = line.match(/^([^:]+\.rb)/)[1]
|
41
|
+
next if (file.nil? || file.empty?)
|
16
42
|
begin
|
17
|
-
require_relative
|
43
|
+
require_relative file
|
18
44
|
child = clas.split("::").inject(Object) do |m, c|
|
19
45
|
m.const_get(c)
|
20
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fagin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|