espressione 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3688e6a8017f44b3eb7915f9b010e8d54879716a92df3c78a88d3610851460a1
4
+ data.tar.gz: 8845ad31303f11e9627ad9e3a60913240cf51e0c80eaa2cd12990075adfb4e0d
5
+ SHA512:
6
+ metadata.gz: 83206eb888dd1ac611c6b83c827842f091329c1c71d105dc6e2ed5613d478e55db5a1a4c240231853e81d99ef4e579011859847ea0a74f77d385a65bd0b13b7f
7
+ data.tar.gz: 4befde357acb382389ec7db47f0cff88df914ab072b0bd4dddbafdc795db1dd424a4f24ee46439c0da8e2e754872543a49f5a8de7fa73bc952b74dfae1bd73a4
data/.gitignore ADDED
@@ -0,0 +1,77 @@
1
+ # Created by https://www.gitignore.io/api/vim,ruby
2
+ # Edit at https://www.gitignore.io/?templates=vim,ruby
3
+
4
+ ### Ruby ###
5
+ *.gem
6
+ *.rbc
7
+ /.config
8
+ /coverage/
9
+ /InstalledFiles
10
+ /pkg/
11
+ /spec/reports/
12
+ /spec/examples.txt
13
+ /test/tmp/
14
+ /test/version_tmp/
15
+ /tmp/
16
+
17
+ # Used by dotenv library to load environment variables.
18
+ # .env
19
+
20
+ # Ignore Byebug command history file.
21
+ .byebug_history
22
+
23
+ ## Specific to RubyMotion:
24
+ .dat*
25
+ .repl_history
26
+ build/
27
+ *.bridgesupport
28
+ build-iPhoneOS/
29
+ build-iPhoneSimulator/
30
+
31
+ ## Specific to RubyMotion (use of CocoaPods):
32
+ #
33
+ # We recommend against adding the Pods directory to your .gitignore. However
34
+ # you should judge for yourself, the pros and cons are mentioned at:
35
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
36
+ # vendor/Pods/
37
+
38
+ ## Documentation cache and generated files:
39
+ /.yardoc/
40
+ /_yardoc/
41
+ /doc/
42
+ /rdoc/
43
+
44
+ ## Environment normalization:
45
+ /.bundle/
46
+ /vendor/bundle
47
+ /lib/bundler/man/
48
+
49
+ # for a library or gem, you might want to ignore these files since the code is
50
+ # intended to run in multiple environments; otherwise, check them in:
51
+ # Gemfile.lock
52
+ # .ruby-version
53
+ # .ruby-gemset
54
+
55
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
56
+ .rvmrc
57
+
58
+ ### Vim ###
59
+ # Swap
60
+ [._]*.s[a-v][a-z]
61
+ [._]*.sw[a-p]
62
+ [._]s[a-rt-v][a-z]
63
+ [._]ss[a-gi-z]
64
+ [._]sw[a-p]
65
+
66
+ # Session
67
+ Session.vim
68
+
69
+ # Temporary
70
+ .netrwhist
71
+ *~
72
+ # Auto-generated tag files
73
+ tags
74
+ # Persistent undo
75
+ [._]*.un~
76
+
77
+ # End of https://www.gitignore.io/api/vim,ruby
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+
6
+ rvm:
7
+ - 2.5.3
8
+ - 2.4.5
9
+ - 2.3.8
10
+ - ruby-head
11
+
12
+ before_install:
13
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
14
+ - gem install bundler -v '< 2'
15
+
16
+ bundler_args:
17
+ --jobs 3 --retry 3
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ group :development, :test do
6
+ gem "byebug"
7
+ end
8
+
9
+ # Specify your gem's dependencies in espressione.gemspec
10
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ espressione (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ byebug (11.0.1)
10
+ concurrent-ruby (1.1.5)
11
+ diff-lcs (1.3)
12
+ docile (1.3.1)
13
+ faker (1.9.3)
14
+ i18n (>= 0.7)
15
+ i18n (1.6.0)
16
+ concurrent-ruby (~> 1.0)
17
+ json (2.2.0)
18
+ rake (10.5.0)
19
+ rspec (3.8.0)
20
+ rspec-core (~> 3.8.0)
21
+ rspec-expectations (~> 3.8.0)
22
+ rspec-mocks (~> 3.8.0)
23
+ rspec-core (3.8.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-expectations (3.8.2)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-mocks (3.8.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-support (3.8.0)
32
+ simplecov (0.16.1)
33
+ docile (~> 1.1)
34
+ json (>= 1.8, < 3)
35
+ simplecov-html (~> 0.10.0)
36
+ simplecov-html (0.10.2)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 2.0)
43
+ byebug
44
+ espressione!
45
+ faker (~> 1.9, >= 1.9.3)
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ simplecov (~> 0.16.1)
49
+
50
+ BUNDLED WITH
51
+ 2.0.1
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Espressione
2
+
3
+ [![Build Status](https://travis-ci.org/dvinciguerra/espressione.svg?branch=master)](https://travis-ci.org/dvinciguerra/espressione)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7b9cf8b8ff2f56e6da36/maintainability)](https://codeclimate.com/github/dvinciguerra/espressione/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/7b9cf8b8ff2f56e6da36/test_coverage)](https://codeclimate.com/github/dvinciguerra/espressione/test_coverage)
6
+
7
+ Espressione is a ruby gem to provide useful regex patterns.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'espressione'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install espressione
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ require "espressione"
29
+
30
+ # validate simple email
31
+ email = 'joe@doe.com'
32
+ puts "Contains a valid e-mail" if Espressione::EMAIL.match(email)
33
+
34
+ # validate url
35
+ url = "https://github.com/dvinciguerra"
36
+ puts "Contains a valid url" if Espressione::URL.match(url)
37
+
38
+ # validate a uuid
39
+ uuid = '8539ad20-317e-0137-4c89-7aa46e47cfb4'
40
+ puts "Contains a valid uuid" if Espressione::UUID.match(uuid)
41
+
42
+ # validate a datetime
43
+ datetime = Time.now.utc
44
+ puts "Contains a valid datetime" if Espressione::DATETIME.match(datetime.to_s)
45
+
46
+ # validate a ip
47
+ ip = '192.168.1.1'
48
+ puts "Contains a valid ip" if Espressione::IP.match(ip)
49
+ ```
50
+
51
+ ## Development
52
+
53
+ 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).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dvinciguerra/espressione.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require "espressione"
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "espressione"
10
+ spec.version = Espressione::VERSION
11
+ spec.license = 'MIT'
12
+ spec.authors = ["Daniel Vinciguerra"]
13
+ spec.email = ["daniel.vinciguerra@resultadosdigitais.com.br"]
14
+
15
+ spec.summary = "Ruby community-driven common regular expressions"
16
+ spec.description = "Espressione is a Ruby community-driven common regular expression patterns gem"
17
+ spec.homepage = "https://github.com/dvinciguerra/espressione"
18
+
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/dvinciguerra/espressione"
22
+ spec.metadata["changelog_uri"] = "https://github.com/dvinciguerra/espressione/blob/master/CHANGELOG.md"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
+ `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 2.0"
34
+ spec.add_development_dependency "faker", "~> 1.9", ">= 1.9.3"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency "simplecov", "~> 0.16.1"
38
+ end
data/example.rb ADDED
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH.unshift File.expand_path('./lib')
2
+
3
+ require "espressione"
4
+
5
+ # validate simple email
6
+ email = 'joe@doe.com'
7
+ puts "Contains a valid e-mail" if Espressione::EMAIL.match(email)
8
+
9
+ # validate url
10
+ url = "https://github.com/dvinciguerra"
11
+ puts "Contains a valid url" if Espressione::URL.match(url)
12
+
13
+ # validate a uuid
14
+ uuid = '8539ad20-317e-0137-4c89-7aa46e47cfb4'
15
+ puts "Contains a valid uuid" if Espressione::UUID.match(uuid)
16
+
17
+ # validate a datetime
18
+ datetime = Time.now.utc
19
+ puts "Contains a valid datetime" if Espressione::DATETIME.match(datetime.to_s)
20
+
21
+ # validate a ip
22
+ ip = '192.168.1.1'
23
+ puts "Contains a valid ip" if Espressione::IP.match(ip)
24
+
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "espressione/regex"
4
+
5
+ module Espressione
6
+ VERSION = "0.1.0"
7
+
8
+ include Espressione::Regex::ID
9
+ include Espressione::Regex::DateTime
10
+ include Espressione::Regex::Internet
11
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Espressione
4
+ module Regex
5
+ autoload :ID, "espressione/regex/id"
6
+ autoload :DateTime, "espressione/regex/datetime"
7
+ autoload :Internet, "espressione/regex/internet"
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Espressione
4
+ module Regex::DateTime
5
+ # datetime (iso format) pattern
6
+ DATETIME = /^\d{4}-\d{2}-\d{2}(\s|T)\d{2}:\d{2}:\d{2}(\s*(UTC|([\-\+]?(\d+|\d{2}:\d{2}))))*$/.freeze
7
+
8
+ # date yyyy/mm/dd pattern
9
+ DATE = /^\d{4}-\d{2}-\d{2}$/.freeze
10
+
11
+ # time pattern
12
+ TIME = /^\d{1,2}:\d{1,2}:\d{1,2}$/.freeze
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Espressione
4
+ module Regex::ID
5
+ # uuid pattern
6
+ UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.freeze
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Espressione
4
+ module Regex::Internet
5
+ # ip{v6} pattern
6
+ IP = /^((?:(?:^|\.)(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])){4})$/.freeze
7
+ IPV6 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/.freeze
8
+
9
+ # url pattern
10
+ URL = %r{\A(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:/[^\s]*)?\z}.freeze
11
+
12
+ # email pattern
13
+ EMAIL = %r{(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])}.freeze
14
+
15
+ # subdomain pattern
16
+ SUBDOMAIN = /([a-zA-Z0-9]+[a-zA-Z0-9\-]*[a-zA-Z0-9]+|([a-zA-Z]+[a-zA-Z0-9]*))/.freeze
17
+
18
+ # html tag pattern
19
+ HTML_TAG = %r{^<([a-z1-6]+)([^<]+)*(?:>(.*)</\1>| */>)$}.freeze
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: espressione
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Vinciguerra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-03 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.9.3
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.9'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.9.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 0.16.1
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 0.16.1
89
+ description: Espressione is a Ruby community-driven common regular expression patterns
90
+ gem
91
+ email:
92
+ - daniel.vinciguerra@resultadosdigitais.com.br
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - ".gitignore"
98
+ - ".rspec"
99
+ - ".travis.yml"
100
+ - CHANGELOG.md
101
+ - Gemfile
102
+ - Gemfile.lock
103
+ - README.md
104
+ - Rakefile
105
+ - espressione.gemspec
106
+ - example.rb
107
+ - lib/espressione.rb
108
+ - lib/espressione/regex.rb
109
+ - lib/espressione/regex/datetime.rb
110
+ - lib/espressione/regex/id.rb
111
+ - lib/espressione/regex/internet.rb
112
+ homepage: https://github.com/dvinciguerra/espressione
113
+ licenses:
114
+ - MIT
115
+ metadata:
116
+ homepage_uri: https://github.com/dvinciguerra/espressione
117
+ source_code_uri: https://github.com/dvinciguerra/espressione
118
+ changelog_uri: https://github.com/dvinciguerra/espressione/blob/master/CHANGELOG.md
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.7.6
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Ruby community-driven common regular expressions
139
+ test_files: []