regeng 0.1.1 → 0.2.0d

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db6c7753dd058abc471673cf6857ef8d44b0e5e80957b57b7482261f825975ea
4
- data.tar.gz: 994bdb33559c7ea9b494db747827077f8ebb4b64780cc43884db74a5f1863f3f
3
+ metadata.gz: 2f6cf6723927902dc4b3bc8dca7d87226f3b0f87ec1cc6470cd0fc988931bdb8
4
+ data.tar.gz: 4332481dc905c79166b87930e2132df9b220da8b85605162e56805084c070655
5
5
  SHA512:
6
- metadata.gz: 1fc3b30e00305fdd76771827b05dc4aefd498e6b67ece638596a394bf8f917a40407a7d0a1d1ebcb747a4a63c03258299cada10851ffdc8e8e756bd4c0292efb
7
- data.tar.gz: da14036bbf083639d96cd6614fc1ce3c2d7b49b7dfdde36bb0109ad612aae95bbcb9cb546e42e68907d5c18c47b19d1bff9e448098e98aa9f9b54171554ac52e
6
+ metadata.gz: 42a4ab3bb1ef46eb1f010c3afeed40baf42e22d7dc9a9e35b09fc9d8b8af922898211bde6f944e8a02f40237eff794dfd5971a7352bd258e80d0017390066072
7
+ data.tar.gz: c918cd089cadf976b29b34a6c94cf4299c94f2355f61fa096c639f2c721a737fe470774f121320348ba5c0d5cdceb8c5d7632ee662815825d1ee25bb9af43c51
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- regeng (0.1.1)
4
+ regeng (0.2.0d)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ [12-10-18][0.2.0d]: Dev Build: Refactored gem, refactored character functionality.
2
+
3
+ [12-09-18][0.1.1]: Fixed changelog link... oops.
1
4
 
2
5
  [12-09-18][0.1.0]: Refactored prototype, now returns regular expressions.
3
6
 
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
- def self.expression(string)
8
- start = ''
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
- start = process_start_of(string) if string =~ /( at ){1}/
13
- middle = process_any(string) if string =~ /(any ){1}/
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.process_start_of(string)
25
+ def self.characters_condition(string)
20
26
  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
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.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]'
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
@@ -1,3 +1,3 @@
1
1
  module Regeng
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0d"
3
3
  end
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.1.1
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-10 00:00:00.000000000 Z
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: '0'
97
+ version: 1.3.1
98
98
  requirements: []
99
99
  rubyforge_project:
100
100
  rubygems_version: 2.7.8