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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6a4fcd3fc144bade4ae7c9c6203282f2bb60263e52b1dbb512e3e2f4aafbdc
4
- data.tar.gz: 78f75f9287faa5f86db07e8de720bf2acdc291e7c77a6dca00a980da6d27b691
3
+ metadata.gz: f12152322fbc0b75e36dcfc4dcc05497cdd16e1f47082949f42ee2af9bebae12
4
+ data.tar.gz: 2f267c665cb5ec0084a9d4752e57763a95f169b34719b4a478622f39ba5c7ece
5
5
  SHA512:
6
- metadata.gz: 8e3df07bd32de3879be644a9b2fc82982d0d8bb942f87f0c1c1391384063024675dd8564fe74dcacaaf0c59dd301ecd3cc2b825579136ddf66fa520033b1a326
7
- data.tar.gz: 21ff7155943997118c937ae08f7cc4727acafc12024b92c9866f205913210aee6480ad7663cc8df9a0f3c5407171d2ab3e8754083b1b87b057034ad855b89158
6
+ metadata.gz: c5ad2bed3658959228d70d592ebf9e6d34d3d14a3b928f945e1dfd916ea1f751a32a3c60fb342bff1e1a4385a9b034a97dd877a0e8ea5a3ecc2e6acf6e725d80
7
+ data.tar.gz: 5a8c239d1972737ecb21d6b15d7e64f4c806933d505f75d289aa42ccd3b34b65ea338d8995ecf65202ff70b9345f8c12be02d3880455f6fdf83857ebfff1169f
@@ -1,30 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adomain (0.1.0)
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.5.2)
11
- public_suffix (>= 2.0.2, < 4.0)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
12
13
  diff-lcs (1.3)
13
- public_suffix (3.0.1)
14
+ logger (1.4.1)
15
+ public_suffix (4.0.1)
14
16
  rake (10.5.0)
15
- rspec (3.7.0)
16
- rspec-core (~> 3.7.0)
17
- rspec-expectations (~> 3.7.0)
18
- rspec-mocks (~> 3.7.0)
19
- rspec-core (3.7.1)
20
- rspec-support (~> 3.7.0)
21
- rspec-expectations (3.7.0)
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.7.0)
24
- rspec-mocks (3.7.0)
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.7.0)
27
- rspec-support (3.7.1)
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.1
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
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
26
 
27
27
  spec.add_dependency "addressable", "~> 2.5"
28
+ spec.add_dependency "logger"
28
29
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Adomain
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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: 2018-02-15 00:00:00.000000000 Z
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.4
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