cucumber-expressions 5.0.12 → 5.0.13

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: ea398357223ad8b15e08a3c66821af289a60c175
4
- data.tar.gz: 6d4cfdf4cb89c2272673ff6c95310964031273c7
3
+ metadata.gz: e37bfd25d2fa6ce81bb76f2a0e4b155b23d7c243
4
+ data.tar.gz: a843eb27ff496f5744bb8fc9b7ff2993640a029a
5
5
  SHA512:
6
- metadata.gz: 2f045c24da07f978651d62e2b7a8bf729c439d5170e0074fefb42c7a8801e25b0d07b4baa91cc4b79f088a7852b615980541cf28fd5a8e9fbf78689404c4535f
7
- data.tar.gz: 68f8e6cd42e31f3e4132332ef1a114de435d9b678db4d1459c44452150a2b1d84c80497920b6933a7b3a6edb3294ebdede54369eff0611c67d037c14ceab207a
6
+ metadata.gz: 7a9c2d12d144a509ff625e72c67cf1b1e2504a2ecab38086f85aa019150e59437ee06807efb5d65c398f7314c52f1677cb7429d75ff442316c043c0d0987d4f3
7
+ data.tar.gz: 8a9e6c44e79d1c713ff2dac7b6b5a2327001615df1ae4e8a356dcc682b7ac71a06629a9f0f5ac5f8d6f053380c5223657eb60ae007a3c0668bdc2a08f30996e4
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'cucumber-expressions'
4
- s.version = '5.0.12'
4
+ s.version = '5.0.13'
5
5
  s.authors = ["Aslak Hellesøy"]
6
6
  s.description = 'Cucumber Expressions - a simpler alternative to Regular Expressions'
7
7
  s.summary = "cucumber-expressions-#{s.version}"
@@ -3,24 +3,18 @@ require 'cucumber/cucumber_expressions/group_builder'
3
3
  module Cucumber
4
4
  module CucumberExpressions
5
5
  class TreeRegexp
6
- REGEXP_CHARS = ['#', '$', '(', ')', '*', '+', '.', '?', '[', '\\', '^', '{', '|']
7
-
8
6
  attr_reader :regexp, :group_builder
9
7
 
10
8
  def initialize(regexp)
11
9
  @regexp = regexp.is_a?(Regexp) ? regexp : Regexp.new(regexp)
12
-
13
10
  stack = [GroupBuilder.new]
14
11
  group_start_stack = []
15
12
  last = nil
16
13
  escaping = false
17
14
  non_capturing_maybe = false
15
+
18
16
  @regexp.source.split('').each_with_index do |c, n|
19
- if escaping && regexp_char?(c)
20
- escaping = false
21
- elsif c == '\\'
22
- escaping = true
23
- elsif c == '(' && !escaping
17
+ if c == '(' && !escaping
24
18
  stack.push(GroupBuilder.new)
25
19
  group_start_stack.push(n+1)
26
20
  non_capturing_maybe = false
@@ -40,15 +34,13 @@ module Cucumber
40
34
  stack.last.set_non_capturing!
41
35
  non_capturing_maybe = false
42
36
  end
37
+
38
+ escaping = c == '\\' && !escaping
43
39
  last = c
44
40
  end
45
41
  @group_builder = stack.pop
46
42
  end
47
43
 
48
- def regexp_char?(c)
49
- REGEXP_CHARS.include?(c)
50
- end
51
-
52
44
  def match(s)
53
45
  match = @regexp.match(s)
54
46
  return nil if match.nil?
@@ -65,6 +65,12 @@ module Cucumber
65
65
  expect(group.children.length).to eq(1)
66
66
  end
67
67
 
68
+ it 'works with digit and word' do
69
+ tr = TreeRegexp.new(/^(\d) (\w+)$/)
70
+ group = tr.match("2 you")
71
+ expect(group.children.length).to eq(2)
72
+ end
73
+
68
74
  it 'captures non capturing groups with capturing groups inside' do
69
75
  tr = TreeRegexp.new(/the stdout(?: from "(.*?)")?/)
70
76
  group = tr.match("the stdout")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-expressions
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.12
4
+ version: 5.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,7 +131,7 @@ rubyforge_project:
131
131
  rubygems_version: 2.6.8
132
132
  signing_key:
133
133
  specification_version: 4
134
- summary: cucumber-expressions-5.0.12
134
+ summary: cucumber-expressions-5.0.13
135
135
  test_files:
136
136
  - spec/capture_warnings.rb
137
137
  - spec/coverage.rb