ecma-re-validator 0.1.0 → 0.1.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
  SHA1:
3
- metadata.gz: ad7c47aa986f667a8972067436fcd35c8e5b1c3b
4
- data.tar.gz: 157e0ee1420ecf52a1725609de98af9c38edc5bd
3
+ metadata.gz: e57fb40607606a28b871027d9d5dfa2ec0a9cca0
4
+ data.tar.gz: b275df109a0f087e9e13694c51201ef42c7f61a9
5
5
  SHA512:
6
- metadata.gz: b773ba7a38ac1ef62d14438ae5052ad4c30810e5bd9246b4e824b6b3cf6fe7ac5125b0075cc29756e5c395b7e5bb14267952a8f0a1424b4fd446162396b63146
7
- data.tar.gz: e1501b5f7f7068c72bd62f8d724b0af1874e7a5b27519721c5307df83eafbc33bcd6b814d1f41fe682f0cc3a92563e3fda96aeda5cb0627896b84e8040452f8d
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
  ```
@@ -42,6 +42,12 @@ module EcmaReValidator
42
42
  return false
43
43
  end
44
44
 
45
- Regexp::Scanner.scan(input).none? { |t| INVALID_TOKENS.include?(t[1]) }
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
@@ -1,3 +1,3 @@
1
1
  module EcmaReValidator
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -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.0
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-19 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: regexp_parser