linkable 0.0.1.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d47ab4de4b09f525bc00096211ab2040cc126ea7
4
+ data.tar.gz: 955e3c4ef40b02e8bbe28b2af55816e51f24c217
5
+ SHA512:
6
+ metadata.gz: 671802f3d6603b346b37504921daa2eb04c9650436b572b22477059fae6e7f1b6e4de1c7b304ff67bb879f8f35e1307d75661c99957812cf626abd77bdfb16fe
7
+ data.tar.gz: 7053dfe30a4b930d5cac893fc7d25d5f6af3bed4272528e3ec1209103dfdbd7bb2e9550eb05057abf2cd55567ad6751b5e72bac13b43fb9babe057509dcb9e2c
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ /.yardoc/
13
+ /_yardoc/
14
+ /doc/
15
+ /rdoc/
16
+
17
+ /.bundle/
18
+ /lib/bundler/man/
19
+
20
+ Gemfile.lock
21
+ .ruby-version
22
+ .ruby-gemset
23
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require helper
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Philip Vieira
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.
@@ -0,0 +1,31 @@
1
+ # Linkable
2
+ Parsing libraries been getting outdated as the web evolve. Linkable takes a scalable approach supporting gTLDs, custom schemas and complex query parameters.
3
+
4
+ ## Usage
5
+
6
+ ```ruby
7
+ require "linkable"
8
+
9
+ string = "Have you heard that github.com/zeeraw/linkable will detect your proprietary://special.snowflake.domain domain."
10
+ string.urls
11
+ # => ["github.com/zeeraw/linkable", "proprietary://special.snowflake.domain"]
12
+ ```
13
+
14
+ ## Installation
15
+ Add this line to your project's Gemfile:
16
+
17
+ ```ruby
18
+ gem "linkable"
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ ```bash
24
+ $ bundle
25
+ ```
26
+
27
+ Or install it yourself as:
28
+
29
+ ```bash
30
+ $ gem install linkable
31
+ ```
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,12 @@
1
+ require "linkable/version"
2
+ require "linkable/expression"
3
+
4
+ module Linkable
5
+
6
+ def urls
7
+ self.scan(Linkable::EXPRESSION).map(&:first)
8
+ end
9
+
10
+ end
11
+
12
+ String.include(Linkable)
@@ -0,0 +1,3 @@
1
+ module Linkable
2
+ EXPRESSION = /(?<=\A|\s)(((\w+\:)??\/\/)?(([\w\-]+\.){1,}[\w\-]+)(\/[^\? ]+)?([^\s]+)?)(?=\z|\s)/
3
+ end
@@ -0,0 +1,3 @@
1
+ module Linkable
2
+ VERSION = "0.0.1.pre1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'linkable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "linkable"
8
+ spec.version = Linkable::VERSION
9
+ spec.authors = ["Philip Vieira"]
10
+ spec.email = ["philip@vallin.se"]
11
+ spec.summary = %q{Next generation ruby URL parser.}
12
+ spec.description = %q{Parsing libraries been getting outdated as the web evolve. Linkable takes a scalable approach supporting gTLDs, custom schemas and complex query parameters.}
13
+ spec.homepage = "https://github.com/zeeraw/linkable"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.1.0"
24
+ spec.add_development_dependency "pry"
25
+ end
@@ -0,0 +1,29 @@
1
+ require "pry"
2
+ require "linkable"
3
+
4
+ RSpec.configure do |config|
5
+
6
+ config.expect_with :rspec do |expectations|
7
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
8
+ end
9
+
10
+ config.mock_with :rspec do |mocks|
11
+ mocks.verify_partial_doubles = true
12
+ end
13
+
14
+ config.filter_run :focus
15
+ config.run_all_when_everything_filtered = true
16
+ config.disable_monkey_patching!
17
+
18
+ config.warnings = true
19
+
20
+ if config.files_to_run.one?
21
+ config.default_formatter = "doc"
22
+ end
23
+
24
+ config.profile_examples = false
25
+ config.order = :random
26
+
27
+ Kernel.srand config.seed
28
+
29
+ end
@@ -0,0 +1,64 @@
1
+ RSpec.describe Linkable do
2
+
3
+ let(:text) { %Q(
4
+ This is a domain called #{ domain } which is my favorite domain.
5
+ I can have query parameters in #{ apex_domain } isn't it cool?
6
+ Subdomains work too #{ subdomain } the ones with query params too
7
+ #{ multiple_subdomains } (those are simply the best).
8
+
9
+ Even the silly ones with numbers & dashes #{ complex_hostname } are fully functional.
10
+
11
+ Got a super cool custom schema? #{ custom_schema } is problem what so ever!
12
+
13
+ Schema relative URLs are pretty common these days, if you need it, we got it #{ schema_relative }
14
+
15
+ And for the grand finale is when you put another domain in the query params #{ url_in_query_parameters } WOW!"
16
+ ) }
17
+
18
+ describe "String#urls" do
19
+
20
+ subject(:urls) { text.urls }
21
+
22
+ let(:domain) { "www.domain.com" }
23
+ it "parses domain" do
24
+ expect(urls).to include domain
25
+ end
26
+
27
+ let(:apex_domain) { "domain.com?foo=bar" }
28
+ it "parses apex domain" do
29
+ expect(urls).to include apex_domain
30
+ end
31
+
32
+ let(:subdomain) { "sub.domain.com" }
33
+ it "parses subdomain" do
34
+ expect(urls).to include subdomain
35
+ end
36
+
37
+ let(:multiple_subdomains) { "second.sub.doma.in/foo/bar?baz=biz" }
38
+ it "parses multiple subdomains" do
39
+ expect(urls).to include multiple_subdomains
40
+ end
41
+
42
+ let(:complex_hostname) { "domain.w1th-d4shes-4nd-numbe.rs" }
43
+ it "parses complex hostnames" do
44
+ expect(urls).to include complex_hostname
45
+ end
46
+
47
+ let(:custom_schema) { "protocol://with.domain.com?queries=too" }
48
+ it "parses custom schema" do
49
+ expect(urls).to include custom_schema
50
+ end
51
+
52
+ let(:schema_relative) { "//with.domain.com?queries=too" }
53
+ it "parses schema relative" do
54
+ expect(urls).to include schema_relative
55
+ end
56
+
57
+ let(:url_in_query_parameters) { "domain.w1th-d4shes-4nd-numbe.rs/foobar?is=http://www.another-domain.com" }
58
+ it "parses domain in query parameters" do
59
+ expect(urls).to include url_in_query_parameters
60
+ end
61
+
62
+ end
63
+
64
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linkable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre1
5
+ platform: ruby
6
+ authors:
7
+ - Philip Vieira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-11 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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.1.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.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Parsing libraries been getting outdated as the web evolve. Linkable takes
70
+ a scalable approach supporting gTLDs, custom schemas and complex query parameters.
71
+ email:
72
+ - philip@vallin.se
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/linkable.rb
84
+ - lib/linkable/expression.rb
85
+ - lib/linkable/version.rb
86
+ - linkable.gemspec
87
+ - spec/helper.rb
88
+ - spec/linkable_spec.rb
89
+ homepage: https://github.com/zeeraw/linkable
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">"
105
+ - !ruby/object:Gem::Version
106
+ version: 1.3.1
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Next generation ruby URL parser.
113
+ test_files:
114
+ - spec/helper.rb
115
+ - spec/linkable_spec.rb