text_extractor 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/text_extractor/record.rb +25 -3
- data/lib/text_extractor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d29f56c023ab50d2bcf9f40869e78febd4fbbb8
|
4
|
+
data.tar.gz: 87da343a092a575b7683bfca3378ed3eeabff820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edcafad5fed934fde4b68b7b22058c600ecdadcbbcf629634285951860740f7a25136de3d133f075bce0a50cdc6bc7265c2b7ff14712ac495885ecc3c5c62741
|
7
|
+
data.tar.gz: b09236449430419201b8e9f3a359f10b0933e0d2584d44b2b424137b2f733e6aa35b95172663f85ff4b2fe2cc68bb1af4b80771161a96d92ce205e1afe4faa3b
|
@@ -20,15 +20,37 @@ class TextExtractor
|
|
20
20
|
def build_extraction(extracted)
|
21
21
|
case factory
|
22
22
|
when Hash
|
23
|
-
|
24
|
-
|
23
|
+
build_extraction_by_hash(extracted)
|
24
|
+
when Set
|
25
|
+
build_extraction_by_set(extracted)
|
25
26
|
when Class
|
26
|
-
|
27
|
+
build_extraction_by_class(extracted)
|
27
28
|
else
|
28
29
|
extracted
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
def build_extraction_by_hash(extracted)
|
34
|
+
klass, params = factory.first
|
35
|
+
klass.new(*extracted.values_at(*params))
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_extraction_by_set(extracted)
|
39
|
+
klass, params = factory.first
|
40
|
+
values = params.each_with_object({}) do |param, hash|
|
41
|
+
hash[param] = extracted[param]
|
42
|
+
end
|
43
|
+
klass.new(**values)
|
44
|
+
end
|
45
|
+
|
46
|
+
def build_extraction_by_class(extracted)
|
47
|
+
if factory.ancestors.include?(Struct)
|
48
|
+
factory.new(*extracted.values)
|
49
|
+
else
|
50
|
+
factory.new(**extracted)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
32
54
|
def match(string, pos = 0)
|
33
55
|
@regexp.match(string, pos)
|
34
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|