uri-redis 1.0.0.pre.RC1 → 1.0.0.pre.RC2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecbcabe135eef8efd0f07943fc756463833a54df37554bd2ba831042ca1a8601
4
- data.tar.gz: f57ae01ba87e295a237b887f1a83338e32cc757a26844a6f44da575294d0990a
3
+ metadata.gz: f6f9b36d382353dc8c9843e0e257123a5f9b6efe2d68ce8a841b379b71a8b9cb
4
+ data.tar.gz: 68e510a31a0996e0fa373e2371ba19d058a66ab907ca0c4bb5df85dad684eb7b
5
5
  SHA512:
6
- metadata.gz: a1469dfbbfe14bb7d44e3206282363193ffd562c3c521105c4f941a863a9e036ebac5996fab45f581bfc5e6b94074123405abcf5ebd982d152dcb80409077d20
7
- data.tar.gz: 1b1aff8dccc907f77d5dbb32c32cfe2cc35966e9e979ee0a914fe8da4f234fc5d834e28a5a83ab45cb41767cc52a7a6a686cab4b787515423b287bd82b177956
6
+ metadata.gz: b3e80f765c0131ea169fc15215bb2f0b1496b1ada1a9f40d409fd88d9c5522e8856c70870cc01c1e11a90100f08608ec5e2c295e5872900f973e5e8b02e78870
7
+ data.tar.gz: 38160331dc1a0d7218e3b2dcc946dbd8f46024350e0b1b54b39a204771fd8c005a94045e75ac5380350f999d44235e116b4ef613988645bced8fed419c23b95b
data/.rubocop.yml CHANGED
@@ -1,12 +1,175 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 2.7.5
3
3
 
4
- Style/StringLiterals:
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
5
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
6
170
  EnforcedStyle: double_quotes
7
-
8
171
  Style/StringLiteralsInInterpolation:
9
- Enabled: true
172
+ Enabled: false
10
173
  EnforcedStyle: double_quotes
11
174
 
12
175
  Layout/LineLength:
data/CHANGES.txt CHANGED
@@ -1,5 +1,9 @@
1
1
  URI-Redis, CHANGES
2
2
 
3
+ #### 1.0.0-RC2 (2023-01-16) ###########################
4
+
5
+ * FIXED: Harmonized ruby versions across gemspec, code, and github action.
6
+
3
7
 
4
8
  #### 1.0.0-RC1 (2023-01-16) ###########################
5
9
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # URI-Redis v1.0-RC1
1
+ # URI-Redis v1.0 (pre-release)
2
2
 
3
3
  Creates a URI object for Redis URLs.
4
4
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module URI
4
4
  module Redis
5
- VERSION = "1.0.0-RC1"
5
+ VERSION = "1.0.0-RC2"
6
6
  end
7
7
  end
data/lib/uri/redis.rb CHANGED
@@ -1,38 +1,50 @@
1
- require 'uri'
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 = '0.4' unless defined?(URI::Redis::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::make_components_hash(self, args)
12
- return super(tmp)
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
- r = path_query
31
+ path_query
21
32
  end
22
33
 
23
34
  def key
24
- return if self.path.nil?
35
+ return if path.nil?
36
+
25
37
  self.path ||= "/#{DEFAULT_DB}"
26
- (self.path.split('/')[2..-1] || []).join('/')
38
+ (self.path.split("/")[2..] || []).join("/")
27
39
  end
28
40
 
29
41
  def key=(val)
30
- self.path = '/' << [db, val].join('/')
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('/')[1] || DEFAULT_DB).to_i
47
+ (self.path.split("/")[1] || DEFAULT_DB).to_i
36
48
  end
37
49
 
38
50
  def db=(val)
@@ -54,29 +66,30 @@ module URI
54
66
  #
55
67
  def conf
56
68
  hsh = {
57
- :host => host,
58
- :port => port,
59
- :db => db
60
- }.merge parse_query(query)
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
- 'redis://%s:%s/%s' % [host, port, db]
78
+ format("redis://%s:%s/%s", host, port, db)
67
79
  end
68
80
 
69
81
  private
70
82
 
71
- # Based on / stolen from: https://github.com/chneukirchen/rack/blob/master/lib/rack/utils.rb
72
- # which was based on / stolen from Mongrel
73
- def parse_query(qs, d = '&;')
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
- (qs || '').split(/[#{d}] */n).each do |p|
76
- k, v = p.split('=', 2).map { |str| str } # NOTE: uri_unescape
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.class == Array
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,25 +100,25 @@ module URI
87
100
  end
88
101
  params
89
102
  end
90
-
91
103
  end
92
104
 
93
- register_scheme 'REDIS', Redis
105
+ register_scheme "REDIS", Redis
94
106
  end
95
107
 
96
-
108
+ # Adds a URI method to Redis
97
109
  class Redis
98
- def self.uri(conf={})
99
- URI.parse 'redis://%s:%s/%s' % [conf[:host], conf[:port], conf[:db]]
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 'redis://%s:%s/%s' % [@client.host, @client.port, @client.db]
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 'redis://%s:%s/%s' % [@host, @port, @db]
121
+ URI.parse format("redis://%s:%s/%s", @host, @port, @db)
109
122
  end
110
123
  end
111
124
  end
@@ -1,31 +1,30 @@
1
- require 'uri/redis'
1
+ # frozen_string_literal: true
2
2
 
3
+ require "uri/redis"
3
4
 
4
5
  ## Default database is 0
5
- uri = URI.parse 'redis://localhost'
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 'redis://localhost/2'
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 'redis://localhost/2/v1:arbitrary:key'
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 'redis://localhost/2/v1:arbitrary:key'
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 'redis://localhost/2/v1:arbitrary:key'
29
- uri.key = 'v2:arbitrary: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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.RC1
4
+ version: 1.0.0.pre.RC2
5
5
  platform: ruby
6
6
  authors:
7
7
  - delano
@@ -75,6 +75,7 @@ metadata:
75
75
  homepage_uri: https://github.com/delano/uri-redis
76
76
  source_code_uri: https://github.com/delano/uri-redis/
77
77
  changelog_uri: https://github.com/delano/uri-redis/blob/feature/001-modernize/CHANGES.txt#L1
78
+ rubygems_mfa_required: 'true'
78
79
  post_install_message:
79
80
  rdoc_options: []
80
81
  require_paths:
@@ -83,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
84
  requirements:
84
85
  - - ">="
85
86
  - !ruby/object:Gem::Version
86
- version: 2.6.0
87
+ version: 2.7.5
87
88
  required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  requirements:
89
90
  - - ">"