twingly-url 2.0.0 → 3.0.0

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
  SHA1:
3
- metadata.gz: 2332efd0ec1df89e43ac8c6dbfe50e32111ee4e1
4
- data.tar.gz: f9242f3818d99ef4b49d997898fd22fba951ea9d
3
+ metadata.gz: b66f417f0fe41cd5079277a287138abdbf43c310
4
+ data.tar.gz: 6f113bf8c3b862541943caac45b69e440c2b76f3
5
5
  SHA512:
6
- metadata.gz: 614aac135b4e9c8fe61dbf9f0e5c13928c5e71f7b552bf980f6ae3331a17eb6cfcbd2d6421d5fdaf49bca9fca723d4a188c1585b8e7b77987a6cd8b27d9abcbc
7
- data.tar.gz: 9d33a5f6ebb37eb410779cd40350df8bea3f7ffad72f93e8b8015e0dca086c3a86b66110cde34c28ac05a1da08985aeee2b46eba9fd6e0b4dce6f56e5e01e7f2
6
+ metadata.gz: 9055372e2fe3732ca1bf2dcbdbd82a7e83e2ed674b5ce90816c71aa8d8486ef3c82cf2ab7bab8aa507afac1b2987298dd23f3230a6769c86dc489a982e49f9e4
7
+ data.tar.gz: dcf3378ddc94bb335f2780b8a7186c308e542ef0bf10bc1d6f5450590145de671cc6a9ad3ab13ac9306fd7831fdfbbd71df4fe4711d3af9da00f37ff5c46401d
data/README.md CHANGED
@@ -35,12 +35,13 @@ Note that this isn't a benchmark, we're using [ruby-prof] which will slow things
35
35
 
36
36
  ## Release workflow
37
37
 
38
- Build the gem.
38
+ * Bump the version in `lib/twingly/version.rb`.
39
39
 
40
- gem build twingly-url.gemspec
40
+ * Make sure you are logged in as [twingly][twingly-rubygems] at RubyGems.org.
41
41
 
42
- [Publish](http://guides.rubygems.org/publishing/) the gem.
42
+ * Build and [publish](http://guides.rubygems.org/publishing/) the gem.
43
43
 
44
- gem push twingly-url-x.y.z.gem
44
+ bundle exec rake release
45
45
 
46
+ [twingly-rubygems]: https://rubygems.org/profiles/twingly
46
47
  [ruby-prof]: http://ruby-prof.rubyforge.org/
data/lib/twingly/url.rb CHANGED
@@ -10,7 +10,7 @@ module Twingly
10
10
  class URL
11
11
  include Comparable
12
12
 
13
- SCHEMES = %w(http https)
13
+ ACCEPTED_SCHEMES = /\Ahttps?\z/i
14
14
  ENDS_WITH_SLASH = /\/+$/
15
15
 
16
16
  def self.parse(potential_url)
@@ -24,15 +24,14 @@ module Twingly
24
24
  end
25
25
 
26
26
  def self.internal_parse(potential_url)
27
- if potential_url.is_a?(Addressable::URI)
28
- addressable_uri = potential_url
29
- else
30
- addressable_uri = Addressable::URI.heuristic_parse(potential_url)
31
- end
32
-
33
- raise Twingly::Error::ParseError if addressable_uri.nil?
27
+ addressable_uri = to_addressable_uri(potential_url)
28
+ raise Twingly::URL::Error::ParseError if addressable_uri.nil?
34
29
 
35
30
  public_suffix_domain = PublicSuffix.parse(addressable_uri.display_uri.host)
31
+ raise Twingly::URL::Error::ParseError if public_suffix_domain.nil?
32
+
33
+ scheme = addressable_uri.scheme
34
+ raise Twingly::URL::Error::ParseError unless scheme =~ ACCEPTED_SCHEMES
36
35
 
37
36
  self.new(addressable_uri, public_suffix_domain)
38
37
  rescue Addressable::URI::InvalidURIError, PublicSuffix::DomainInvalid => error
@@ -100,7 +99,7 @@ module Twingly
100
99
  end
101
100
 
102
101
  def normalized_scheme
103
- addressable_uri.scheme.downcase
102
+ scheme.downcase
104
103
  end
105
104
 
106
105
  def normalized_host
@@ -123,7 +122,7 @@ module Twingly
123
122
  end
124
123
 
125
124
  def valid?
126
- addressable_uri && public_suffix_domain && SCHEMES.include?(normalized_scheme)
125
+ true
127
126
  end
128
127
 
129
128
  def <=>(other)
@@ -138,6 +137,15 @@ module Twingly
138
137
  sprintf("#<%s:0x%x %s>", self.class.name, __id__, self.to_s)
139
138
  end
140
139
 
140
+ private_class_method \
141
+ def self.to_addressable_uri(potential_url)
142
+ if potential_url.is_a?(Addressable::URI)
143
+ potential_url
144
+ else
145
+ Addressable::URI.heuristic_parse(potential_url)
146
+ end
147
+ end
148
+
141
149
  private
142
150
 
143
151
  attr_reader :addressable_uri, :public_suffix_domain
@@ -1,3 +1,5 @@
1
+ require_relative "../url"
2
+
1
3
  module Twingly
2
4
  class URL
3
5
  class NullURL
@@ -1,3 +1,5 @@
1
+ require_relative "../url"
2
+
1
3
  module Twingly
2
4
  class URL
3
5
  module Utilities
@@ -1,5 +1,5 @@
1
1
  module Twingly
2
2
  class URL
3
- VERSION = "2.0.0"
3
+ VERSION = "3.0.0"
4
4
  end
5
5
  end
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: 2.0.0
4
+ version: 3.0.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: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2015-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -104,9 +104,9 @@ require_paths:
104
104
  - lib
105
105
  required_ruby_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ">="
107
+ - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 1.9.3
109
+ version: '2.2'
110
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  requirements:
112
112
  - - ">="
@@ -119,4 +119,3 @@ signing_key:
119
119
  specification_version: 4
120
120
  summary: Ruby library for URL handling
121
121
  test_files: []
122
- has_rdoc: