uri-redis 0.4.2 → 1.0.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 +7 -0
- data/.rubocop.yml +176 -0
- data/CHANGES.txt +20 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +4 -2
- data/README.md +40 -0
- data/Rakefile +5 -59
- data/lib/uri/redis/version.rb +7 -0
- data/lib/uri/redis.rb +61 -48
- data/sig/uri/redis.rbs +6 -0
- data/try/10_uri_redis_try.rb +9 -10
- metadata +83 -59
- data/README.rdoc +0 -35
- data/VERSION.yml +0 -5
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 4cc5ef97a1ea80b106e1cbff2db3aa804b74040ebfbb405db2c36fd4407236fd
|
|
4
|
+
data.tar.gz: b57c846e9e4dee92363226ec0c32d7bcd1fa1f103f2f7893d97e9bb27c4aa24c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bd5af060359ec55d14e6b254d500f3f24f3d0eaef267ed9b83edc768f7561ae585faf49873c21ebfd92adc019527ddbb73461da0112c19de95561ec973d206ca
|
|
7
|
+
data.tar.gz: aa4a71b7c0ad842f6d3d2cfd05bce94a63f85f15a1e4007b2daf5ede87117c2e625ea1c8b73bebc81030b0741ef783db43c0ae0a2dad720f150adfaab09eae07
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.7.5
|
|
3
|
+
|
|
4
|
+
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
|
|
5
|
+
Enabled: true
|
|
6
|
+
Gemspec/RequireMFA: # new in 1.23
|
|
7
|
+
Enabled: true
|
|
8
|
+
Layout/LineContinuationLeadingSpace: # new in 1.31
|
|
9
|
+
Enabled: true
|
|
10
|
+
Layout/LineContinuationSpacing: # new in 1.31
|
|
11
|
+
Enabled: true
|
|
12
|
+
Layout/LineEndStringConcatenationIndentation: # new in 1.18
|
|
13
|
+
Enabled: true
|
|
14
|
+
Layout/SpaceBeforeBrackets: # new in 1.7
|
|
15
|
+
Enabled: true
|
|
16
|
+
Lint/AmbiguousAssignment: # new in 1.7
|
|
17
|
+
Enabled: true
|
|
18
|
+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
|
|
19
|
+
Enabled: true
|
|
20
|
+
Lint/AmbiguousRange: # new in 1.19
|
|
21
|
+
Enabled: true
|
|
22
|
+
Lint/ConstantOverwrittenInRescue: # new in 1.31
|
|
23
|
+
Enabled: true
|
|
24
|
+
Lint/DeprecatedConstants: # new in 1.8
|
|
25
|
+
Enabled: true
|
|
26
|
+
Lint/DuplicateBranch: # new in 1.3
|
|
27
|
+
Enabled: true
|
|
28
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
|
29
|
+
Enabled: true
|
|
30
|
+
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
|
|
31
|
+
Enabled: true
|
|
32
|
+
Lint/EmptyBlock: # new in 1.1
|
|
33
|
+
Enabled: true
|
|
34
|
+
Lint/EmptyClass: # new in 1.3
|
|
35
|
+
Enabled: true
|
|
36
|
+
Lint/EmptyInPattern: # new in 1.16
|
|
37
|
+
Enabled: true
|
|
38
|
+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
|
|
39
|
+
Enabled: true
|
|
40
|
+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
|
|
41
|
+
Enabled: true
|
|
42
|
+
Lint/NoReturnInBeginEndBlocks: # new in 1.2
|
|
43
|
+
Enabled: true
|
|
44
|
+
Lint/NonAtomicFileOperation: # new in 1.31
|
|
45
|
+
Enabled: true
|
|
46
|
+
Lint/NumberedParameterAssignment: # new in 1.9
|
|
47
|
+
Enabled: true
|
|
48
|
+
Lint/OrAssignmentToConstant: # new in 1.9
|
|
49
|
+
Enabled: true
|
|
50
|
+
Lint/RedundantDirGlobSort: # new in 1.8
|
|
51
|
+
Enabled: true
|
|
52
|
+
Lint/RefinementImportMethods: # new in 1.27
|
|
53
|
+
Enabled: true
|
|
54
|
+
Lint/RequireRangeParentheses: # new in 1.32
|
|
55
|
+
Enabled: true
|
|
56
|
+
Lint/RequireRelativeSelfPath: # new in 1.22
|
|
57
|
+
Enabled: true
|
|
58
|
+
Lint/SymbolConversion: # new in 1.9
|
|
59
|
+
Enabled: true
|
|
60
|
+
Lint/ToEnumArguments: # new in 1.1
|
|
61
|
+
Enabled: true
|
|
62
|
+
Lint/TripleQuotes: # new in 1.9
|
|
63
|
+
Enabled: true
|
|
64
|
+
Lint/Void: # new in 1.1
|
|
65
|
+
Enabled: false
|
|
66
|
+
Lint/UnexpectedBlockArity: # new in 1.5
|
|
67
|
+
Enabled: true
|
|
68
|
+
Lint/UnmodifiedReduceAccumulator: # new in 1.1
|
|
69
|
+
Enabled: true
|
|
70
|
+
Lint/UselessRescue: # new in 1.43
|
|
71
|
+
Enabled: true
|
|
72
|
+
Lint/UselessRuby2Keywords: # new in 1.23
|
|
73
|
+
Enabled: true
|
|
74
|
+
Metrics/AbcSize: # new in 1.0
|
|
75
|
+
Enabled: false
|
|
76
|
+
Metrics/MethodLength: # new in 1.0
|
|
77
|
+
Enabled: false
|
|
78
|
+
Metrics/PerceivedComplexity: # new in 1.0
|
|
79
|
+
Enabled: false
|
|
80
|
+
Naming/BlockForwarding: # new in 1.24
|
|
81
|
+
Enabled: true
|
|
82
|
+
Security/CompoundHash: # new in 1.28
|
|
83
|
+
Enabled: true
|
|
84
|
+
Security/IoMethods: # new in 1.22
|
|
85
|
+
Enabled: true
|
|
86
|
+
Style/ArgumentsForwarding: # new in 1.1
|
|
87
|
+
Enabled: true
|
|
88
|
+
Style/ArrayIntersect: # new in 1.40
|
|
89
|
+
Enabled: true
|
|
90
|
+
Style/CollectionCompact: # new in 1.2
|
|
91
|
+
Enabled: true
|
|
92
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
|
93
|
+
Enabled: true
|
|
94
|
+
Style/DocumentDynamicEvalDefinition: # new in 1.1
|
|
95
|
+
Enabled: true
|
|
96
|
+
Style/EmptyHeredoc: # new in 1.32
|
|
97
|
+
Enabled: true
|
|
98
|
+
Style/EndlessMethod: # new in 1.8
|
|
99
|
+
Enabled: true
|
|
100
|
+
Style/EnvHome: # new in 1.29
|
|
101
|
+
Enabled: true
|
|
102
|
+
Style/FetchEnvVar: # new in 1.28
|
|
103
|
+
Enabled: true
|
|
104
|
+
Style/FileRead: # new in 1.24
|
|
105
|
+
Enabled: true
|
|
106
|
+
Style/FileWrite: # new in 1.24
|
|
107
|
+
Enabled: true
|
|
108
|
+
Style/FormatStringToken: # new in 1.1
|
|
109
|
+
Enabled: false
|
|
110
|
+
Style/HashConversion: # new in 1.10
|
|
111
|
+
Enabled: true
|
|
112
|
+
Style/HashExcept: # new in 1.7
|
|
113
|
+
Enabled: true
|
|
114
|
+
Style/IfWithBooleanLiteralBranches: # new in 1.9
|
|
115
|
+
Enabled: true
|
|
116
|
+
Style/InPatternThen: # new in 1.16
|
|
117
|
+
Enabled: true
|
|
118
|
+
Style/MagicCommentFormat: # new in 1.35
|
|
119
|
+
Enabled: true
|
|
120
|
+
Style/MapCompactWithConditionalBlock: # new in 1.30
|
|
121
|
+
Enabled: true
|
|
122
|
+
Style/MapToHash: # new in 1.24
|
|
123
|
+
Enabled: true
|
|
124
|
+
Style/MapToSet: # new in 1.42
|
|
125
|
+
Enabled: true
|
|
126
|
+
Style/MinMaxComparison: # new in 1.42
|
|
127
|
+
Enabled: true
|
|
128
|
+
Style/MultilineInPatternThen: # new in 1.16
|
|
129
|
+
Enabled: true
|
|
130
|
+
Style/NegatedIfElseCondition: # new in 1.2
|
|
131
|
+
Enabled: true
|
|
132
|
+
Style/NestedFileDirname: # new in 1.26
|
|
133
|
+
Enabled: true
|
|
134
|
+
Style/NilLambda: # new in 1.3
|
|
135
|
+
Enabled: true
|
|
136
|
+
Style/NumberedParameters: # new in 1.22
|
|
137
|
+
Enabled: true
|
|
138
|
+
Style/NumberedParametersLimit: # new in 1.22
|
|
139
|
+
Enabled: true
|
|
140
|
+
Style/ObjectThen: # new in 1.28
|
|
141
|
+
Enabled: true
|
|
142
|
+
Style/OpenStructUse: # new in 1.23
|
|
143
|
+
Enabled: true
|
|
144
|
+
Style/OperatorMethodCall: # new in 1.37
|
|
145
|
+
Enabled: true
|
|
146
|
+
Style/QuotedSymbols: # new in 1.16
|
|
147
|
+
Enabled: true
|
|
148
|
+
Style/RedundantArgument: # new in 1.4
|
|
149
|
+
Enabled: true
|
|
150
|
+
Style/RedundantConstantBase: # new in 1.40
|
|
151
|
+
Enabled: true
|
|
152
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
|
153
|
+
Enabled: true
|
|
154
|
+
Style/RedundantEach: # new in 1.38
|
|
155
|
+
Enabled: true
|
|
156
|
+
Style/RedundantInitialize: # new in 1.27
|
|
157
|
+
Enabled: true
|
|
158
|
+
Style/RedundantSelfAssignmentBranch: # new in 1.19
|
|
159
|
+
Enabled: true
|
|
160
|
+
Style/RedundantStringEscape: # new in 1.37
|
|
161
|
+
Enabled: true
|
|
162
|
+
Style/SelectByRegexp: # new in 1.22
|
|
163
|
+
Enabled: true
|
|
164
|
+
Style/StringChars: # new in 1.12
|
|
165
|
+
Enabled: true
|
|
166
|
+
Style/SwapValues: # new in 1.1
|
|
167
|
+
Enabled: true
|
|
168
|
+
Style/StringLiterals:
|
|
169
|
+
Enabled: false
|
|
170
|
+
EnforcedStyle: double_quotes
|
|
171
|
+
Style/StringLiteralsInInterpolation:
|
|
172
|
+
Enabled: false
|
|
173
|
+
EnforcedStyle: double_quotes
|
|
174
|
+
|
|
175
|
+
Layout/LineLength:
|
|
176
|
+
Max: 120
|
data/CHANGES.txt
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
URI-Redis, CHANGES
|
|
2
2
|
|
|
3
|
+
#### 1.0.0 (2023-01-17) ###############################
|
|
4
|
+
|
|
5
|
+
* CHANGE: Just a version bump to 1.0 for a full
|
|
6
|
+
release. No code changes.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#### 1.0.0-RC2 (2023-01-16) ###########################
|
|
10
|
+
|
|
11
|
+
* FIXED: Harmonized ruby versions across gemspec,
|
|
12
|
+
code, and github action.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#### 1.0.0-RC1 (2023-01-16) ###########################
|
|
16
|
+
|
|
17
|
+
* CHANGE: Moderized gem
|
|
18
|
+
* ADDED: Only redis-4.1.0+ supported
|
|
19
|
+
* FIXED: Support URI v0.11
|
|
20
|
+
* See: https://github.com/delano/redis-dump/issues/33
|
|
21
|
+
|
|
22
|
+
|
|
3
23
|
#### 0.4.2 (2010-12-23) ###############################
|
|
4
24
|
|
|
5
25
|
# CHANGE: URI#conf enforces symbols as keys
|
data/Gemfile
ADDED
data/LICENSE.txt
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 delano
|
|
2
4
|
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -16,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
16
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
THE SOFTWARE.
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# URI-Redis v1.0 (pre-release)
|
|
2
|
+
|
|
3
|
+
Creates a URI object for Redis URLs.
|
|
4
|
+
|
|
5
|
+
e.g.
|
|
6
|
+
|
|
7
|
+
redis://host:port/dbindex
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
**
|
|
11
|
+
require 'uri/redis'
|
|
12
|
+
|
|
13
|
+
conf = URI.parse 'redis://localhost:4380/2'
|
|
14
|
+
conf.host # => localhost
|
|
15
|
+
conf.port # => 4380
|
|
16
|
+
conf.db # => 2
|
|
17
|
+
conf.to_s # => redis://localhost:4380/2
|
|
18
|
+
conf
|
|
19
|
+
**
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
Get it in one of the following ways:
|
|
23
|
+
|
|
24
|
+
* `gem install uri-redis`
|
|
25
|
+
* `git clone git+ssh://github.com/delano/uri-redis.git`
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## About
|
|
29
|
+
|
|
30
|
+
* [Github](https://github.com/delano/uri-redis)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Credits
|
|
34
|
+
|
|
35
|
+
* delano (https://delanotes.com/)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
See LICENSE.txt
|
data/Rakefile
CHANGED
|
@@ -1,62 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
require "rake"
|
|
3
|
-
require "rake/clean"
|
|
4
|
-
require 'yaml'
|
|
5
|
-
|
|
6
|
-
begin
|
|
7
|
-
require 'hanna/rdoctask'
|
|
8
|
-
rescue LoadError
|
|
9
|
-
require 'rake/rdoctask'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
config = YAML.load_file("VERSION.yml")
|
|
13
|
-
task :default => ["build"]
|
|
14
|
-
CLEAN.include [ 'pkg', 'doc', '*gemspec' ]
|
|
15
|
-
name = "uri-redis"
|
|
16
|
-
|
|
17
|
-
begin
|
|
18
|
-
require "jeweler"
|
|
19
|
-
Jeweler::Tasks.new do |gem|
|
|
20
|
-
gem.version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}"
|
|
21
|
-
gem.name = "uri-redis"
|
|
22
|
-
gem.rubyforge_project = gem.name
|
|
23
|
-
gem.summary = "URI-Redis: support for parsing redis://host:port/dbindex/keyname"
|
|
24
|
-
gem.description = gem.summary
|
|
25
|
-
gem.email = "delano@solutious.com"
|
|
26
|
-
gem.homepage = "http://github.com/delano/uri-redis"
|
|
27
|
-
gem.authors = ["Delano Mandelbaum"]
|
|
28
|
-
end
|
|
29
|
-
Jeweler::GemcutterTasks.new
|
|
30
|
-
rescue LoadError
|
|
31
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Rake::RDocTask.new do |rdoc|
|
|
36
|
-
version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}"
|
|
37
|
-
rdoc.rdoc_dir = "doc"
|
|
38
|
-
rdoc.title = "redis-dump #{version}"
|
|
39
|
-
rdoc.rdoc_files.include("README*")
|
|
40
|
-
rdoc.rdoc_files.include("LICENSE.txt")
|
|
41
|
-
#rdoc.rdoc_files.include("bin/*.rb")
|
|
42
|
-
rdoc.rdoc_files.include("lib/**/*.rb")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
# Rubyforge Release / Publish Tasks ==================================
|
|
47
|
-
|
|
48
|
-
#about 'Publish website to rubyforge'
|
|
49
|
-
task 'publish:rdoc' => 'doc/index.html' do
|
|
50
|
-
sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
#about 'Public release to rubyforge'
|
|
54
|
-
task 'publish:gem' => [:package] do |t|
|
|
55
|
-
sh <<-end
|
|
56
|
-
rubyforge add_release -o Any -a CHANGES.txt -f -n README.md #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
|
|
57
|
-
rubyforge add_file -o Any -a CHANGES.txt -f -n README.md #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
|
|
58
|
-
end
|
|
59
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
60
2
|
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rubocop/rake_task"
|
|
61
5
|
|
|
6
|
+
RuboCop::RakeTask.new
|
|
62
7
|
|
|
8
|
+
task default: :rubocop
|
data/lib/uri/redis.rb
CHANGED
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
require 'redis'
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
3
|
+
require "uri"
|
|
4
|
+
require "redis"
|
|
5
|
+
|
|
6
|
+
# URI::Redis - adds support for Redis URIs to core.
|
|
4
7
|
module URI
|
|
8
|
+
# Redis URI
|
|
9
|
+
#
|
|
10
|
+
# This is a subclass of URI::Generic and supports the following URI formats:
|
|
11
|
+
#
|
|
12
|
+
# redis://host:port/dbindex
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# uri = URI::Redis.build(host: "localhost", port: 6379, db: 2, key: "v1:arbitrary:key")
|
|
16
|
+
# uri.to_s #=> "redis://localhost:6379/2/v1:arbitrary:key"
|
|
17
|
+
#
|
|
18
|
+
# uri = URI::Redis.build(host: "localhost", port: 6379, db: 2)
|
|
19
|
+
# uri.to_s #=> "redis://localhost:6379/2"
|
|
5
20
|
class Redis < URI::Generic
|
|
6
|
-
VERSION =
|
|
21
|
+
VERSION = "0.4" unless defined?(URI::Redis::VERSION)
|
|
7
22
|
DEFAULT_PORT = 6379
|
|
8
23
|
DEFAULT_DB = 0
|
|
9
|
-
|
|
24
|
+
|
|
10
25
|
def self.build(args)
|
|
11
|
-
tmp = Util
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def initialize(*arg)
|
|
16
|
-
super(*arg)
|
|
26
|
+
tmp = Util.make_components_hash(self, args)
|
|
27
|
+
super(tmp)
|
|
17
28
|
end
|
|
18
|
-
|
|
29
|
+
|
|
19
30
|
def request_uri
|
|
20
|
-
|
|
31
|
+
path_query
|
|
21
32
|
end
|
|
22
|
-
|
|
33
|
+
|
|
23
34
|
def key
|
|
24
|
-
return if
|
|
35
|
+
return if path.nil?
|
|
36
|
+
|
|
25
37
|
self.path ||= "/#{DEFAULT_DB}"
|
|
26
|
-
(self.path.split(
|
|
38
|
+
(self.path.split("/")[2..] || []).join("/")
|
|
27
39
|
end
|
|
28
|
-
|
|
40
|
+
|
|
29
41
|
def key=(val)
|
|
30
|
-
self.path =
|
|
42
|
+
self.path = "/" << [db, val].join("/")
|
|
31
43
|
end
|
|
32
|
-
|
|
44
|
+
|
|
33
45
|
def db
|
|
34
46
|
self.path ||= "/#{DEFAULT_DB}"
|
|
35
|
-
(self.path.split(
|
|
47
|
+
(self.path.split("/")[1] || DEFAULT_DB).to_i
|
|
36
48
|
end
|
|
37
|
-
|
|
49
|
+
|
|
38
50
|
def db=(val)
|
|
39
51
|
current_key = key
|
|
40
52
|
self.path = "/#{val}"
|
|
41
53
|
self.path << "/#{current_key}"
|
|
42
54
|
self.path
|
|
43
55
|
end
|
|
44
|
-
|
|
45
|
-
# Returns a hash suitable for sending to Redis.new.
|
|
56
|
+
|
|
57
|
+
# Returns a hash suitable for sending to Redis.new.
|
|
46
58
|
# The hash is generated from the host, port, db and
|
|
47
59
|
# password from the URI as well as any query vars.
|
|
48
|
-
#
|
|
49
|
-
# e.g.
|
|
60
|
+
#
|
|
61
|
+
# e.g.
|
|
50
62
|
#
|
|
51
63
|
# uri = URI.parse "redis://127.0.0.1/6/?timeout=5"
|
|
52
64
|
# uri.conf
|
|
@@ -54,29 +66,30 @@ module URI
|
|
|
54
66
|
#
|
|
55
67
|
def conf
|
|
56
68
|
hsh = {
|
|
57
|
-
:
|
|
58
|
-
:
|
|
59
|
-
:
|
|
60
|
-
}.merge
|
|
69
|
+
host: host,
|
|
70
|
+
port: port,
|
|
71
|
+
db: db
|
|
72
|
+
}.merge(parse_query(query))
|
|
61
73
|
hsh[:password] = password if password
|
|
62
74
|
hsh
|
|
63
75
|
end
|
|
64
|
-
|
|
76
|
+
|
|
65
77
|
def serverid
|
|
66
|
-
|
|
78
|
+
format("redis://%s:%s/%s", host, port, db)
|
|
67
79
|
end
|
|
68
|
-
|
|
80
|
+
|
|
69
81
|
private
|
|
70
|
-
|
|
71
|
-
# Based on
|
|
72
|
-
# which was based on
|
|
73
|
-
def parse_query(
|
|
82
|
+
|
|
83
|
+
# Based on: https://github.com/chneukirchen/rack/blob/master/lib/rack/utils.rb
|
|
84
|
+
# which was originally based on Mongrel
|
|
85
|
+
def parse_query(query, delim = nil)
|
|
86
|
+
delim ||= "&;"
|
|
74
87
|
params = {}
|
|
75
|
-
(
|
|
76
|
-
k, v = p.split(
|
|
88
|
+
(query || "").split(/[#{delim}] */n).each do |p|
|
|
89
|
+
k, v = p.split("=", 2).map { |str| str } # NOTE: uri_unescape
|
|
77
90
|
k = k.to_sym
|
|
78
|
-
if cur = params[k]
|
|
79
|
-
if cur.
|
|
91
|
+
if (cur = params[k])
|
|
92
|
+
if cur.instance_of?(Array)
|
|
80
93
|
params[k] << v
|
|
81
94
|
else
|
|
82
95
|
params[k] = [cur, v]
|
|
@@ -87,26 +100,26 @@ module URI
|
|
|
87
100
|
end
|
|
88
101
|
params
|
|
89
102
|
end
|
|
90
|
-
|
|
91
103
|
end
|
|
92
|
-
|
|
93
|
-
@@schemes['REDIS'] = Redis
|
|
94
|
-
end
|
|
95
104
|
|
|
105
|
+
register_scheme "REDIS", Redis
|
|
106
|
+
end
|
|
96
107
|
|
|
108
|
+
# Adds a URI method to Redis
|
|
97
109
|
class Redis
|
|
98
|
-
def self.uri(conf={})
|
|
99
|
-
URI.parse
|
|
110
|
+
def self.uri(conf = {})
|
|
111
|
+
URI.parse format("redis://%s:%s/%s", conf[:host], conf[:port], conf[:db])
|
|
100
112
|
end
|
|
101
113
|
if defined?(Redis::VERSION) && Redis::VERSION >= "2.0.0"
|
|
102
114
|
def uri
|
|
103
|
-
URI.parse
|
|
115
|
+
URI.parse format("redis://%s:%s/%s", @client.host, @client.port, @client.db)
|
|
104
116
|
end
|
|
105
117
|
else
|
|
118
|
+
# Redis < 2.0.0
|
|
106
119
|
class Client
|
|
107
120
|
def uri
|
|
108
|
-
URI.parse
|
|
121
|
+
URI.parse format("redis://%s:%s/%s", @host, @port, @db)
|
|
109
122
|
end
|
|
110
123
|
end
|
|
111
124
|
end
|
|
112
|
-
end
|
|
125
|
+
end
|
data/sig/uri/redis.rbs
ADDED
data/try/10_uri_redis_try.rb
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "uri/redis"
|
|
3
4
|
|
|
4
5
|
## Default database is 0
|
|
5
|
-
uri = URI.parse
|
|
6
|
+
uri = URI.parse "redis://localhost"
|
|
6
7
|
[uri.db, uri.host, uri.port]
|
|
7
8
|
#=> [0, 'localhost', 6379]
|
|
8
9
|
|
|
9
|
-
|
|
10
10
|
## Can parse a redis URI with a database
|
|
11
|
-
uri = URI.parse
|
|
11
|
+
uri = URI.parse "redis://localhost/2"
|
|
12
12
|
[uri.db, uri.host, uri.port]
|
|
13
13
|
#=> [2, 'localhost', 6379]
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
## Can parse a key name
|
|
17
|
-
uri = URI.parse
|
|
16
|
+
uri = URI.parse "redis://localhost/2/v1:arbitrary:key"
|
|
18
17
|
[uri.key, uri.db, uri.host, uri.port]
|
|
19
18
|
#=> ['v1:arbitrary:key', 2, 'localhost', 6379]
|
|
20
19
|
|
|
21
20
|
## Can set db
|
|
22
|
-
uri = URI.parse
|
|
21
|
+
uri = URI.parse "redis://localhost/2/v1:arbitrary:key"
|
|
23
22
|
uri.db = 6
|
|
24
23
|
uri.to_s
|
|
25
24
|
#=> 'redis://localhost/6/v1:arbitrary:key'
|
|
26
25
|
|
|
27
26
|
## Can set key
|
|
28
|
-
uri = URI.parse
|
|
29
|
-
uri.key =
|
|
27
|
+
uri = URI.parse "redis://localhost/2/v1:arbitrary:key"
|
|
28
|
+
uri.key = "v2:arbitrary:key"
|
|
30
29
|
uri.to_s
|
|
31
|
-
#=> 'redis://localhost/2/v2:arbitrary:key'
|
|
30
|
+
#=> 'redis://localhost/2/v2:arbitrary:key'
|
metadata
CHANGED
|
@@ -1,74 +1,98 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: uri-redis
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
5
|
-
prerelease: false
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 4
|
|
9
|
-
- 2
|
|
10
|
-
version: 0.4.2
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
11
5
|
platform: ruby
|
|
12
|
-
authors:
|
|
13
|
-
-
|
|
14
|
-
autorequire:
|
|
15
|
-
bindir:
|
|
6
|
+
authors:
|
|
7
|
+
- delano
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
16
10
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: redis
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '4.1'
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 4.1.0
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - "~>"
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '4.1'
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 4.1.0
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: tryouts
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.1'
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 2.1.1
|
|
43
|
+
type: :development
|
|
44
|
+
prerelease: false
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - "~>"
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '2.1'
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 2.1.1
|
|
53
|
+
description: 'URI-Redis: support for parsing Redis URIs like redis://host:port/dbindex'
|
|
54
|
+
email:
|
|
55
|
+
- delano@solutious.com
|
|
24
56
|
executables: []
|
|
25
|
-
|
|
26
57
|
extensions: []
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
- README.rdoc
|
|
31
|
-
files:
|
|
58
|
+
extra_rdoc_files: []
|
|
59
|
+
files:
|
|
60
|
+
- ".rubocop.yml"
|
|
32
61
|
- CHANGES.txt
|
|
62
|
+
- Gemfile
|
|
33
63
|
- LICENSE.txt
|
|
34
|
-
- README.
|
|
64
|
+
- README.md
|
|
35
65
|
- Rakefile
|
|
36
|
-
- VERSION.yml
|
|
37
66
|
- lib/uri/redis.rb
|
|
67
|
+
- lib/uri/redis/version.rb
|
|
68
|
+
- sig/uri/redis.rbs
|
|
38
69
|
- try/10_uri_redis_try.rb
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
70
|
+
homepage: https://github.com/delano/uri-redis
|
|
71
|
+
licenses:
|
|
72
|
+
- MIT
|
|
73
|
+
metadata:
|
|
74
|
+
allowed_push_host: https://rubygems.org
|
|
75
|
+
homepage_uri: https://github.com/delano/uri-redis
|
|
76
|
+
source_code_uri: https://github.com/delano/uri-redis/
|
|
77
|
+
changelog_uri: https://github.com/delano/uri-redis/blob/feature/001-modernize/CHANGES.txt#L1
|
|
78
|
+
rubygems_mfa_required: 'true'
|
|
79
|
+
post_install_message:
|
|
80
|
+
rdoc_options: []
|
|
81
|
+
require_paths:
|
|
47
82
|
- lib
|
|
48
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
|
-
|
|
50
|
-
requirements:
|
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
51
85
|
- - ">="
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
version: "0"
|
|
57
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
|
-
none: false
|
|
59
|
-
requirements:
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: 2.7.5
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
60
90
|
- - ">="
|
|
61
|
-
- !ruby/object:Gem::Version
|
|
62
|
-
|
|
63
|
-
segments:
|
|
64
|
-
- 0
|
|
65
|
-
version: "0"
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
66
93
|
requirements: []
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
specification_version: 3
|
|
72
|
-
summary: "URI-Redis: support for parsing redis://host:port/dbindex/keyname"
|
|
94
|
+
rubygems_version: 3.3.7
|
|
95
|
+
signing_key:
|
|
96
|
+
specification_version: 4
|
|
97
|
+
summary: 'URI-Redis: support for parsing Redis URIs'
|
|
73
98
|
test_files: []
|
|
74
|
-
|
data/README.rdoc
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
= URI-Redis v0.2
|
|
2
|
-
|
|
3
|
-
redis://host:port/dbindex
|
|
4
|
-
|
|
5
|
-
== Usage
|
|
6
|
-
|
|
7
|
-
require 'uri/redis'
|
|
8
|
-
|
|
9
|
-
conf = URI.parse 'redis://localhost:8999/2'
|
|
10
|
-
conf.host # => localhost
|
|
11
|
-
conf.port # => 8999
|
|
12
|
-
conf.db # => 2
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
== Installation
|
|
16
|
-
|
|
17
|
-
Get it in one of the following ways:
|
|
18
|
-
|
|
19
|
-
* <tt>gem install uri-redis</tt>
|
|
20
|
-
* <tt>git clone git://github.com/delano/uri-redis.git</tt>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
== More Information
|
|
24
|
-
|
|
25
|
-
* Codes[http://github.com/delano/uri-redis]
|
|
26
|
-
* RDocs[http://delano.github.com/uri-redis]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
== Credits
|
|
30
|
-
|
|
31
|
-
* Delano Mandelbaum (http://solutious.com)
|
|
32
|
-
|
|
33
|
-
== License
|
|
34
|
-
|
|
35
|
-
See LICENSE.txt
|