philiprehberger-uri_kit 0.2.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +30 -0
- data/lib/philiprehberger/uri_kit/version.rb +1 -1
- data/lib/philiprehberger/uri_kit.rb +45 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a026f3d20cd016c911d1a4218e7eae2a8f636a54548ca0b226cb9306d20161fd
|
|
4
|
+
data.tar.gz: 557e3f6ff76a3c92c9346f67f0d3c9d44b083a07ca768bea060c4fa31d2966ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6f97d4a9d71f30dd31520affc81b20d49927c17068ab6ac58149e018c1cc2db7f49dbe02c05906c03364c3e8d924f9a95068f23ae6b6a8879b8b10c5dbd6952d
|
|
7
|
+
data.tar.gz: 5415549cb15e13d66785af54af0c4c5664e7fbbd7ce1bae50399e54af5dd644d3e9d6f8fc7db4b36255b386f73d4d9ea92b97cd3444e2af817ecd5322e360fd8
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-04-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Component accessors: `scheme`, `host`, `port`, `path`, `query`, `fragment`
|
|
14
|
+
- Value equality: `==`, `eql?`, `hash` based on string representation
|
|
15
|
+
|
|
10
16
|
## [0.2.0] - 2026-04-03
|
|
11
17
|
|
|
12
18
|
### Added
|
data/README.md
CHANGED
|
@@ -96,6 +96,29 @@ url = Philiprehberger::UriKit.parse('https://example.com:8080/api/v2?key=val')
|
|
|
96
96
|
url.base_url # => "https://example.com:8080"
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
+
### Component Accessors
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
url = Philiprehberger::UriKit.parse('https://example.com:8080/api?key=val#section')
|
|
103
|
+
url.scheme # => "https"
|
|
104
|
+
url.host # => "example.com"
|
|
105
|
+
url.port # => 8080
|
|
106
|
+
url.path # => "/api"
|
|
107
|
+
url.query # => "key=val"
|
|
108
|
+
url.fragment # => "section"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Equality
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
a = Philiprehberger::UriKit.parse('https://example.com/path')
|
|
115
|
+
b = Philiprehberger::UriKit.parse('https://example.com/path')
|
|
116
|
+
a == b # => true
|
|
117
|
+
|
|
118
|
+
# Works with Hash keys and arrays
|
|
119
|
+
set = [a, b].uniq # => 1 element
|
|
120
|
+
```
|
|
121
|
+
|
|
99
122
|
### Joining URLs
|
|
100
123
|
|
|
101
124
|
```ruby
|
|
@@ -122,7 +145,14 @@ url.to_s # => "https://example.com/base/page.html"
|
|
|
122
145
|
| `Url#add_params(hash)` | Add multiple query parameters, returns new Url |
|
|
123
146
|
| `Url#clear_params` | Remove all query parameters, returns new Url |
|
|
124
147
|
| `Url#base_url` | Get scheme + host + port as a string |
|
|
148
|
+
| `Url#scheme` | URL scheme (e.g. `"https"`) |
|
|
149
|
+
| `Url#host` | Hostname |
|
|
150
|
+
| `Url#port` | Port number |
|
|
151
|
+
| `Url#path` | Path component |
|
|
152
|
+
| `Url#query` | Raw query string |
|
|
153
|
+
| `Url#fragment` | Fragment identifier |
|
|
125
154
|
| `Url#to_s` | Get the full URL string |
|
|
155
|
+
| `Url#==` / `Url#eql?` | Value equality based on string representation |
|
|
126
156
|
|
|
127
157
|
## Development
|
|
128
158
|
|
|
@@ -142,11 +142,56 @@ module Philiprehberger
|
|
|
142
142
|
base
|
|
143
143
|
end
|
|
144
144
|
|
|
145
|
+
# @return [String, nil] the URL scheme (e.g. "https")
|
|
146
|
+
def scheme
|
|
147
|
+
@uri.scheme
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# @return [String, nil] the hostname
|
|
151
|
+
def host
|
|
152
|
+
@uri.host
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# @return [Integer, nil] the port number
|
|
156
|
+
def port
|
|
157
|
+
@uri.port
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# @return [String] the path component
|
|
161
|
+
def path
|
|
162
|
+
@uri.path
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# @return [String, nil] the raw query string
|
|
166
|
+
def query
|
|
167
|
+
@uri.query
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# @return [String, nil] the fragment
|
|
171
|
+
def fragment
|
|
172
|
+
@uri.fragment
|
|
173
|
+
end
|
|
174
|
+
|
|
145
175
|
# @return [String] the full URL string
|
|
146
176
|
def to_s
|
|
147
177
|
@uri.to_s
|
|
148
178
|
end
|
|
149
179
|
|
|
180
|
+
# Value equality based on string representation
|
|
181
|
+
#
|
|
182
|
+
# @param other [Object] object to compare
|
|
183
|
+
# @return [Boolean]
|
|
184
|
+
def ==(other)
|
|
185
|
+
other.is_a?(self.class) && to_s == other.to_s
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
alias eql? ==
|
|
189
|
+
|
|
190
|
+
# @return [Integer] hash code consistent with eql?
|
|
191
|
+
def hash
|
|
192
|
+
to_s.hash
|
|
193
|
+
end
|
|
194
|
+
|
|
150
195
|
private
|
|
151
196
|
|
|
152
197
|
def encode_params(hash)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: philiprehberger-uri_kit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Philip Rehberger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Parse, build, and manipulate URLs with query parameter management, normalization,
|
|
14
14
|
domain extraction, and URL joining. Built on Ruby stdlib URI.
|