qf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +30 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/qf +46 -0
- data/bin/setup +8 -0
- data/lib/qf.rb +5 -0
- data/lib/qf/version.rb +3 -0
- data/lib/rules.rb +14 -0
- data/qf.gemspec +24 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a45fe35781e069c9028f32df2267757cec043ba0
|
4
|
+
data.tar.gz: 4d2aa921777c30967b2cc9b3abbb64c5a6f4501b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01a309693226acaafea9f3fbd39b64edc6b1ca2393582219cc683e685767e3c8577bb2b105744a2d878dd6554204a798d9c6d10c667094ed601a150c8e88175f
|
7
|
+
data.tar.gz: b4f1722098f3142a84f42dc75cf32820beb2f303db29a4244331913aab5c9e2048933e7622bedfd20979bf694c82d2e821e6e08507de7b6146f75351c6469da5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
qf
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.3.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# qf
|
2
|
+
|
3
|
+
[![Travis](https://img.shields.io/travis/krmbzds/qf.svg)](https://travis-ci.org/krmbzds/qf)
|
4
|
+
[![Gem](https://img.shields.io/gem/dv/qf/stable.svg)](https://rubygems.org/gems/qf)
|
5
|
+
|
6
|
+
qf is a ruby gem that extracts specific substrings from a block of text. Examples of substrings are the following, but not limited to: emails, URIs, magnets links, ipv4, ipv6 addresses, etc.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'qf'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install qf
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
TODO: Write usage instructions here
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/krmbzds/qf.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "qf"
|
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
|
data/bin/qf
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
5
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require 'rules'
|
8
|
+
|
9
|
+
@help = '
|
10
|
+
Usage: qf [filter]
|
11
|
+
|
12
|
+
Options
|
13
|
+
-h, --help Prints this help page
|
14
|
+
-l, --list Lists available filters
|
15
|
+
|
16
|
+
Examples
|
17
|
+
qf url
|
18
|
+
qf magnet
|
19
|
+
qf creditcard
|
20
|
+
qf creditcard:visa
|
21
|
+
|
22
|
+
This application standard input and output.
|
23
|
+
|
24
|
+
'
|
25
|
+
|
26
|
+
def parse_options
|
27
|
+
arg = ARGV[0]
|
28
|
+
|
29
|
+
if arg
|
30
|
+
rule = Regexp.new RULES[arg]
|
31
|
+
begin
|
32
|
+
STDOUT.puts STDIN.read.scan(rule)
|
33
|
+
rescue
|
34
|
+
print_help
|
35
|
+
end
|
36
|
+
|
37
|
+
else
|
38
|
+
print_help
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def print_help
|
43
|
+
STDOUT.puts @help
|
44
|
+
end
|
45
|
+
|
46
|
+
parse_options
|
data/bin/setup
ADDED
data/lib/qf.rb
ADDED
data/lib/qf/version.rb
ADDED
data/lib/rules.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
RULES = {
|
2
|
+
'url' => '(?:https?|ftp):\/\/(?:-\.)?(?:[^\s/?\.#-]+\.?)+(?:\/[^\s]*)?',
|
3
|
+
'email' => '[a-zA-Z0-9_.+\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+',
|
4
|
+
'magnet' => 'magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32}',
|
5
|
+
'ipv4' => '(?:(?: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]?)',
|
6
|
+
'ipv6' => '(?:(?:::(?:[0-9a-f]{1,4}:){0,5}|[0-9a-f]{1,4}::(?:[0-9a-f]{1,4}:){0,4}|(?:[0-9a-f]{1,4}:){2}:(?:[0-9a-f]{1,4}:){0,3}|(?:[0-9a-f]{1,4}:){3}:(?:[0-9a-f]{1,4}:){0,2}|(?:[0-9a-f]{1,4}:){4}:(?:[0-9a-f]{1,4}:)?|(?:[0-9a-f]{1,4}:){5}:|(?:[0-9a-f]{1,4}:){6})(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})|:(?::|(?::[0-9a-f]{1,4}){1,7})|[0-9a-f]{1,4}:(?::|(?::[0-9a-f]{1,4}){1,6})|(?:[0-9a-f]{1,4}:){2}(?::|(?::[0-9a-f]{1,4}){1,5})|(?:[0-9a-f]{1,4}:){3}(?::|(?::[0-9a-f]{1,4}){1,4})|(?:[0-9a-f]{1,4}:){4}(?::|(?::[0-9a-f]{1,4}){1,3})|(?:[0-9a-f]{1,4}:){5}(?::|(?::[0-9a-f]{1,4}){1,2})|(?:[0-9a-f]{1,4}:){6}(?::|(?::[0-9a-f]{1,4}))|(?:[0-9a-f]{1,4}:){7}:|(?:[0-9a-f]{1,4}:){7}[0-9a-f]{1,4})(?:%[0-9a-z]+)?',
|
7
|
+
'iban' => '[a-zA-Z]{2}[0-9 ]{2}[a-zA-Z0-9 ]{4}[0-9 ]{7}(?:[a-zA-Z0-9 ]?){0,20}',
|
8
|
+
'creditcard' => '(?:\d[ -]*?){13,16}',
|
9
|
+
'visa' => '4[0-9]{12}(?:[0-9]{3})?',
|
10
|
+
'mastercard' => '5[1-5][0-9]{14}',
|
11
|
+
'amex' => '3[47][0-9]{13}',
|
12
|
+
'tckn'=> '\d{11}',
|
13
|
+
'gun' => 'GUN(?:DAM|TANK|CANON)'
|
14
|
+
}
|
data/qf.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'qf/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "qf"
|
8
|
+
spec.version = Qf::VERSION
|
9
|
+
spec.authors = ["Kerem Bozdas", "A. Besir Kurtulmus", "Umut Karci"]
|
10
|
+
spec.email = ["krmbzds.github@gmail.com", "besirkurtulmus@gmail.com", "cediddi@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Extract specific substrings from a block of text"
|
13
|
+
spec.description = "qf is a ruby gem that extracts specific substrings from a block of text. Examples of substrings are the following, but not limited to: emails, URIs, magnets links, ipv4, ipv6 addresses, etc."
|
14
|
+
spec.homepage = "http://krmbzds.github.io/qf"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'bin'
|
18
|
+
spec.executables = ['qf']
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kerem Bozdas
|
8
|
+
- A. Besir Kurtulmus
|
9
|
+
- Umut Karci
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.11'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.11'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '10.0'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '10.0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rspec
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '3.0'
|
57
|
+
description: 'qf is a ruby gem that extracts specific substrings from a block of text.
|
58
|
+
Examples of substrings are the following, but not limited to: emails, URIs, magnets
|
59
|
+
links, ipv4, ipv6 addresses, etc.'
|
60
|
+
email:
|
61
|
+
- krmbzds.github@gmail.com
|
62
|
+
- besirkurtulmus@gmail.com
|
63
|
+
- cediddi@gmail.com
|
64
|
+
executables:
|
65
|
+
- qf
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- ".gitignore"
|
70
|
+
- ".rspec"
|
71
|
+
- ".ruby-gemset"
|
72
|
+
- ".ruby-version"
|
73
|
+
- ".travis.yml"
|
74
|
+
- Gemfile
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- bin/console
|
78
|
+
- bin/qf
|
79
|
+
- bin/setup
|
80
|
+
- lib/qf.rb
|
81
|
+
- lib/qf/version.rb
|
82
|
+
- lib/rules.rb
|
83
|
+
- qf.gemspec
|
84
|
+
homepage: http://krmbzds.github.io/qf
|
85
|
+
licenses: []
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.5.1
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Extract specific substrings from a block of text
|
107
|
+
test_files: []
|