uri-redis 1.2.0 → 1.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/CHANGES.txt +4 -0
- data/Gemfile +2 -2
- data/README.md +15 -3
- data/lib/uri/redis/version.rb +4 -2
- data/lib/uri/redis.rb +10 -14
- data/try/10_uri_redis_try.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7c320d796599dbe819c6f6f42ab5655fd476c6c4c14fbb5e2e06b96d406ed0b
|
4
|
+
data.tar.gz: 82a9de5b109832c565cbded9aa9311020bf4937b27959086941582caa5c3403c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7a975c5b9aadd178da1f52d25910dc4b9bfd33b065cfbd876dfd4b622de860a2a31e0a99e2e30b541ed72571a1713a00981f0774f7ce932c41ac221077589b4
|
7
|
+
data.tar.gz: ae0da4815dddaa945093437f9ec2df218ec0e29be9b4f73cef0460d9046038d0933e4eb4e28f01b60b84d1550ae7c1e28ecb344026c4fae1dd27c01aebb89dbe
|
data/CHANGES.txt
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# URI-Redis v1.
|
1
|
+
# URI-Redis v1.3 (2024-06-15)
|
2
2
|
|
3
3
|
Creates a URI object for Redis URLs.
|
4
4
|
|
@@ -12,11 +12,23 @@ e.g.
|
|
12
12
|
require 'uri/redis'
|
13
13
|
|
14
14
|
conf = URI.parse 'redis://localhost:4380/2'
|
15
|
+
conf.scheme # => "redis"
|
15
16
|
conf.host # => localhost
|
16
17
|
conf.port # => 4380
|
17
18
|
conf.db # => 2
|
18
19
|
conf.to_s # => redis://localhost:4380/2
|
19
|
-
|
20
|
+
```
|
21
|
+
|
22
|
+
### SSL Support
|
23
|
+
|
24
|
+
SSL is supported by using the `rediss` scheme. Note: SSL support is only available in Redis (Server) 6.0 and later and via redis-rb 4.7 and later.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'uri/redis'
|
28
|
+
|
29
|
+
conf = URI.parse 'rediss://localhost:4380/2'
|
30
|
+
conf.scheme # => "rediss"
|
31
|
+
conf.to_s # => rediss://localhost:4380/2
|
20
32
|
```
|
21
33
|
|
22
34
|
|
@@ -25,7 +37,7 @@ e.g.
|
|
25
37
|
Get it in one of the following ways:
|
26
38
|
|
27
39
|
* `gem install uri-redis`
|
28
|
-
* `git clone git
|
40
|
+
* `git clone git@github.com:delano/uri-redis.git`
|
29
41
|
|
30
42
|
|
31
43
|
## About
|
data/lib/uri/redis/version.rb
CHANGED
data/lib/uri/redis.rb
CHANGED
@@ -66,14 +66,16 @@ module URI
|
|
66
66
|
hsh = {
|
67
67
|
host: host,
|
68
68
|
port: port,
|
69
|
-
db: db
|
69
|
+
db: db,
|
70
|
+
ssl: scheme == 'rediss'
|
70
71
|
}.merge(parse_query(query))
|
71
72
|
hsh[:password] = password if password
|
73
|
+
hsh[:timeout] = hsh[:timeout].to_i if hsh.key?(:timeout)
|
72
74
|
hsh
|
73
75
|
end
|
74
76
|
|
75
77
|
def serverid
|
76
|
-
format(
|
78
|
+
format('%s://%s:%s/%s', scheme, host, port, db)
|
77
79
|
end
|
78
80
|
|
79
81
|
private
|
@@ -102,26 +104,20 @@ module URI
|
|
102
104
|
|
103
105
|
if URI.respond_to?(:register_scheme)
|
104
106
|
URI.register_scheme "REDIS", Redis
|
107
|
+
URI.register_scheme "REDISS", Redis
|
105
108
|
else
|
106
109
|
@@schemes['REDIS'] = Redis
|
110
|
+
@@schemes['REDISS'] = Redis
|
107
111
|
end
|
108
112
|
end
|
109
113
|
|
110
114
|
# Adds a URI method to Redis
|
111
115
|
class Redis
|
112
116
|
def self.uri(conf = {})
|
113
|
-
URI.parse format("
|
117
|
+
URI.parse format("%s://%s:%s/%s", conf[:ssl] ? 'rediss' : 'redis', conf[:host], conf[:port], conf[:db])
|
114
118
|
end
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
else
|
120
|
-
# Redis < 2.0.0
|
121
|
-
class Client
|
122
|
-
def uri
|
123
|
-
URI.parse format("redis://%s:%s/%s", @host, @port, @db)
|
124
|
-
end
|
125
|
-
end
|
119
|
+
|
120
|
+
def uri
|
121
|
+
URI.parse @client.id
|
126
122
|
end
|
127
123
|
end
|
data/try/10_uri_redis_try.rb
CHANGED
@@ -10,6 +10,11 @@ uri = URI.parse "redis://localhost/2"
|
|
10
10
|
[uri.db, uri.host, uri.port]
|
11
11
|
#=> [2, 'localhost', 6379]
|
12
12
|
|
13
|
+
## Parsed URI can be accessed via conf hash
|
14
|
+
uri = URI.parse "redis://localhost:16739/2"
|
15
|
+
[uri.scheme, uri.conf]
|
16
|
+
#=> ['redis', {:host=>"localhost", :port=>16739, :db=>2, :ssl=>false}]
|
17
|
+
|
13
18
|
## Can parse a key name
|
14
19
|
uri = URI.parse "redis://localhost/2/v1:arbitrary:key"
|
15
20
|
[uri.key, uri.db, uri.host, uri.port]
|
@@ -26,3 +31,8 @@ uri = URI.parse "redis://localhost/2/v1:arbitrary:key"
|
|
26
31
|
uri.key = "v2:arbitrary:key"
|
27
32
|
uri.to_s
|
28
33
|
#=> 'redis://localhost/2/v2:arbitrary:key'
|
34
|
+
|
35
|
+
## Support rediss
|
36
|
+
uri = URI.parse "rediss://localhost"
|
37
|
+
[uri.scheme, uri.conf]
|
38
|
+
#=> ["rediss", {:host=>"localhost", :port=>6379, :db=>0, :ssl=>true}]
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uri-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- delano
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: 'URI-Redis: support for parsing Redis URIs like redis://host:port/dbindex'
|
13
|
+
description: 'URI-Redis: support for parsing Redis URIs like redis://host:port/dbindex/key'
|
14
14
|
email:
|
15
15
|
- gems@solutious.com
|
16
16
|
executables: []
|