uri-builder 0.1.2 → 0.1.4

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: 2ecd15fc5e3de3f5fb700759eaba92a5db8731c144a3e1335b7c3ecd8a4dcb5c
4
- data.tar.gz: 604d547bfedf9127efb57c674ea7f99bb9f8a0ad2f64dfbcde5d3f29fd351df6
3
+ metadata.gz: d90c9dfcbf3a15504e21d45d26a2c61878aebcd7571d18e07ad8782370011195
4
+ data.tar.gz: d25487607b08a42ae363681724ac0190fef6a522771ad06ba686c908e65529ea
5
5
  SHA512:
6
- metadata.gz: e1a497fe06a2838a4bec7ea091c47fd770e0a67e05325e230e81bb26dc4b75cbb0f0f460ba5cc968cdc2b4b2e07fa050fe7d77bfb9cd20da05d4f994d446ead0
7
- data.tar.gz: 051ab649d2c481a8a9991339c810331ad7aede03e56de45933880e2a093f4fcfbbde8ac8506c8f0c0e9b150fb7da2208816ca2a8e56041c04b00a0be0817f61b
6
+ metadata.gz: 661d6acf1e0d8e37543d0bf8a02c7a7964e453c9e55e074c03aed13010bb51ca236b846a6eb017bf8831ea09d866e16cfbf0084b6525bf8e23e930d2df59bac7
7
+ data.tar.gz: ef46b356e3770bd5ccf7e1eea45d02eb700b913e1b019c7fc0bd651238b1d5b0c7a760775d1f6ca581081714597702fe3cc1609258ce167a2c3989c4e519ee02
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uri-builder (0.1.2)
4
+ uri-builder (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -24,6 +24,7 @@ GEM
24
24
 
25
25
  PLATFORMS
26
26
  arm64-darwin-21
27
+ arm64-darwin-22
27
28
  x86_64-darwin-20
28
29
 
29
30
  DEPENDENCIES
@@ -2,6 +2,6 @@
2
2
 
3
3
  module URI
4
4
  module Build
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
data/lib/uri/builder.rb CHANGED
@@ -14,12 +14,28 @@ module URI
14
14
  @uri = uri.clone
15
15
  end
16
16
 
17
- [:host, :scheme, :query, :fragment, :port].each do |property|
17
+ [:host, :query, :fragment, :port].each do |property|
18
18
  define_method property do |value|
19
19
  wrap property, value
20
20
  end
21
21
  end
22
22
 
23
+ def scheme(value)
24
+ if @uri.scheme
25
+ # Handles URLs without schemes, like https://example.com/foo
26
+ target_scheme = URI.scheme_list[value.upcase]
27
+ args = Hash[target_scheme.component.map { |attr| [ attr, @uri.send(attr) ] }]
28
+ @uri = target_scheme.build(**args)
29
+ else
30
+ # Handles URLs without schemes, like example.com/foo
31
+ uri = URI.parse("#{value}://#{@uri.path}")
32
+ (uri.component - %i[host path scheme]).each do |component|
33
+ uri.send "#{component}=", @uri.send(component)
34
+ end
35
+ @uri = uri
36
+ end
37
+ end
38
+
23
39
  def query(value)
24
40
  value = case value
25
41
  when Hash
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-26 00:00:00.000000000 Z
11
+ date: 2023-07-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Build URIs via chains
14
14
  email:
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.3.7
52
+ rubygems_version: 3.4.6
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: Build URIs via chains