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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f17cdfbe4067e8ea3574bf6a2588a078347c52b6dd0797e244d1235f2469368
4
- data.tar.gz: be13b4aa4cc21fb7fc679f82eba084f52069a4926134bef4ff7a51b7c08899da
3
+ metadata.gz: d741dba07900c3b2364e317a4929a286cbefc3951218ec3878c08a695233b290
4
+ data.tar.gz: 80d263d8957320e7deac43b1b72a41891032c7660f4102bb435faee009fe706f
5
5
  SHA512:
6
- metadata.gz: 68acdc534ecb0e1753e645f312af3bfc6b52a972440907768d0c68dbee622dbb9044f1af7fca8d5062f3436a129d0eac05f9f596ece7da70ba0bc491ee3361da
7
- data.tar.gz: e40ece7ba16ea77f36cc319c4c6bf1c7f7110b31fddad77e23eaa6e99292eb96ce3f920810347157d0bbef33c7a7ab953385bf3126061e10b05e407e8bdf848d
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 named targets
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
@@ -1,3 +1,3 @@
1
1
  module RegexGenerator
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
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.0
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-26 00:00:00.000000000 Z
11
+ date: 2019-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler