fagin 1.1.2 → 1.1.3
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 +7 -29
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ec627f1c90e140159c4542b062be31ab8a8830cd717d8779713dec262232190
|
4
|
+
data.tar.gz: ab6c12883739989c0be041efd35140aa9762d3bf1773414efee64a4299e7d16d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a714340c867111b18a04c7afc2ee8eef242f9a5d673d1ffc9c447e2922cec61355c74ddb5b56bcba612d1f09ea31b1f72d00e1331f1c5d1698e7445cc88881
|
7
|
+
data.tar.gz: 30e35bf695755e4971778d285577ab7820787196d69d190907c916cdf02e37a08741e75bc0154d59981623d38f9ff90c13eb423e8b41647edffae171281538e1
|
data/lib/fagin.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
require "pathname"
|
2
2
|
|
3
3
|
class Fagin
|
4
|
-
def self.find_children(parent, dir)
|
4
|
+
def self.find_children(parent, dir, recursive = false)
|
5
5
|
children = Hash.new
|
6
6
|
path = Pathname.new(dir).expand_path
|
7
7
|
return children if (!path.exist?)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
pattern = "\"^class +[^ ]+ *< *#{parent}\""
|
10
|
+
cmd = "grep -EHors #{pattern} #{path}"
|
11
|
+
cmd += "/*.rb" if (!recursive)
|
12
|
+
|
13
|
+
%x(#{cmd}).each_line do |line|
|
12
14
|
line.match(/^([^:]+\.rb).+class\s+(\S+)\s*</) do |match|
|
13
15
|
file = match[1]
|
14
16
|
next if (file.nil? || file.empty?)
|
@@ -30,31 +32,7 @@ class Fagin
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def self.find_children_recursively(parent, dir)
|
33
|
-
|
34
|
-
path = Pathname.new(dir).expand_path
|
35
|
-
return children if (!path.exist?)
|
36
|
-
|
37
|
-
%x(
|
38
|
-
\grep -EHors "^class +.+ *< *#{parent}" #{path}
|
39
|
-
).each_line do |line|
|
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::UnknownChildClass.new(clas)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
return children
|
35
|
+
return find_children(parent, dir, true)
|
58
36
|
end
|
59
37
|
end
|
60
38
|
|
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.1.
|
4
|
+
version: 1.1.3
|
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-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.7.
|
63
|
+
rubygems_version: 2.7.6
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Dynamically load children classes
|