text_extractor 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 516fd52deaf25b6e67241cd40b55580a43227247
4
- data.tar.gz: b776cac3194257f826d8671aef2cf1991a075ae2
3
+ metadata.gz: 5c189f0b5ec9e1038d1861be7917451115f06980
4
+ data.tar.gz: 2817759a04f289b9aea17e559591420f69d74bd2
5
5
  SHA512:
6
- metadata.gz: 28cf87f08c5c04cc2d11c8576692f15919925360e6b5b31459d2319e4b5a3904a7925f87cc03749947a42cb21f8ce0f21759eb98a57376d7115725e6cba288be
7
- data.tar.gz: fa79da2fbd314b46ea0343cf7647c23f843a98ad27a0e04b69a665b6f872ab02384bc7d555b2229aaf3207e082c60522f9dfffebcefc1ab596b8ad3d871604ff
6
+ metadata.gz: 6ff6af6d8e7158e3ee1301e00190ce6865d2d9783510374e0252393837597f4a95dfdee2f5f9b58e634f88753d789ea69d866aa018fd46e2520946c20ba02c98
7
+ data.tar.gz: 280b8271a4c6b99afd426324fc463c55366d658014bd2e07137ea34ff0511462e5fd687abd435822f667f56dad44fa1acc914162e4ab2e282e446ad88e20d3f7
@@ -1,9 +1,11 @@
1
+ require_relative 'directives'
2
+
1
3
  class TextExtractor
2
4
  class Record
3
5
  attr_reader :regexp, :factory, :values
4
6
 
5
- def initialize(regexp, factory: nil, values: [], fill: [])
6
- @regexp = regexp
7
+ def initialize(regexp, factory: nil, values: [], fill: [], directives: true)
8
+ @regexp = expand_regexp(regexp, directives)
7
9
  @factory = factory
8
10
  @constructor = FactoryAnalyzer.new(factory).to_proc
9
11
  @values = values.map { |val| [val.id, val] }.to_h
@@ -23,6 +25,14 @@ class TextExtractor
23
25
  @constructor.call(extracted)
24
26
  end
25
27
 
28
+ def expand_regexp(regexp, directives)
29
+ if directives
30
+ TextExtractor.expand_directives(regexp)
31
+ else
32
+ regexp
33
+ end
34
+ end
35
+
26
36
  def match(string, pos = 0)
27
37
  @regexp.match(string, pos)
28
38
  end
@@ -1,5 +1,5 @@
1
1
  class TextExtractor
2
2
  def self.version
3
- '0.1.5'
3
+ '0.1.6'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text_extractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Miller