ecma-re-validator 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/ecma-re-validator.rb +7 -1
- data/lib/ecma-re-validator/version.rb +1 -1
- data/spec/unicode_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e57fb40607606a28b871027d9d5dfa2ec0a9cca0
|
4
|
+
data.tar.gz: b275df109a0f087e9e13694c51201ef42c7f61a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35cd75278a8e2837d2c60c42b6e23640bb7631fdf3cec3a76d591e135d68c26f77a98a9b1b8a498aaebba7fdca0bfb891a909aba3d75dff7b6cf3347009ddfd
|
7
|
+
data.tar.gz: 63767431a1c105d52e10c8272a881620d875313c4dc55186afd0b11e73052222e9c6e9de8d5fdabadc11ae3aeeca1bd758150574038fd355b3c045ae60d750a8
|
data/README.md
CHANGED
@@ -8,10 +8,16 @@ The information for what is valid and what isn't comes from <http://www.regular-
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
|
+
Pass in either a string or a Regexp:
|
12
|
+
|
11
13
|
``` ruby
|
12
14
|
require 'ecma-re-validator'
|
13
15
|
|
14
16
|
re = "[Ss]mith\\\\b"
|
15
17
|
|
16
18
|
EcmaReValidator.valid?(re) # true
|
19
|
+
|
20
|
+
re = /(?<=a)b/
|
21
|
+
|
22
|
+
EcmaReValidator.valid?(re) # false--lookbehinds don't exist in JS
|
17
23
|
```
|
data/lib/ecma-re-validator.rb
CHANGED
@@ -42,6 +42,12 @@ module EcmaReValidator
|
|
42
42
|
return false
|
43
43
|
end
|
44
44
|
|
45
|
-
Regexp::Scanner.scan(input).none?
|
45
|
+
Regexp::Scanner.scan(input).none? do |t|
|
46
|
+
if t[1] == :word || t[1] == :space || t[1] == :digit
|
47
|
+
t[0] != :type
|
48
|
+
else
|
49
|
+
INVALID_TOKENS.include?(t[1])
|
50
|
+
end
|
51
|
+
end
|
46
52
|
end
|
47
53
|
end
|
data/spec/unicode_spec.rb
CHANGED
@@ -95,4 +95,22 @@ describe 'EcmaReValidator::Unicode' do
|
|
95
95
|
|
96
96
|
expect(EcmaReValidator.valid?(re)).to eql(true)
|
97
97
|
end
|
98
|
+
|
99
|
+
it 'should pass if regexp uses a \w' do
|
100
|
+
re = /^\w+/
|
101
|
+
|
102
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should pass if regexp uses a \s' do
|
106
|
+
re = /\s*wow/
|
107
|
+
|
108
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should pass if regexp uses a \d' do
|
112
|
+
re = /\d$/
|
113
|
+
|
114
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
115
|
+
end
|
98
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecma-re-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: regexp_parser
|