regex_generator 0.3.0 → 0.3.1
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 +4 -4
- data/lib/regex_generator/generator.rb +11 -2
- data/lib/regex_generator/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d741dba07900c3b2364e317a4929a286cbefc3951218ec3878c08a695233b290
|
4
|
+
data.tar.gz: 80d263d8957320e7deac43b1b72a41891032c7660f4102bb435faee009fe706f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2de6cc1cce3b2a96a0aad9cd859460dfbbcf8ef7628456a71ec1a106cfe09fa889baf59bdb46e9426880c6a6f9edd8168032715b47da87754f058e2eba2bd1a8
|
7
|
+
data.tar.gz: af1ca8dfe14b9531dd69862a306f189904cc0f998a76f0b4b8e12333f18ad6e8d696be67b28ff9882af73b261c45533933d256ad8066437d3f52e513dabadca6
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module RegexGenerator
|
2
2
|
class Generator
|
3
|
-
# @param target [String, Hash] target string or hash with
|
3
|
+
# @param target [String, Integer, Float, Hash] target string or hash with
|
4
|
+
# named targets
|
4
5
|
# @param text [String] source text
|
5
6
|
# @param options [Hash] options to generate regex with
|
6
7
|
# @option options [true, false] :exact_target to generate regex
|
@@ -9,7 +10,7 @@ module RegexGenerator
|
|
9
10
|
# itself
|
10
11
|
def initialize(target, text, options = {})
|
11
12
|
@text = text
|
12
|
-
@target = target
|
13
|
+
@target = target_to_s(target)
|
13
14
|
@options = options
|
14
15
|
end
|
15
16
|
|
@@ -77,6 +78,14 @@ module RegexGenerator
|
|
77
78
|
@options
|
78
79
|
end
|
79
80
|
|
81
|
+
def target_to_s(target)
|
82
|
+
return target.to_s unless target.is_a? Hash
|
83
|
+
|
84
|
+
target.each_with_object({}) do |(key, value), result|
|
85
|
+
result[key] = value.to_s
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
80
89
|
# Checks if target is present in the text
|
81
90
|
def target_present?
|
82
91
|
return @target.values.all? { |t| @text[t] } if @target.is_a? Hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regex_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- o.vykhor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|