fagin 1.0.0 → 1.0.2
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 +5 -5
- data/lib/fagin.rb +14 -16
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '069a7332914f17b5aa052943c548d1b552fcc31bec3c4782e577179cdb6f677f'
|
4
|
+
data.tar.gz: 4485c842d4ef0038af526089db5a415da9dd6ffba44fca12a120e3150b9e4bec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d4fb3fbb7d71d3693d1dd6948acd12d22104734519893cb4fdcd809c06ebd0d2fa40dae6e4de951d5e555565c0a9fcae0f9b4206a2c059f3bb550582bd9c6a
|
7
|
+
data.tar.gz: 7f2abdb3089168974d2392f55379b0aacf7920d4149b662fcc5b5899805b31bb717f6f1311ae1fb4ffcc85201b41f5691b04098aab74bfe881f1fb0f96197a3e
|
data/lib/fagin.rb
CHANGED
@@ -5,24 +5,22 @@ class Fagin
|
|
5
5
|
children = Hash.new
|
6
6
|
path = Pathname.new(dir).expand_path
|
7
7
|
|
8
|
-
Dir["#{path}/*.rb"]
|
9
|
-
|
10
|
-
\grep -E "^class .+ < #{parent}" #{file} | \
|
11
|
-
awk '{print $2}'
|
12
|
-
).each_line do |clas|
|
13
|
-
next if (clas.nil?)
|
14
|
-
clas.strip!
|
15
|
-
next if (clas.empty?)
|
8
|
+
files = Dir["#{path}/*.rb"]
|
9
|
+
return children if (files.empty?)
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
%x(
|
12
|
+
\grep -EHo "^class +.+ *< *#{parent}" #{files.join(" ")}
|
13
|
+
).each_line do |line|
|
14
|
+
clas = line.match(/class\s+(\S+)\s*</)[1]
|
15
|
+
next if (clas.nil? || clas.empty?)
|
16
|
+
begin
|
17
|
+
require_relative line.match(/^([^:]+)/)[1]
|
18
|
+
child = clas.split("::").inject(Object) do |m, c|
|
19
|
+
m.const_get(c)
|
25
20
|
end
|
21
|
+
children[clas] = child
|
22
|
+
rescue NameError
|
23
|
+
raise Error::UnknownChildClassError.new(clas)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
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.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-23 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.
|
63
|
+
rubygems_version: 2.7.3
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Dynamically load children classes
|