tilia-uri 1.0.1 → 1.0.1.1

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: d05aacc9eb7c559b01f9845a5baf5fff2f92f0c4
4
- data.tar.gz: 1242281c7936522ba63c1ce8e2130ad6522bc2b9
3
+ metadata.gz: 09e0ca42bc4ae761128b569b6b23fee7e0c4c5be
4
+ data.tar.gz: e552181bbf1a3b8e536fc95eda81fe689e722e75
5
5
  SHA512:
6
- metadata.gz: 7bbe25462c7a574ba32b8e579fa4edddda7c086fcc97325f38c2b25bffc6e2836fdc03b6aeb98f8460f8502650ade09052917c389ce51afdbb96cb1d999857f2
7
- data.tar.gz: 3afe6f78cd198ba2b8fc24d86cf2a12d20f09fbd0ca6b2b270e25eec98341d02aa6b0f8ca349568b02846a0dc46ba758bde26020b02492e4a579721a437357f8
6
+ metadata.gz: da688f7e21c205162da6db73304147ea21bb3508259f5e3d9c68cf70717a1ebc26039f027efc744bcd7cc9d5dba5dd4cea19a0bd9a4332e1dde394965ae00ea4
7
+ data.tar.gz: 5aaaeff5968abee8f4c0581e1c5c570b8b91858ad61706db3294fc45e8bc8001b61e93ab371f812ea41dd6429f7c7dfed14a95af5a67076b4465e612f917412c
data/.simplecov CHANGED
@@ -1,4 +1,4 @@
1
1
  SimpleCov.start do
2
- add_filter "/spec/"
2
+ add_filter "/test/"
3
3
  end
4
4
 
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # External dependencies
4
- gem 'activesupport', '~> 4.2'
4
+ gemspec
5
5
 
6
6
  # Testing
7
7
  gem 'rake'
@@ -1,7 +1,13 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tilia-uri (1.0.1.1)
5
+ activesupport (>= 4.0)
6
+
1
7
  GEM
2
8
  remote: https://rubygems.org/
3
9
  specs:
4
- activesupport (4.2.4)
10
+ activesupport (4.2.5.1)
5
11
  i18n (~> 0.7)
6
12
  json (~> 1.7, >= 1.7.7)
7
13
  minitest (~> 5.1)
@@ -40,11 +46,11 @@ PLATFORMS
40
46
  ruby
41
47
 
42
48
  DEPENDENCIES
43
- activesupport (~> 4.2)
44
49
  minitest (~> 5.8)
45
50
  rake
46
51
  rubocop (~> 0.34)
47
52
  simplecov (~> 0.10)
53
+ tilia-uri!
48
54
  yard (~> 0.8)
49
55
 
50
56
  BUNDLED WITH
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2015 Jakob Sack (tilia@jakobsack.de)
1
+ Copyright (C) 2015-2016 Jakob Sack (tilia@jakobsack.de)
2
2
 
3
3
  All rights reserved.
4
4
 
@@ -1,4 +1,4 @@
1
- Copyright (C) 2014-2015 fruux GmbH (https://fruux.com/)
1
+ Copyright (C) 2014-2016 fruux GmbH (https://fruux.com/)
2
2
 
3
3
  All rights reserved.
4
4
 
data/Rakefile CHANGED
@@ -12,6 +12,7 @@ RuboCop::RakeTask.new do |t|
12
12
  end
13
13
  YARD::Rake::YardocTask.new do |t|
14
14
  t.files = ['lib/**/*.rb', '-', 'README.md']
15
+ t.options = ['--private', '--protected']
15
16
  end
16
17
 
17
18
  task(default: :test)
@@ -32,27 +32,27 @@ module Tilia
32
32
 
33
33
  # If the new path defines a scheme, it's absolute and we can just return
34
34
  # that.
35
- return build(delta) if delta['scheme']
35
+ return build(delta) if delta[:scheme]
36
36
 
37
37
  new_parts = {}
38
38
 
39
- new_parts['scheme'] = pick.call('scheme')
40
- new_parts['host'] = pick.call('host')
41
- new_parts['port'] = pick.call('port')
39
+ new_parts[:scheme] = pick.call(:scheme)
40
+ new_parts[:host] = pick.call(:host)
41
+ new_parts[:port] = pick.call(:port)
42
42
 
43
43
  path = ''
44
- if !delta['path'].blank?
44
+ if !delta[:path].blank?
45
45
  # If the path starts with a slash
46
- if delta['path'][0] == '/'
47
- path = delta['path']
46
+ if delta[:path][0] == '/'
47
+ path = delta[:path]
48
48
  else
49
49
  # Removing last component from base path.
50
- path = base['path']
50
+ path = base[:path]
51
51
  path = path[0...path.rindex('/')] if path.index '/'
52
- path += '/' + delta['path']
52
+ path += '/' + delta[:path]
53
53
  end
54
54
  else
55
- path = base['path'].blank? ? '/' : base['path']
55
+ path = base[:path].blank? ? '/' : base[:path]
56
56
  end
57
57
 
58
58
  # Removing .. and .
@@ -79,15 +79,15 @@ module Tilia
79
79
  path = new_path_parts.join '/'
80
80
 
81
81
  # If the source url ended with a /, we want to preserve that.
82
- new_parts['path'] = path
83
- if delta['query']
84
- new_parts['query'] = delta['query']
85
- elsif !base['query'].blank? && delta['host'].blank? && delta['path'].blank?
82
+ new_parts[:path] = path
83
+ if delta[:query]
84
+ new_parts[:query] = delta[:query]
85
+ elsif !base[:query].blank? && delta[:host].blank? && delta[:path].blank?
86
86
  # Keep the old query if host and path didn't change
87
- new_parts['query'] = base['query']
87
+ new_parts[:query] = base[:query]
88
88
  end
89
89
 
90
- new_parts['fragment'] = delta['fragment'] if delta['fragment']
90
+ new_parts[:fragment] = delta[:fragment] if delta[:fragment]
91
91
  build(new_parts)
92
92
  end
93
93
 
@@ -104,8 +104,8 @@ module Tilia
104
104
  def self.normalize(uri)
105
105
  parts = parse(uri)
106
106
 
107
- unless parts['path'].blank?
108
- path_parts = parts['path'].gsub(%r{^/+}, '').split(%r{/})
107
+ unless parts[:path].blank?
108
+ path_parts = parts[:path].gsub(%r{^/+}, '').split(%r{/})
109
109
 
110
110
  new_path_parts = []
111
111
  path_parts.each do |path_part|
@@ -120,32 +120,32 @@ module Tilia
120
120
  new_path_parts << URI.escape(URI.unescape(path_part), Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
121
121
  end
122
122
  end
123
- parts['path'] = '/' + new_path_parts.join('/')
123
+ parts[:path] = '/' + new_path_parts.join('/')
124
124
  end
125
125
 
126
- if parts['scheme']
127
- parts['scheme'] = parts['scheme'].downcase
126
+ if parts[:scheme]
127
+ parts[:scheme] = parts[:scheme].downcase
128
128
  default_ports = {
129
129
  'http' => '80',
130
130
  'https' => '443'
131
131
  }
132
132
 
133
- if !parts['port'].blank? && default_ports.key?(parts['scheme']) && default_ports[parts['scheme']] == parts['port']
133
+ if !parts[:port].blank? && default_ports.key?(parts[:scheme]) && default_ports[parts[:scheme]] == parts[:port]
134
134
  # Removing default ports.
135
- parts['port'] = nil
135
+ parts[:port] = nil
136
136
  end
137
137
 
138
138
  # A few HTTP specific rules.
139
- case parts['scheme']
139
+ case parts[:scheme]
140
140
  when 'http', 'https'
141
- if parts['path'].blank?
141
+ if parts[:path].blank?
142
142
  # An empty path is equivalent to / in http.
143
- parts['path'] = '/'
143
+ parts[:path] = '/'
144
144
  end
145
145
  end
146
146
  end
147
147
 
148
- parts['host'] = parts['host'].downcase if parts['host']
148
+ parts[:host] = parts[:host].downcase if parts[:host]
149
149
 
150
150
  build(parts)
151
151
  end
@@ -157,17 +157,17 @@ module Tilia
157
157
  # set by parse_url, which makes it a bit easier to work with.
158
158
  #
159
159
  # @param [String] uri
160
- # @return [Hash]
160
+ # @return [Hash{Symbol => String}]
161
161
  def self.parse(uri)
162
162
  u = ::URI.split(uri)
163
163
  {
164
- 'scheme' => u[0],
165
- 'user' => u[1],
166
- 'host' => u[2],
167
- 'port' => u[3],
168
- 'path' => u[5] || u[6], # 6 = mailto, opaque
169
- 'query' => u[7],
170
- 'fragment' => u[8]
164
+ scheme: u[0],
165
+ user: u[1],
166
+ host: u[2],
167
+ port: u[3],
168
+ path: u[5] || u[6], # 6 = mailto, opaque
169
+ query: u[7],
170
+ fragment: u[8]
171
171
  }
172
172
  end
173
173
 
@@ -180,16 +180,16 @@ module Tilia
180
180
  uri = ''
181
181
 
182
182
  authority = ''
183
- unless parts['host'].blank?
184
- authority = parts['host']
183
+ unless parts[:host].blank?
184
+ authority = parts[:host]
185
185
 
186
- authority = parts['user'] + '@' + authority unless parts['user'].blank?
187
- authority = authority + ':' + parts['port'].to_s unless parts['port'].blank?
186
+ authority = parts[:user] + '@' + authority unless parts[:user].blank?
187
+ authority = authority + ':' + parts[:port].to_s unless parts[:port].blank?
188
188
  end
189
189
 
190
- unless parts['scheme'].blank?
190
+ unless parts[:scheme].blank?
191
191
  # If there's a scheme, there's also a host.
192
- uri = parts['scheme'] + ':'
192
+ uri = parts[:scheme] + ':'
193
193
  end
194
194
 
195
195
  unless authority.blank?
@@ -197,9 +197,9 @@ module Tilia
197
197
  uri += '//' + authority
198
198
  end
199
199
 
200
- uri += parts['path'] unless parts['path'].blank?
201
- uri += '?' + parts['query'] unless parts['query'].blank?
202
- uri += '#' + parts['fragment'] unless parts['fragment'].blank?
200
+ uri += parts[:path] unless parts[:path].blank?
201
+ uri += '?' + parts[:query] unless parts[:query].blank?
202
+ uri += '#' + parts[:fragment] unless parts[:fragment].blank?
203
203
 
204
204
  uri
205
205
  end
@@ -219,12 +219,12 @@ module Tilia
219
219
  # the end of the string is stripped off.
220
220
  #
221
221
  # @param [String] path
222
- # @return [Array]
222
+ # @return [Array(String, String)]
223
223
  def self.split(path)
224
224
  if path =~ %r{^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$}u
225
225
  [Regexp.last_match[1] || '', Regexp.last_match[2] || '']
226
226
  else
227
- [nil, nil]
227
+ ['', '']
228
228
  end
229
229
  end
230
230
  end
@@ -3,7 +3,7 @@ module Tilia
3
3
  # This class contains the version number for this package.
4
4
  class Version
5
5
  # Full version number
6
- VERSION = '1.0.1'
6
+ VERSION = '1.0.1.1'
7
7
  end
8
8
  end
9
9
  end
@@ -15,7 +15,7 @@ module Tilia
15
15
  'foo/' => ['', 'foo'],
16
16
  '/foo/' => ['', 'foo'],
17
17
  '/foo' => ['', 'foo'],
18
- '' => [nil, nil],
18
+ '' => ['', ''],
19
19
 
20
20
  # UTF-8
21
21
  "/\xC3\xA0fo\xC3\xB3/bar" => ["/\xC3\xA0fo\xC3\xB3", 'bar'],
@@ -9,5 +9,6 @@ Gem::Specification.new do |s|
9
9
  s.email = 'tilia@jakobsack.de'
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.homepage = 'https://github.com/tilia/tilia-uri'
12
- s.add_runtime_dependency 'activesupport', '~> 4.2'
12
+
13
+ s.add_runtime_dependency 'activesupport', '>= 4.0'
13
14
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilia-uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakob Sack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.2'
26
+ version: '4.0'
27
27
  description: Functions for making sense out of URIs.
28
28
  email: tilia@jakobsack.de
29
29
  executables: []