js_regex 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/js_regex/conversion.rb +82 -0
- data/lib/js_regex/converter/anchor_converter.rb +24 -0
- data/lib/js_regex/converter/assertion_converter.rb +27 -0
- data/lib/js_regex/converter/base.rb +44 -0
- data/lib/js_regex/converter/conditional_converter.rb +24 -0
- data/lib/js_regex/converter/context.rb +63 -0
- data/lib/js_regex/converter/escape_converter.rb +27 -0
- data/lib/js_regex/converter/freespace_converter.rb +16 -0
- data/lib/js_regex/converter/group_converter.rb +81 -0
- data/lib/js_regex/converter/literal_converter.rb +29 -0
- data/lib/js_regex/converter/meta_converter.rb +28 -0
- data/lib/js_regex/converter/nonproperty_converter.rb +18 -0
- data/lib/js_regex/converter/property_converter.rb +40 -0
- data/lib/js_regex/converter/quantifier_converter.rb +37 -0
- data/lib/js_regex/converter/set_converter.rb +137 -0
- data/lib/js_regex/converter/subset_converter.rb +10 -0
- data/lib/js_regex/converter/type_converter.rb +26 -0
- data/lib/js_regex/converter/unsupported_token_converter.rb +16 -0
- data/lib/js_regex/property_map.rb +330 -0
- data/lib/js_regex.rb +26 -0
- metadata +107 -0
data/lib/js_regex.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# JsRegex converts ::Regexp instances to JavaScript.
|
3
|
+
#
|
4
|
+
# Usage:
|
5
|
+
#
|
6
|
+
# js_regex = JsRegex.new(my_ruby_regex)
|
7
|
+
# js_regex.to_h # for use in 'new RegExp()'
|
8
|
+
# js_regex.to_s # for direct injection into JavaScript
|
9
|
+
#
|
10
|
+
class JsRegex
|
11
|
+
require_relative File.join('js_regex', 'conversion')
|
12
|
+
|
13
|
+
attr_reader :source, :options, :warnings
|
14
|
+
|
15
|
+
def initialize(ruby_regex)
|
16
|
+
@source, @options, @warnings = Conversion.of(ruby_regex)
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_h
|
20
|
+
{ source: source.gsub('\\', '\\\\\\\\'), options: options }
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
"/#{source}/#{options}"
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: js_regex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Janosch Müller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: regexp_parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.3.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.3.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: codeclimate-test-reporter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: therubyracer
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.12'
|
55
|
+
description: JsRegex converts Ruby's native regular expressions for JavaScript, taking
|
56
|
+
care of various incompatibilities and returning warnings for unsolvable differences.
|
57
|
+
email:
|
58
|
+
- janosch84@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- lib/js_regex.rb
|
64
|
+
- lib/js_regex/conversion.rb
|
65
|
+
- lib/js_regex/converter/anchor_converter.rb
|
66
|
+
- lib/js_regex/converter/assertion_converter.rb
|
67
|
+
- lib/js_regex/converter/base.rb
|
68
|
+
- lib/js_regex/converter/conditional_converter.rb
|
69
|
+
- lib/js_regex/converter/context.rb
|
70
|
+
- lib/js_regex/converter/escape_converter.rb
|
71
|
+
- lib/js_regex/converter/freespace_converter.rb
|
72
|
+
- lib/js_regex/converter/group_converter.rb
|
73
|
+
- lib/js_regex/converter/literal_converter.rb
|
74
|
+
- lib/js_regex/converter/meta_converter.rb
|
75
|
+
- lib/js_regex/converter/nonproperty_converter.rb
|
76
|
+
- lib/js_regex/converter/property_converter.rb
|
77
|
+
- lib/js_regex/converter/quantifier_converter.rb
|
78
|
+
- lib/js_regex/converter/set_converter.rb
|
79
|
+
- lib/js_regex/converter/subset_converter.rb
|
80
|
+
- lib/js_regex/converter/type_converter.rb
|
81
|
+
- lib/js_regex/converter/unsupported_token_converter.rb
|
82
|
+
- lib/js_regex/property_map.rb
|
83
|
+
homepage: https://github.com/janosch-x/js_regex
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.5
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Converts Ruby regexes to JavaScript regexes.
|
107
|
+
test_files: []
|