text_extractor 0.5.0 → 0.5.1
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.rb +1 -1
- data/lib/text_extractor/guard.rb +23 -23
- data/lib/text_extractor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01262caa92a85326128a3821f293908d9ea6d3fcfc6d485e65745d48e8afbac5
|
4
|
+
data.tar.gz: 1f2ced91682b5960624b0bf30c3c9e109dae657c578a6b072a3eefe5610c11cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 571979757cd7b6d5f0db52019671c4dcffd7b17ea31af9deffe6df01a270c2e7222df5edb27ecb6eca79e7143cc34b2030da01c19cb8a290f18e914819328a8f
|
7
|
+
data.tar.gz: ec37c7732ccf1ddacccf0b4bb69a14e82bf20e69b6a1e64df07a5228ab8df3a498e8f2fb507e0eb0c765d9cd8af2faea2c7ede102ff4db6f78c3582eef34523c
|
data/lib/text_extractor.rb
CHANGED
data/lib/text_extractor/guard.rb
CHANGED
@@ -5,37 +5,37 @@ class TextExtractor
|
|
5
5
|
def initialize(_regexp, description:, **kwargs)
|
6
6
|
super
|
7
7
|
@description = description
|
8
|
-
@factory ||= :itself.to_proc
|
9
8
|
end
|
10
9
|
|
11
10
|
def extraction(match, _fill)
|
12
|
-
text =
|
11
|
+
text = match[0]
|
12
|
+
text = @factory.call(text) if @factory
|
13
13
|
raise GuardError, "#{@description} near #{text.inspect}"
|
14
14
|
end
|
15
|
-
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
INDENTED = {
|
17
|
+
description: 'indented line',
|
18
|
+
block: proc {
|
19
|
+
/
|
20
|
+
^[^\n\S]+[^\n]*$
|
21
|
+
/
|
22
|
+
}
|
23
|
+
}.freeze
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
25
|
+
UNINDENTED = {
|
26
|
+
description: 'unindented line',
|
27
|
+
block: proc {
|
28
|
+
/
|
29
|
+
^\S+[^\n]*$
|
30
|
+
/
|
31
|
+
}
|
32
|
+
}.freeze
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
DEFAULT = [
|
35
|
+
INDENTED,
|
36
|
+
UNINDENTED
|
37
|
+
].freeze
|
38
|
+
end
|
39
39
|
|
40
40
|
class GuardError < StandardError; end
|
41
41
|
end # class TextExtractor
|