mask_man 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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mask_man/convert.rb +7 -0
- data/lib/mask_man/validate.rb +56 -0
- data/lib/mask_man/version.rb +3 -0
- data/lib/mask_man.rb +6 -0
- data/mask_man.gemspec +26 -0
- metadata +100 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1681b9c87b78ad8dcfe09da091a6f4ce279bf75b
|
|
4
|
+
data.tar.gz: d6436d6a30a764deef51840ef668e74ef00788c5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c07b179ce8851e2270ead42bcbcc089b62b367d4eaf70f14285f1447862363f55440fb59f721a6c48bc93309ac90836df106a08ed1a172aa9b3649db4efdb818
|
|
7
|
+
data.tar.gz: f952d0b360b8d9a044174b8e98feba5e15df042f95f810c6ee3d737fa6e701c9c08fe2d700439bdc9a9a1a5d9f13e32d31eb214ddba496647475fc6ebe2df88f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Icaro Falcao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# MaskMan
|
|
2
|
+
|
|
3
|
+
> Abstraction of the most common regular expressions (Regex) for your Ruby application. Validate and convert your strings fast and easy with Maskman. See **Usage** for more instructions and examples.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'mask_man'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install mask_man
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
We currently have 2 modules: `Convert` and `Validate`, let's see a example for each.
|
|
24
|
+
|
|
25
|
+
If you want to remove all special characters from your string, that's fairly simple with MaskMan, just do as below:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
require MaskMan
|
|
29
|
+
|
|
30
|
+
MaskMan::Convert.rm_special(your_string_here)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
But in case you want to check the presence of a special character within your string, you can use:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
require MaskMan
|
|
37
|
+
|
|
38
|
+
MaskMan::Validate.has_special_chars?(your_string_here)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
Be sure to create the test cases for your new feature, we are using [RSpec](https://github.com/rspec/rspec-rails) to accomplish this.
|
|
46
|
+
|
|
47
|
+
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).
|
|
48
|
+
|
|
49
|
+
## Contributing
|
|
50
|
+
|
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/iFalcao/mask_man.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "mask_man"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module MaskMan
|
|
2
|
+
class Validate
|
|
3
|
+
|
|
4
|
+
SPECIAL_CHARS = ['*', '-', '(', ')', '/', '|', '\\', '#', '$', '%', '&', '.']
|
|
5
|
+
|
|
6
|
+
def self.has_special_chars?(string)
|
|
7
|
+
contains = false
|
|
8
|
+
|
|
9
|
+
string.each_char do |char|
|
|
10
|
+
if SPECIAL_CHARS.include?(char)
|
|
11
|
+
contains = true
|
|
12
|
+
break
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
contains
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.only_asc?(string)
|
|
20
|
+
only_asc = true
|
|
21
|
+
|
|
22
|
+
string.each_byte do |byte|
|
|
23
|
+
if byte > 127
|
|
24
|
+
only_asc = false
|
|
25
|
+
break
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
only_asc
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.count_special_chars(string)
|
|
33
|
+
count = 0
|
|
34
|
+
string.each_char { |char| count += 1 if SPECIAL_CHARS.include?(char) }
|
|
35
|
+
return count
|
|
36
|
+
end
|
|
37
|
+
=begin
|
|
38
|
+
TODOS:
|
|
39
|
+
def only_words?
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def only_numbers?
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def has_numbers?
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def has_words?
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
=end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/mask_man.rb
ADDED
data/mask_man.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "mask_man/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "mask_man"
|
|
8
|
+
spec.version = MaskMan::VERSION
|
|
9
|
+
spec.summary = %q{Abstraction of common regular expressions(regex) in Ruby}
|
|
10
|
+
spec.authors = ["Icaro Falcao"]
|
|
11
|
+
spec.email = ["vbsfalcao@gmail.com"]
|
|
12
|
+
spec.description = %q{Abstraction of common regular expressions(regex) in Ruby}
|
|
13
|
+
spec.homepage = "https://github.com/iFalcao/mask_man"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
|
18
|
+
end
|
|
19
|
+
spec.bindir = "exe"
|
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
21
|
+
spec.require_paths = ["lib"]
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mask_man
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Icaro Falcao
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-11-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
description: Abstraction of common regular expressions(regex) in Ruby
|
|
56
|
+
email:
|
|
57
|
+
- vbsfalcao@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".rspec"
|
|
64
|
+
- ".travis.yml"
|
|
65
|
+
- Gemfile
|
|
66
|
+
- LICENSE.txt
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- bin/console
|
|
70
|
+
- bin/setup
|
|
71
|
+
- lib/mask_man.rb
|
|
72
|
+
- lib/mask_man/convert.rb
|
|
73
|
+
- lib/mask_man/validate.rb
|
|
74
|
+
- lib/mask_man/version.rb
|
|
75
|
+
- mask_man.gemspec
|
|
76
|
+
homepage: https://github.com/iFalcao/mask_man
|
|
77
|
+
licenses:
|
|
78
|
+
- MIT
|
|
79
|
+
metadata: {}
|
|
80
|
+
post_install_message:
|
|
81
|
+
rdoc_options: []
|
|
82
|
+
require_paths:
|
|
83
|
+
- lib
|
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">="
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
requirements: []
|
|
95
|
+
rubyforge_project:
|
|
96
|
+
rubygems_version: 2.6.11
|
|
97
|
+
signing_key:
|
|
98
|
+
specification_version: 4
|
|
99
|
+
summary: Abstraction of common regular expressions(regex) in Ruby
|
|
100
|
+
test_files: []
|