adomain 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +18 -16
- data/README.md +14 -0
- data/adomain.gemspec +1 -0
- data/lib/adomain.rb +17 -0
- data/lib/adomain/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f12152322fbc0b75e36dcfc4dcc05497cdd16e1f47082949f42ee2af9bebae12
|
4
|
+
data.tar.gz: 2f267c665cb5ec0084a9d4752e57763a95f169b34719b4a478622f39ba5c7ece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5ad2bed3658959228d70d592ebf9e6d34d3d14a3b928f945e1dfd916ea1f751a32a3c60fb342bff1e1a4385a9b034a97dd877a0e8ea5a3ecc2e6acf6e725d80
|
7
|
+
data.tar.gz: 5a8c239d1972737ecb21d6b15d7e64f4c806933d505f75d289aa42ccd3b34b65ea338d8995ecf65202ff70b9345f8c12be02d3880455f6fdf83857ebfff1169f
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
adomain (0.1.
|
4
|
+
adomain (0.1.1)
|
5
5
|
addressable (~> 2.5)
|
6
|
+
logger
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
addressable (2.
|
11
|
-
public_suffix (>= 2.0.2, <
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
13
|
diff-lcs (1.3)
|
13
|
-
|
14
|
+
logger (1.4.1)
|
15
|
+
public_suffix (4.0.1)
|
14
16
|
rake (10.5.0)
|
15
|
-
rspec (3.
|
16
|
-
rspec-core (~> 3.
|
17
|
-
rspec-expectations (~> 3.
|
18
|
-
rspec-mocks (~> 3.
|
19
|
-
rspec-core (3.
|
20
|
-
rspec-support (~> 3.
|
21
|
-
rspec-expectations (3.
|
17
|
+
rspec (3.8.0)
|
18
|
+
rspec-core (~> 3.8.0)
|
19
|
+
rspec-expectations (~> 3.8.0)
|
20
|
+
rspec-mocks (~> 3.8.0)
|
21
|
+
rspec-core (3.8.2)
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-expectations (3.8.4)
|
22
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-mocks (3.
|
25
|
+
rspec-support (~> 3.8.0)
|
26
|
+
rspec-mocks (3.8.1)
|
25
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-support (3.
|
28
|
+
rspec-support (~> 3.8.0)
|
29
|
+
rspec-support (3.8.2)
|
28
30
|
|
29
31
|
PLATFORMS
|
30
32
|
ruby
|
@@ -36,4 +38,4 @@ DEPENDENCIES
|
|
36
38
|
rspec (~> 3.0)
|
37
39
|
|
38
40
|
BUNDLED WITH
|
39
|
-
1.16.
|
41
|
+
1.16.6
|
data/README.md
CHANGED
@@ -57,6 +57,20 @@ Adomain["hola"] # => nil
|
|
57
57
|
Adomain["::::::::"] # => nil
|
58
58
|
Adomain[""] # => Addressable::URI::InvalidURIError
|
59
59
|
Adomain["{}"] # => Addressable::URI::InvalidURIError
|
60
|
+
Gem::Version.new(Adomain::VERSION) >= Gem::Version.new(0.2) # => false
|
61
|
+
```
|
62
|
+
|
63
|
+
#### WARNING: All InvalidURIError will be caught in >= version 0.2
|
64
|
+
|
65
|
+
When 0.2 is released, `Addressable::URI::InvalidURIError`s will be caught
|
66
|
+
and ignored. Nil will be returned.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
Gem::Version.new(Adomain::VERSION) >= Gem::Version.new(0.2) # => true
|
70
|
+
Adomain["hola"] # => nil
|
71
|
+
Adomain["::::::::"] # => nil
|
72
|
+
Adomain[""] # => nil
|
73
|
+
Adomain["{}"] # => nil
|
60
74
|
```
|
61
75
|
|
62
76
|
## Installation
|
data/adomain.gemspec
CHANGED
data/lib/adomain.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
require "adomain/version"
|
2
2
|
require "addressable/uri"
|
3
|
+
require "logger"
|
3
4
|
|
4
5
|
class Adomain
|
5
6
|
class << self
|
7
|
+
|
8
|
+
ADDRESSABLE_WARNING = %{
|
9
|
+
WARNING: breaking change planned:
|
10
|
+
Adomain will catch Addressable::URI::InvalidURIError.
|
11
|
+
This error will be caught in version 0.2.
|
12
|
+
Any code relying on the error will break.
|
13
|
+
}.gsub(/\s+/, ' ').strip
|
14
|
+
|
6
15
|
# [] is a convenience method to subdomain the URL,
|
7
16
|
# or optionally domain or subdomain_www.
|
8
17
|
# Adomain["http://abc.xyz.com"] # => "abc.xyz.com"
|
@@ -75,6 +84,14 @@ class Adomain
|
|
75
84
|
domain ||= uri.host
|
76
85
|
|
77
86
|
return domain
|
87
|
+
rescue Addressable::URI::InvalidURIError => e
|
88
|
+
logger.warn ADDRESSABLE_WARNING
|
89
|
+
|
90
|
+
raise e
|
78
91
|
end
|
92
|
+
|
93
|
+
def logger
|
94
|
+
@logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
95
|
+
end # https://stackoverflow.com/a/30623846/1651458
|
79
96
|
end
|
80
97
|
end
|
data/lib/adomain/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adomain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Nissen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: logger
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- scnissen@gmail.com
|
@@ -107,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
121
|
version: '0'
|
108
122
|
requirements: []
|
109
123
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.7.
|
124
|
+
rubygems_version: 2.7.10
|
111
125
|
signing_key:
|
112
126
|
specification_version: 4
|
113
127
|
summary: Simple, uncomplicated, schemed domain parsing using Addressable
|