regeng 0.0.1 → 0.1.0
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 +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -0
- data/lib/regeng.rb +48 -38
- data/lib/regeng/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c49b60387c63fa04b2eee8bb587d5fec33cb5f2b1113b01da5818620f5c5e8e
|
4
|
+
data.tar.gz: 88fcc5a92dc11b9c44a840eac43b6ca13e2996b9ea308512566d01f37e255209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c38f7c83cc735f372a18a903832294919054d26a7f5610559c9176826605de54e930d79839a57067336decb84b2f5959172916e1396bc6496c08b9ca5d8c29c
|
7
|
+
data.tar.gz: 56ecbf74789c5c40070bb8c83fe4afb251828759c1f25ef398ccd36b1a32dd4c6550c9da59031896276577d6b7a12b0b52b2a182943591dab98cd59fbfdff3b9
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/regeng.rb
CHANGED
@@ -4,49 +4,59 @@ require 'regeng/version'
|
|
4
4
|
module Regeng
|
5
5
|
class Error < StandardError; end
|
6
6
|
|
7
|
-
def self.
|
8
|
-
array = string.split(' and ')
|
7
|
+
def self.expression(string)
|
9
8
|
start = ''
|
10
9
|
middle = ''
|
11
10
|
ending = ''
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
elsif string =~ /(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
11
|
+
|
12
|
+
start = process_start_of(string) if string =~ /( at ){1}/
|
13
|
+
middle = process_any(string) if string =~ /(any ){1}/
|
14
|
+
|
15
|
+
expression = "#{start}#{middle}#{ending}"
|
16
|
+
Regexp.new expression
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.process_start_of(string)
|
20
|
+
result = ''
|
21
|
+
if string =~ /(start of){1}/
|
22
|
+
if string =~ /(line){1}/
|
23
|
+
result = '^'
|
24
|
+
elsif string =~ /(string){1}/
|
25
|
+
result = '\A'
|
26
|
+
end
|
27
|
+
elsif string =~ /(end of){1}/
|
28
|
+
if string =~ /(line){1}/
|
29
|
+
result = '$'
|
30
|
+
elsif string =~ /(string){1}/
|
31
|
+
result = '\z'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.process_any(string)
|
38
|
+
result = ''
|
39
|
+
if string =~ /(character){1}/
|
40
|
+
if string =~ /([a-z]-[a-z])/i
|
41
|
+
character_mod = string.match(/([a-z]-[a-z])/i)
|
42
|
+
character_mod = "^#{character_mod}" if string =~ /(except){1}/
|
43
|
+
result = "[#{character_mod}]"
|
44
|
+
elsif string =~ /(uppercase){1}/
|
45
|
+
result = '[A-Z]'
|
46
|
+
elsif string =~ /(lowercase){1}/
|
47
|
+
result = '[a-z]'
|
48
|
+
else
|
49
|
+
result = '[A-Za-z]'
|
33
50
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
elsif string =~ /(end of){1}/
|
42
|
-
if string =~ /(line){1}/
|
43
|
-
start = "#{start}$"
|
44
|
-
elsif string =~ /(string){1}/
|
45
|
-
start = "#{start}\\z"
|
46
|
-
end
|
47
|
-
end
|
51
|
+
elsif string =~ /(digit){1}/
|
52
|
+
if string =~ /([0-9]+-[0-9]+){1}/
|
53
|
+
digit_mod = string.match(/([0-9]+-[0-9]+){1}/)
|
54
|
+
digit_mod = "^#{digit_mod}" if string =~ /(except){1}/
|
55
|
+
result = "[#{digit_mod}]"
|
56
|
+
else
|
57
|
+
result = '[0-9]+'
|
48
58
|
end
|
49
59
|
end
|
50
|
-
|
60
|
+
result
|
51
61
|
end
|
52
62
|
end
|
data/lib/regeng/version.rb
CHANGED