regeng 0.2.4 → 0.2.5

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: 793b1fe234f31d0436bd4897e1790b58866446ab38d26e7bafef3a2c259abaf2
4
- data.tar.gz: 20b8ee94808bfa33dca2bebec6a370892f18aebdf545b949a5ca4797fb618d29
3
+ metadata.gz: b08c143342913d8a64a5cce550f2d1fa132acd8f92b543f833ac3fb631661cf8
4
+ data.tar.gz: 4121b024940ece38acec13398b97630fd65e7d369d1c91dad03b8a2c805da1ca
5
5
  SHA512:
6
- metadata.gz: 8abc45f0202349ae23642cf86d5ce9ce03a7340dc757cce58f2449c092352874d1dbc1b315aa3ae8ef124b5f1ebc09e70ce5d5f59c6d9e227355e29c766709eb
7
- data.tar.gz: 5a30c9135b3b2d6b662258c996bbc281603346d4d8380d6bfeeee8a168afeb4b892a8f8914de736af65224a730c942f86119d8ee7c4e81f646c9c36a796db8ef
6
+ metadata.gz: 4862c021d796fa74b5ac55ae15f069ff3f4c7f03d15b45da3fa3a52cf7b0ed7f7dea97f4f4bc1829fe3ae5c37c4051d0d29919e5e9b0b3b5d492a6bf44b489ca
7
+ data.tar.gz: 720e2344a7670dc5509c3a5b5a53931b9523ba7b1dfa645466e1f869f291676c6251b4d98656d77e1fc6bd490a7f0fdf8b4d17bec2c437972cf084302a0e470c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- regeng (0.2.4)
4
+ regeng (0.2.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,4 @@
1
- # Regeng
2
-
3
- # (WIP)
1
+ # Regeng (WIP) {docsify-ignore-all}
4
2
 
5
3
  Regeng or regular english, is a gem aimed to make regular expressions a bit more noob friendly.
6
4
 
@@ -27,11 +25,11 @@ Or install it yourself as:
27
25
  ```ruby
28
26
  require 'regeng'
29
27
  => true
30
- Regeng.new 'any character except e-z at start of string'
31
- => /\A[^e-z]/
28
+ Regeng.new 'any characters except e through z at start of string'
29
+ => /\A[^e-z]+/
32
30
  ```
33
31
 
34
- Documentation in progress...
32
+ More examples in the [Documentation](https://luchighwalker.github.io/regeng/)
35
33
 
36
34
  ## Development
37
35
 
data/docs/.nojekyll ADDED
File without changes
data/docs/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Regeng (WIP) {docsify-ignore-all}
2
+
3
+ Regeng or regular english, is a gem aimed to make regular expressions a bit more noob friendly.
4
+
5
+ [Regeng Gem](https://rubygems.org/gems/regeng)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'regeng'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install regeng
22
+
23
+ ## Usage
24
+
25
+ ### Quick Start
26
+
27
+ ```ruby
28
+ require 'regeng'
29
+ => true
30
+ Regeng.new 'any characters except e through z at start of string'
31
+ => /\A[^e-z]+/
32
+ ```
33
+
34
+ [Characters](/usage/characters.md ':include')
35
+
36
+ [Numbers](/usage/numbers.md ':include')
37
+
38
+ [AtModifier](/usage/atmodifier.md ':include')
39
+
40
+ [ExceptMod](/usage/exceptmod.md ':include')
41
+
42
+ ## Development
43
+
44
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+
46
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/LucHighwalker/regeng.
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
55
+
56
+ ## Changelog
57
+
58
+ [Changelog](/changelog.md ':include')
data/docs/changelog.md ADDED
@@ -0,0 +1,18 @@
1
+ [01-04-19] [0.2.5]: Now handles uppercase/lowercase with specified characters.
2
+
3
+ [01-02-19] [0.2.4]: Now processes more complex numbers.
4
+
5
+ [12-11-18] [0.2.3]: Now raises errors when expression fails to process.
6
+
7
+ [12-11-18] [0.2.2]: Now can use .new to mimic Regex behaviour.
8
+ Slightly expanded functionality.
9
+
10
+ [12-11-18] [0.2.1d]: Dev Build: At modifiers and simple digit expressions.
11
+
12
+ [12-10-18] [0.2.0d]: Dev Build: Refactored gem, refactored character functionality.
13
+
14
+ [12-09-18] [0.1.1]: Fixed changelog link... oops.
15
+
16
+ [12-09-18] [0.1.0]: Refactored prototype, now returns regular expressions.
17
+
18
+ [12-09-18] [0.0.1]: Initial prototype.
data/docs/index.html ADDED
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Document</title>
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7
+ <meta name="description" content="Description">
8
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9
+ <link rel="stylesheet" href="https://unpkg.com/docsify-themeable/dist/css/theme-simple-dark.css">
10
+ </head>
11
+ <body>
12
+ <div id="app"></div>
13
+ <script>
14
+ window.$docsify = {
15
+ name: '',
16
+ repo: ''
17
+ }
18
+ </script>
19
+ <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
20
+ </body>
21
+ </html>
@@ -0,0 +1,14 @@
1
+ ### At Modifier
2
+
3
+ The 'at' modifier can be used to indicate the start or end of a line or string.
4
+
5
+ ```ruby
6
+ Regeng.new 'any characters at start of line'
7
+ => /^[A-Za-z]+/
8
+ Regeng.new 'any characters at end of line'
9
+ => /$[A-Za-z]+/
10
+ Regeng.new 'any characters at start of string'
11
+ => /\A[A-Za-z]+/
12
+ Regeng.new 'any characters at end of string'
13
+ => /\z[A-Za-z]+/
14
+ ```
@@ -0,0 +1,43 @@
1
+ ### Characters
2
+
3
+ Use the 'to', 'through' or '-' indicator for ranges.
4
+ You can also use the 'and' indicator for ranges if the characters are preceeded with 'between' or 'from'.
5
+
6
+ ```ruby
7
+ Regeng.new 'character e to z'
8
+ Regeng.new 'character e through z'
9
+ Regeng.new 'character e-z'
10
+ Regeng.new 'character between e and z'
11
+ Regeng.new 'character from e and z'
12
+ => /[E-Ze-z]/
13
+ ```
14
+
15
+ Using 'and' as an indicator without 'between' or 'from' will result in exact matches.
16
+
17
+ ```ruby
18
+ Regeng.new 'character s o e and z'
19
+ => /[SOEZsoez]/
20
+ ```
21
+
22
+ Pluralizing 'character' will result in multiples.
23
+
24
+ ```ruby
25
+ Regeng.new 'characters e through z'
26
+ => /[E-Ze-z]+/
27
+ ```
28
+
29
+ Indicate 'any character(s)'
30
+
31
+ ```ruby
32
+ Regeng.new 'any characters'
33
+ => /[A-Za-z]+/
34
+ ```
35
+
36
+ Use an 'uppercase' or 'lowercase' modifier
37
+
38
+ ```ruby
39
+ Regeng.new 'any uppercase character e through z'
40
+ => /[E-Z]/
41
+ Regeng.new 'any lowercase character e through z'
42
+ => /[e-z]/
43
+ ```
@@ -0,0 +1,8 @@
1
+ ### Except Modifier
2
+
3
+ The 'except' modifier can be used to exclude matches.
4
+
5
+ ```ruby
6
+ Regeng.new 'any character except e through z'
7
+ => /[^E-Ze-z]/
8
+ ```
@@ -0,0 +1,43 @@
1
+ ### Numbers
2
+
3
+ Use either the 'number' or 'digit' keywords.
4
+
5
+ Use the 'to', 'through' or '-' indicator for ranges.
6
+ You can also use the 'and' indicator for ranges if the numbers are preceeded with 'between' or 'from'.
7
+
8
+ ```ruby
9
+ Regeng.new 'number 2 to 4'
10
+ Regeng.new 'number 2 through 4'
11
+ Regeng.new 'number 2-4'
12
+ Regeng.new 'number between 2 and 4'
13
+ Regeng.new 'number from 2 and 4'
14
+ => /[2-4]/
15
+ ```
16
+
17
+ Using the 'and' keyword will result in exact matches.
18
+
19
+ ```ruby
20
+ Regeng.new 'number 2 1 5 and 4'
21
+ => /[2154]/
22
+ ```
23
+
24
+ Pluralizing 'number' will result in multiples.
25
+
26
+ ```ruby
27
+ Regeng.new 'numbers 2 through 4'
28
+ => /[2-4]+/
29
+ ```
30
+
31
+ Indicate 'any number(s)'
32
+
33
+ ```ruby
34
+ Regeng.new 'any numbers'
35
+ => /[0-9]+/
36
+ ```
37
+
38
+ Regeng supports multiples of 10s. Currently both numbers must have the same amount of zeros.
39
+
40
+ ```ruby
41
+ Regeng.new 'number between 400 and 600'
42
+ => /(4[0-9][0-9])|(5[0-9][0-9])|(600)/
43
+ ```
data/lib/regeng.rb CHANGED
@@ -61,6 +61,16 @@ module Regeng
61
61
  character_mod = unfiltered_mod.to_s.gsub(/( )|(and )/, '')
62
62
  end
63
63
 
64
+ character_mod = character_mod.to_s
65
+
66
+ character_mod = if /(uppercase)/.match?(string)
67
+ character_mod.upcase
68
+ elsif /(lowercase)/.match?(string)
69
+ character_mod.downcase
70
+ else
71
+ "#{character_mod.upcase}#{character_mod.downcase}"
72
+ end
73
+
64
74
  Error.invalid_expression if character_mod.nil? || character_mod == '-'
65
75
 
66
76
  "[#{except}#{character_mod}]#{multiples}"
@@ -68,7 +78,7 @@ module Regeng
68
78
 
69
79
  # Processes simple character expressions.
70
80
  def self.characters_simple(string)
71
- character_mod = 'a-zA-Z'
81
+ character_mod = 'A-Za-z'
72
82
  multiples = '+' if /(character)(s)/.match?(string)
73
83
  if /(uppercase)/.match?(string)
74
84
  character_mod = 'A-Z'
@@ -103,7 +113,7 @@ module Regeng
103
113
  Error.invalid_expression if digit_mod.nil? || digit_mod == '-'
104
114
 
105
115
  if complex
106
- "#{digit_mod}"
116
+ digit_mod.to_s
107
117
  else
108
118
  "[#{except}#{digit_mod}]#{multiples}"
109
119
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Regeng
4
- VERSION = '0.2.4'
4
+ VERSION = '0.2.5'
5
5
  end
data/regeng.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = 'A gem which converts plain english to regular expressions.'
12
12
  # spec.description = %q{TODO: Write a longer description or delete this line.}
13
- spec.homepage = 'https://rubygems.org/gems/regeng'
13
+ spec.homepage = 'https://luchighwalker.github.io/regeng/'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.metadata['homepage_uri'] = spec.homepage
22
22
  spec.metadata['source_code_uri'] = 'https://github.com/LucHighwalker/regeng.git'
23
- spec.metadata['changelog_uri'] = 'https://github.com/LucHighwalker/regeng/blob/master/changelog.md'
23
+ spec.metadata['documentation_uri'] = 'https://luchighwalker.github.io/regeng/'
24
+ spec.metadata['changelog_uri'] = 'https://luchighwalker.github.io/regeng/#/?id=changelog'
24
25
  else
25
26
  raise 'RubyGems 2.0 or newer is required to protect against ' \
26
27
  'public gem pushes.'
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - LucHighwalker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-02 00:00:00.000000000 Z
11
+ date: 2019-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,18 +69,26 @@ files:
69
69
  - Rakefile
70
70
  - bin/console
71
71
  - bin/setup
72
- - changelog.md
72
+ - docs/.nojekyll
73
+ - docs/README.md
74
+ - docs/changelog.md
75
+ - docs/index.html
76
+ - docs/usage/atmodifier.md
77
+ - docs/usage/characters.md
78
+ - docs/usage/exceptmod.md
79
+ - docs/usage/numbers.md
73
80
  - lib/regeng.rb
74
81
  - lib/regeng/version.rb
75
82
  - regeng.gemspec
76
- homepage: https://rubygems.org/gems/regeng
83
+ homepage: https://luchighwalker.github.io/regeng/
77
84
  licenses:
78
85
  - MIT
79
86
  metadata:
80
87
  allowed_push_host: https://rubygems.org
81
- homepage_uri: https://rubygems.org/gems/regeng
88
+ homepage_uri: https://luchighwalker.github.io/regeng/
82
89
  source_code_uri: https://github.com/LucHighwalker/regeng.git
83
- changelog_uri: https://github.com/LucHighwalker/regeng/blob/master/changelog.md
90
+ documentation_uri: https://luchighwalker.github.io/regeng/
91
+ changelog_uri: https://luchighwalker.github.io/regeng/#/?id=changelog
84
92
  post_install_message:
85
93
  rdoc_options: []
86
94
  require_paths:
data/changelog.md DELETED
@@ -1,16 +0,0 @@
1
- [01-02-19][0.2.4]: Now processes more complex numbers.
2
-
3
- [12-11-18][0.2.3]: Now raises errors when expression fails to process.
4
-
5
- [12-11-18][0.2.2]: Now can use .new to mimic Regex behaviour.
6
- Slightly expanded functionality.
7
-
8
- [12-11-18][0.2.1d]: Dev Build: At modifiers and simple digit expressions.
9
-
10
- [12-10-18][0.2.0d]: Dev Build: Refactored gem, refactored character functionality.
11
-
12
- [12-09-18][0.1.1]: Fixed changelog link... oops.
13
-
14
- [12-09-18][0.1.0]: Refactored prototype, now returns regular expressions.
15
-
16
- [12-09-18][0.0.1]: Initial prototype.