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.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/fagin.rb +14 -16
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 59bdfaa3eae3de5a50ff4fba0ec0583434243915
4
- data.tar.gz: 4c1778cc02346efb385779365fab492c5e0df407
2
+ SHA256:
3
+ metadata.gz: '069a7332914f17b5aa052943c548d1b552fcc31bec3c4782e577179cdb6f677f'
4
+ data.tar.gz: 4485c842d4ef0038af526089db5a415da9dd6ffba44fca12a120e3150b9e4bec
5
5
  SHA512:
6
- metadata.gz: d1515137a0998eabdf7242f0ac9cf91621045e11d53f7c36eddbbaafafd56956de66e7a46e28375dff2b4646dce9bbc31d1a183d76f1d3cdee4605629c8e109c
7
- data.tar.gz: 67054e78b542e9ee968eb9d3234cb932170e1518b8022991b6a12c1e3c1217298990159f11b0641bb0400ff1b5679151cc03369e8cf0cfe7379a01998e0d2b75
6
+ metadata.gz: 99d4fb3fbb7d71d3693d1dd6948acd12d22104734519893cb4fdcd809c06ebd0d2fa40dae6e4de951d5e555565c0a9fcae0f9b4206a2c059f3bb550582bd9c6a
7
+ data.tar.gz: 7f2abdb3089168974d2392f55379b0aacf7920d4149b662fcc5b5899805b31bb717f6f1311ae1fb4ffcc85201b41f5691b04098aab74bfe881f1fb0f96197a3e
@@ -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"].each do |file|
9
- %x(
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
- 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)
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.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: 2016-11-03 00:00:00.000000000 Z
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.4.5.1
63
+ rubygems_version: 2.7.3
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: Dynamically load children classes