twingly-url 4.1.0 → 4.2.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 +4 -4
- data/README.md +43 -1
- data/lib/twingly/url.rb +8 -0
- data/lib/twingly/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e450e3b0005ae549f7465be270f474d921f1c5bd
|
4
|
+
data.tar.gz: 897b0ff72f7d298edd7846068d6d3ae4a0197cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56efced017c87d78a72ef97cf2d98f89c5e2329b79d9ca55440d4564b5c24edd8a95d9f3ce3bf9ff65d23ca58990269fd02c7244abe12cd686b15da061e7ab9a
|
7
|
+
data.tar.gz: 0fc17c60dafbbd9278f5ad1aee81553c42bf76e1734eacd45e944e2700f3770e6a0a3056630efec5c8274ed61d3ccc5e5deec95f34d079c7048390eca64e1245
|
data/README.md
CHANGED
@@ -15,10 +15,47 @@ Twingly URL tools.
|
|
15
15
|
* `twingly/url/utilities` - Utilities to work with URLs
|
16
16
|
* `Twingly::URL::Utilities.extract_valid_urls` - Returns Array of valid `Twingly::URL`
|
17
17
|
|
18
|
-
##
|
18
|
+
## Getting Started
|
19
|
+
|
20
|
+
Install the gem:
|
19
21
|
|
20
22
|
gem install twingly-url
|
21
23
|
|
24
|
+
Usage (this output was created with [`examples/url.rb`][examples]):
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require "twingly/url"
|
28
|
+
|
29
|
+
url = Twingly::URL.parse("http://www.twingly.co.uk/search")
|
30
|
+
url.scheme # => "http"
|
31
|
+
url.trd # => "www"
|
32
|
+
url.sld # => "twingly"
|
33
|
+
url.tld # => "co.uk"
|
34
|
+
url.ttld # => "uk"
|
35
|
+
url.domain # => "twingly.co.uk"
|
36
|
+
url.host # => "www.twingly.co.uk"
|
37
|
+
url.origin # => "http://www.twingly.co.uk"
|
38
|
+
url.path # => "/search"
|
39
|
+
url.without_scheme # => "//www.twingly.co.uk/search"
|
40
|
+
url.valid? # => "true"
|
41
|
+
|
42
|
+
url = Twingly::URL.parse("https://admin:correcthorsebatterystaple@example.com/")
|
43
|
+
url.scheme # => "https"
|
44
|
+
url.trd # => ""
|
45
|
+
url.sld # => "example"
|
46
|
+
url.tld # => "com"
|
47
|
+
url.ttld # => "com"
|
48
|
+
url.domain # => "example.com"
|
49
|
+
url.host # => "example.com"
|
50
|
+
url.origin # => "https://example.com"
|
51
|
+
url.path # => "/"
|
52
|
+
url.without_scheme # => "//admin:correcthorsebatterystaple@example.com/"
|
53
|
+
url.userinfo # => "admin:correcthorsebatterystaple"
|
54
|
+
url.user # => "admin"
|
55
|
+
url.password # => "correcthorsebatterystaple"
|
56
|
+
url.valid? # => "true"
|
57
|
+
```
|
58
|
+
|
22
59
|
### Dependencies
|
23
60
|
|
24
61
|
The gem requires libidn.
|
@@ -42,6 +79,10 @@ Note that this isn't a benchmark, we're using [ruby-prof] which will slow things
|
|
42
79
|
|
43
80
|
## Release workflow
|
44
81
|
|
82
|
+
* Update the [examples] in this README if needed, generate the output with
|
83
|
+
|
84
|
+
ruby examples/url.rb
|
85
|
+
|
45
86
|
* Bump the version in `lib/twingly/version.rb` in a commit, no need to push (the release task does that).
|
46
87
|
|
47
88
|
* Make sure you are logged in as [twingly][twingly-rubygems] at RubyGems.org.
|
@@ -52,3 +93,4 @@ Note that this isn't a benchmark, we're using [ruby-prof] which will slow things
|
|
52
93
|
|
53
94
|
[twingly-rubygems]: https://rubygems.org/profiles/twingly
|
54
95
|
[ruby-prof]: http://ruby-prof.rubyforge.org/
|
96
|
+
[examples]: examples/url.rb
|
data/lib/twingly/url.rb
CHANGED
@@ -100,6 +100,14 @@ module Twingly
|
|
100
100
|
public_suffix_domain.tld
|
101
101
|
end
|
102
102
|
|
103
|
+
# Many ccTLDs have a second level[1] underneath their ccTLD, use this when
|
104
|
+
# you don't care about the second level.
|
105
|
+
#
|
106
|
+
# [1]: https://en.wikipedia.org/wiki/Second-level_domain
|
107
|
+
def ttld
|
108
|
+
tld.split(".").last
|
109
|
+
end
|
110
|
+
|
103
111
|
def domain
|
104
112
|
public_suffix_domain.domain
|
105
113
|
end
|
data/lib/twingly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twingly-url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Twingly AB
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Twingly URL tools
|
98
112
|
email:
|
99
113
|
- support@twingly.com
|