regeng 0.1.1 → 0.2.0d
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/Gemfile.lock +1 -1
- data/changelog.md +3 -0
- data/lib/regeng.rb +32 -42
- data/lib/regeng/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f6cf6723927902dc4b3bc8dca7d87226f3b0f87ec1cc6470cd0fc988931bdb8
|
4
|
+
data.tar.gz: 4332481dc905c79166b87930e2132df9b220da8b85605162e56805084c070655
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42a4ab3bb1ef46eb1f010c3afeed40baf42e22d7dc9a9e35b09fc9d8b8af922898211bde6f944e8a02f40237eff794dfd5971a7352bd258e80d0017390066072
|
7
|
+
data.tar.gz: c918cd089cadf976b29b34a6c94cf4299c94f2355f61fa096c639f2c721a737fe470774f121320348ba5c0d5cdceb8c5d7632ee662815825d1ee25bb9af43c51
|
data/Gemfile.lock
CHANGED
data/changelog.md
CHANGED
data/lib/regeng.rb
CHANGED
@@ -1,61 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'regeng/version'
|
2
4
|
|
3
5
|
# A gem which creates regular expressions using plain english.
|
4
6
|
module Regeng
|
5
7
|
class Error < StandardError; end
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
middle = ''
|
10
|
-
ending = ''
|
9
|
+
CHARACTER_COND = /(any character(s)?( except)?( between)?( [a-zA-Z])+((-)|( through )|( to )|( and )){1}[a-zA-Z]){1}/.freeze
|
10
|
+
CHARACTER_SIMP = /(any ((uppercase )?|(lowercase )?)character){1}/.freeze
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
def self.expression(string)
|
13
|
+
expression = ''
|
14
|
+
if CHARACTER_COND.match?(string)
|
15
|
+
puts string.match(CHARACTER_COND)
|
16
|
+
expression = characters_condition(string)
|
17
|
+
elsif CHARACTER_SIMP.match?(string)
|
18
|
+
puts string.match(CHARACTER_SIMP)
|
19
|
+
expression = characters_simple(string)
|
20
|
+
end
|
14
21
|
|
15
|
-
expression = "#{start}#{middle}#{ending}"
|
16
22
|
Regexp.new expression
|
17
23
|
end
|
18
24
|
|
19
|
-
def self.
|
25
|
+
def self.characters_condition(string)
|
20
26
|
result = ''
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
result = '\z'
|
32
|
-
end
|
27
|
+
character_mod = ''
|
28
|
+
except = ''
|
29
|
+
if /( ([a-z])(-)(([a-z])))/i.match?(string)
|
30
|
+
character_mod = string.match(/([a-z]-[a-z])/i)
|
31
|
+
elsif /( ([a-z])(( through )|( to ))(([a-z])))/i.match?(string)
|
32
|
+
unfiltered_mod = string.match(/(([a-z])(( through )|( to ))(([a-z])))/)
|
33
|
+
character_mod = unfiltered_mod.to_s.sub(/( through )|( to )/, '-')
|
34
|
+
elsif /( ([a-z] )+(and )([a-z]))/.match?(string)
|
35
|
+
unfiltered_mod = string.match(/( ([a-z] )+(and )([a-z]))/)
|
36
|
+
character_mod = unfiltered_mod.to_s.gsub(/( )|(and )/, '')
|
33
37
|
end
|
38
|
+
except = '^' if /(except)/.match?(string)
|
39
|
+
result = "#{result}[#{except}#{character_mod}]" if character_mod != ''
|
34
40
|
result
|
35
41
|
end
|
36
42
|
|
37
|
-
def self.
|
38
|
-
result = ''
|
39
|
-
if
|
40
|
-
|
41
|
-
|
42
|
-
|
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]'
|
50
|
-
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]+'
|
58
|
-
end
|
43
|
+
def self.characters_simple(string)
|
44
|
+
result = '[a-zA-Z]'
|
45
|
+
if /(uppercase)/.match?(string)
|
46
|
+
result = '[A-Z]'
|
47
|
+
elsif /(lowercase)/.match?(string)
|
48
|
+
result = '[a-z]'
|
59
49
|
end
|
60
50
|
result
|
61
51
|
end
|
data/lib/regeng/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regeng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0d
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LucHighwalker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -92,9 +92,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - ">"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: 1.3.1
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
100
|
rubygems_version: 2.7.8
|