js_regex 1.0.11 → 1.0.12
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f7c9a503a4ccb3152c6420bc351830c9ac1be24
|
4
|
+
data.tar.gz: 7b32c73207f49ac9417bc002a2196036af413f90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cde6b670649bf911692408b718785bd523d30d35d01e82c9b6b3ac3ea37dac84d43a2ec28b712f9681c828ec522f54f39098e7cc7ccbbd61cfee09f2b08bcc6
|
7
|
+
data.tar.gz: 14fe5c44dbd8613f45dbdb8a3ffa7792721a7c9db80a8088027e7e78f69aa3c96b351e688f1347d22ee3437951a86509566fa979c9dfa69a88b110e0fed34473
|
@@ -13,13 +13,12 @@ class JsRegex
|
|
13
13
|
def convert_data
|
14
14
|
case subtype
|
15
15
|
when :lookahead, :nlookahead
|
16
|
-
|
16
|
+
open_group(non_capturing: true)
|
17
17
|
when :nlookbehind
|
18
18
|
context.negative_lookbehind = true
|
19
19
|
warn_of_unsupported_feature('negative lookbehind assertion')
|
20
20
|
else # :lookbehind, ...
|
21
|
-
|
22
|
-
open_group('(?:')
|
21
|
+
open_unsupported_group
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
@@ -8,11 +8,10 @@ class JsRegex
|
|
8
8
|
class Context
|
9
9
|
attr_accessor :buffered_set_members,
|
10
10
|
:buffered_set_extractions,
|
11
|
-
:
|
11
|
+
:captured_group_count,
|
12
12
|
:group_count_changed,
|
13
13
|
:group_level,
|
14
14
|
:group_level_for_backreference,
|
15
|
-
:group_number_for_backreference,
|
16
15
|
:negative_lookbehind,
|
17
16
|
:negative_set_levels,
|
18
17
|
:previous_quantifier_subtype,
|
@@ -22,7 +21,7 @@ class JsRegex
|
|
22
21
|
def initialize
|
23
22
|
self.buffered_set_members = []
|
24
23
|
self.buffered_set_extractions = []
|
25
|
-
self.
|
24
|
+
self.captured_group_count = 0
|
26
25
|
self.group_count_changed = false
|
27
26
|
self.group_level = 0
|
28
27
|
self.negative_lookbehind = false
|
@@ -14,39 +14,44 @@ class JsRegex
|
|
14
14
|
when :capture then open_group
|
15
15
|
when :close then close_group
|
16
16
|
when :comment then '' # drop whole group w/o warning
|
17
|
-
when :named_ab, :named_sq then
|
17
|
+
when :named_ab, :named_sq then open_named_group
|
18
18
|
when :options then open_options_group
|
19
|
-
when :passive then
|
20
|
-
else
|
21
|
-
warn_of_unsupported_feature
|
22
|
-
open_group('(')
|
19
|
+
when :passive then open_passive_group
|
20
|
+
else open_unsupported_group
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
26
24
|
def open_atomic_group
|
27
|
-
# Atomicity is
|
25
|
+
# Atomicity is emulated using backreferenced lookahead groups:
|
28
26
|
# http://instanceof.me/post/52245507631
|
29
27
|
# regex-emulate-atomic-grouping-with-lookahead
|
30
28
|
context.group_level_for_backreference = context.group_level
|
31
|
-
|
32
|
-
|
29
|
+
open_group(head: '(?=(')
|
30
|
+
end
|
31
|
+
|
32
|
+
def open_named_group
|
33
|
+
# drop name w/o warning
|
34
|
+
open_group(head: '(')
|
33
35
|
end
|
34
36
|
|
35
37
|
def open_options_group
|
36
38
|
warn_of_unsupported_feature('group-specific options')
|
37
|
-
open_group('(')
|
39
|
+
open_group(head: '(')
|
38
40
|
end
|
39
41
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
def open_passive_group
|
43
|
+
open_group(head: '(?:', non_capturing: true)
|
44
|
+
end
|
45
|
+
|
46
|
+
def open_unsupported_group
|
47
|
+
warn_of_unsupported_feature
|
48
|
+
open_passive_group
|
44
49
|
end
|
45
50
|
|
46
|
-
def
|
47
|
-
# these don't count as opened groups for backreference purposes
|
51
|
+
def open_group(options = {})
|
48
52
|
context.group_level += 1
|
49
|
-
|
53
|
+
context.captured_group_count += 1 unless options[:non_capturing]
|
54
|
+
options[:head] || pass_through
|
50
55
|
end
|
51
56
|
|
52
57
|
def close_group
|
@@ -74,7 +79,7 @@ class JsRegex
|
|
74
79
|
context.group_level_for_backreference = nil
|
75
80
|
context.group_count_changed = true
|
76
81
|
# the empty passive group (?:) is appended in case literal digits follow
|
77
|
-
"))\\#{context.
|
82
|
+
"))\\#{context.captured_group_count}(?:)"
|
78
83
|
end
|
79
84
|
end
|
80
85
|
end
|
@@ -126,7 +126,8 @@ class JsRegex
|
|
126
126
|
case buffered_extractions.count
|
127
127
|
when 0 then ''
|
128
128
|
when 1 then buffered_extractions.first
|
129
|
-
else "(?:#{buffered_extractions.join('|')})"
|
129
|
+
else "(?:#{buffered_extractions.join('|')})"
|
130
|
+
end
|
130
131
|
end
|
131
132
|
|
132
133
|
def build_set(members, negative)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_regex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janosch Müller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: regexp_parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.3.
|
26
|
+
version: 0.3.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: codeclimate-test-reporter
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,8 +129,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.4.
|
132
|
+
rubygems_version: 2.4.8
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Converts Ruby regexes to JavaScript regexes.
|
136
136
|
test_files: []
|
137
|
+
has_rdoc:
|