adomain 0.1.1 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6a4fcd3fc144bade4ae7c9c6203282f2bb60263e52b1dbb512e3e2f4aafbdc
4
- data.tar.gz: 78f75f9287faa5f86db07e8de720bf2acdc291e7c77a6dca00a980da6d27b691
3
+ metadata.gz: 83a5d692e2425fec3d5bbc93a753d7c96a73223f2c0e63c13cb7554519dccf86
4
+ data.tar.gz: 29d37fcdca4db2f997c4d473b012a06677e06e0d713899e4e76569f2ad2ce630
5
5
  SHA512:
6
- metadata.gz: 8e3df07bd32de3879be644a9b2fc82982d0d8bb942f87f0c1c1391384063024675dd8564fe74dcacaaf0c59dd301ecd3cc2b825579136ddf66fa520033b1a326
7
- data.tar.gz: 21ff7155943997118c937ae08f7cc4727acafc12024b92c9866f205913210aee6480ad7663cc8df9a0f3c5407171d2ab3e8754083b1b87b057034ad855b89158
6
+ metadata.gz: 3f9ffd06b85aac9718c5d450125838acc7a38034fa805f5578c621d70522e3d33dbe451c988c56c6a593d9b0e2359fca128975599f53a21956883c1fc8993d2d
7
+ data.tar.gz: ae911c83f0e65a877837b3fb8cd4eeacf2d9058f380b2a07da48369880d532bb7c04eb2747196c5f0aaa68c1b2ba962adf5bfbd730eef53a5bb0924a3416a783
data/Gemfile.lock CHANGED
@@ -1,30 +1,32 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- adomain (0.1.0)
4
+ adomain (0.1.2)
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.9.0)
18
+ rspec-core (~> 3.9.0)
19
+ rspec-expectations (~> 3.9.0)
20
+ rspec-mocks (~> 3.9.0)
21
+ rspec-core (3.9.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-expectations (3.9.0)
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.9.0)
26
+ rspec-mocks (3.9.0)
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.9.0)
29
+ rspec-support (3.9.0)
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.17.3
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
@@ -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,3 +1,3 @@
1
1
  class Adomain
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/adomain.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "adomain/version"
2
2
  require "addressable/uri"
3
+ require "logger"
3
4
 
4
5
  class Adomain
5
6
  class << self
@@ -40,6 +41,22 @@ class Adomain
40
41
  subdomain(string, true)
41
42
  end
42
43
 
44
+ # scheme is a wrapper around Addressable::URI's scheme
45
+ # it is only included for convenience
46
+ def scheme(string)
47
+ Addressable::URI.parse(string).scheme
48
+ rescue Addressable::URI::InvalidURIError => e
49
+ nil
50
+ end
51
+
52
+ # path is a wrapper around Addressable::URI's path
53
+ # it is only included for convenience
54
+ def path(string)
55
+ Addressable::URI.parse(string).path
56
+ rescue Addressable::URI::InvalidURIError => e
57
+ nil
58
+ end
59
+
43
60
  private
44
61
  # parse_for_domain accepts one hash of arguments that allow
45
62
  # changes to the parsing behavior of domains
@@ -75,6 +92,12 @@ class Adomain
75
92
  domain ||= uri.host
76
93
 
77
94
  return domain
95
+ rescue Addressable::URI::InvalidURIError => e
96
+ nil
78
97
  end
98
+
99
+ def logger
100
+ @logger ||= defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
101
+ end # https://stackoverflow.com/a/30623846/1651458
79
102
  end
80
103
  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.2.0
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-11-11 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
@@ -106,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
120
  - !ruby/object:Gem::Version
107
121
  version: '0'
108
122
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.7.4
123
+ rubygems_version: 3.0.6
111
124
  signing_key:
112
125
  specification_version: 4
113
126
  summary: Simple, uncomplicated, schemed domain parsing using Addressable