handy_regexps 0.0.1

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.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ coverage
3
+ rdoc
4
+ pkg
5
+ *.gem
6
+ *.gemspec
7
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in handy_regexps.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Macario
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ = hady-regexps
2
+
3
+ Email and Url so far
4
+
5
+
6
+
7
+ == Copyright
8
+
9
+ Copyright (c) 2010 Macario. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList['test/test*.rb']
8
+ t.verbose = true
9
+ end
@@ -0,0 +1,3 @@
1
+ module HandyRegexps
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,49 @@
1
+ module HandyRegexps
2
+ DomainName = %r{
3
+ \b
4
+ # Match the leading part (proto://hostname, or just hostname)
5
+ (
6
+ # http://, or https:// leading part
7
+ (https?)://[-\w]+(\.\w[-\w]*)+
8
+ |
9
+ # or, try to find a hostname with more specific sub-expression
10
+ (?i: [a-z0-9] (?:[-a-z0-9]*[a-z0-9])? \. )+ # sub domains
11
+ # Now ending .com, etc. For these, require lowercase
12
+ (?-i: com\b
13
+ | edu\b
14
+ | name\b
15
+ | biz\b
16
+ | gov\b
17
+ | in(?:t|fo)\b # .int or .info
18
+ | mil\b
19
+ | net\b
20
+ | org\b
21
+ | [a-z][a-z]\b
22
+ | [a-z][a-z]\.[a-z][a-z]\b # two-letter country code
23
+ )
24
+ )
25
+ }ix
26
+
27
+ Url = %r{
28
+ #{DomainName}
29
+ # Allow an optional port number
30
+ ( : \d+ )?
31
+
32
+ # The rest of the URL is optional, and begins with /
33
+ (
34
+ /
35
+ # The rest are heuristics for what seems to work well
36
+ [^.!,?;"'<>()\[\]\{\}\s\x7F-\xFF]*
37
+ (
38
+ [.!,?]+ [^.!,?;"'<>()\[\]\{\}\s\x7F-\xFF]+
39
+ )*
40
+ )?
41
+ # http://immike.net/blog/2007/04/06/5-regular-expressions-every-web-programmer-should-know/
42
+ }ix
43
+
44
+ Email = %r{
45
+ [a-z0-9!\#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!\#$%&'*+/=?^_`{|}~-]+)*
46
+ @
47
+ #{DomainName}
48
+ }ix
49
+ end
@@ -0,0 +1,26 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'ffaker'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+
7
+ require 'handy_regexps'
8
+
9
+ describe HandyRegexps do
10
+ 100.times do
11
+ email = Faker::Internet.email
12
+ it "should match email '#{email}'" do
13
+ email.must_match HandyRegexps::Email
14
+ end
15
+
16
+ domain = Faker::Internet.domain_name
17
+ it "should match domain '#{domain}'" do
18
+ domain.must_match HandyRegexps::Url
19
+ end
20
+
21
+ uri = Faker::Internet.uri('http')
22
+ it "should match url '#{uri}'" do
23
+ uri.must_match HandyRegexps::Url
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: handy_regexps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Macario
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ffaker
16
+ requirement: &26759580 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *26759580
25
+ description: Some useful regular expressions
26
+ email:
27
+ - mail@makarius.me
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .document
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - lib/handy_regexps.rb
39
+ - lib/handy_regexps/version.rb
40
+ - test/test_hady_regexps.rb
41
+ homepage: http://github.com/maca/handy_regexps
42
+ licenses: []
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 1.8.11
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Some useful regular expressions
65
+ test_files:
66
+ - test/test_hady_regexps.rb
67
+ has_rdoc: