protocol-redis 0.5.0 → 0.5.1

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: 1be06c92dd3aa593fd22a8e4a437c93d3d74b8cf5308ec7a7721ce48f74d88c5
4
- data.tar.gz: eaa6c565377014ffae9c6bcd20b02437f6c83126da57cd12c4d768e54a320c3a
3
+ metadata.gz: a32bb81e55ba8e8b7c7ed5e18bf138661824f43c5a77c4b2b749f3486c4842a8
4
+ data.tar.gz: 415214403453d4a2758d08e8db9cc491c2f7cdcf9fff6fdfd057bcd64c2abbe8
5
5
  SHA512:
6
- metadata.gz: 6f473cf7bacd6bc990bd412c544f6911248c1a392412a0c85201b33dd60706e50f4cf6fe84c10f82d6018e3952733491aee1bb0113058201af250979cc6091da
7
- data.tar.gz: 468ddc3e83d7da8165bfebacc1c4860407647c5f8ac66129b0c889742da1da35d97e480cfee2007db172000a685d423840a1fffd81d98a4c9ceb44111486173e
6
+ metadata.gz: 741e5ca5e967a652c95c8cc81579339daf42be0e1c2cfc7c14fb57f5fbdd5bca84c2a282ec8ce78b82a830e0178e92d27abcd3e5ce34e2152a816effa3b15162
7
+ data.tar.gz: bbcd868f11a0c3df64c65eaae1043b6fde2ca218da9664ddee30fe97d48221015416047f8b91da494431585c12d9f7aa62d0b8b9518ffe6f8120a928e65fea01
@@ -31,7 +31,7 @@ module Protocol
31
31
  def info
32
32
  metadata = {}
33
33
 
34
- call('INFO').each_line(Protocol::CRLF) do |line|
34
+ call('INFO').each_line(Redis::Connection::CRLF) do |line|
35
35
  key, value = line.split(':')
36
36
 
37
37
  if value
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Protocol
24
24
  module Redis
25
- VERSION = "0.5.0"
25
+ VERSION = "0.5.1"
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-02-22 00:00:00.000000000 Z
12
+ date: 2020-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: async-http
@@ -26,7 +26,7 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: trenni
29
+ name: bake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
@@ -40,7 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: benchmark-ips
43
+ name: bake-bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
@@ -54,7 +54,21 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: covered
57
+ name: bake-modernize
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: benchmark-ips
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - ">="
@@ -81,6 +95,20 @@ dependencies:
81
95
  - - ">="
82
96
  - !ruby/object:Gem::Version
83
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: covered
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
84
112
  - !ruby/object:Gem::Dependency
85
113
  name: rspec
86
114
  requirement: !ruby/object:Gem::Requirement
@@ -96,7 +124,7 @@ dependencies:
96
124
  - !ruby/object:Gem::Version
97
125
  version: '3.6'
98
126
  - !ruby/object:Gem::Dependency
99
- name: rake
127
+ name: trenni
100
128
  requirement: !ruby/object:Gem::Requirement
101
129
  requirements:
102
130
  - - ">="
@@ -110,21 +138,11 @@ dependencies:
110
138
  - !ruby/object:Gem::Version
111
139
  version: '0'
112
140
  description:
113
- email:
114
- - samuel.williams@oriontransfer.co.nz
115
- - 12huba@gmail.com
141
+ email:
116
142
  executables: []
117
143
  extensions: []
118
144
  extra_rdoc_files: []
119
145
  files:
120
- - ".editorconfig"
121
- - ".github/workflows/development.yml"
122
- - ".gitignore"
123
- - ".rspec"
124
- - Gemfile
125
- - README.md
126
- - Rakefile
127
- - benchmark/call.rb
128
146
  - lib/protocol/redis.rb
129
147
  - lib/protocol/redis/connection.rb
130
148
  - lib/protocol/redis/error.rb
@@ -142,12 +160,11 @@ files:
142
160
  - lib/protocol/redis/methods/streams.rb
143
161
  - lib/protocol/redis/methods/strings.rb
144
162
  - lib/protocol/redis/version.rb
145
- - protocol-redis.gemspec
146
- - tasks/generate.rake
147
- - tasks/methods.trenni
148
163
  homepage: https://github.com/socketry/protocol-redis
149
- licenses: []
150
- metadata: {}
164
+ licenses:
165
+ - MIT
166
+ metadata:
167
+ funding_uri: https://github.com/sponsors/ioquatix
151
168
  post_install_message:
152
169
  rdoc_options: []
153
170
  require_paths:
@@ -156,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
173
  requirements:
157
174
  - - ">="
158
175
  - !ruby/object:Gem::Version
159
- version: '0'
176
+ version: '2.5'
160
177
  required_rubygems_version: !ruby/object:Gem::Requirement
161
178
  requirements:
162
179
  - - ">="
@@ -1,6 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
@@ -1,34 +0,0 @@
1
- name: Development
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- test:
7
- strategy:
8
- matrix:
9
- os:
10
- - ubuntu
11
- - macos
12
-
13
- ruby:
14
- - 2.4
15
- - 2.5
16
- - 2.6
17
- - 2.7
18
-
19
- include:
20
- - os: 'ubuntu'
21
- ruby: '2.6'
22
- env: COVERAGE=PartialSummary,Coveralls
23
-
24
- runs-on: ${{matrix.os}}-latest
25
-
26
- steps:
27
- - uses: actions/checkout@v1
28
- - uses: ruby/setup-ruby@v1
29
- with:
30
- ruby-version: ${{matrix.ruby}}
31
- - name: Install dependencies
32
- run: bundle install
33
- - name: Run tests
34
- run: ${{matrix.env}} bundle exec rspec
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
- .covered.db
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in async-io.gemspec
6
- gemspec
7
-
8
- group :development do
9
- gem 'pry'
10
- end
data/README.md DELETED
@@ -1,67 +0,0 @@
1
- # Protocol::Redis
2
-
3
- Implements the RESP2 and [RESP3](https://github.com/antirez/RESP3) Redis protocols.
4
-
5
- [![Actions Status](https://github.com/socketry/protocol-redis/workflows/Development/badge.svg)](https://github.com/socketry/protocol-redis/actions?workflow=Development)
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'protocol-redis'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install protocol-redis
22
-
23
- ## Usage
24
-
25
- ```ruby
26
- sockets = Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)
27
-
28
- client = Protocol::Redis::Connection.new(sockets.first)
29
- server = Protocol::Redis::Connection.new(sockets.last)
30
-
31
- client.write_object("Hello World!")
32
- puts server.read_object
33
- # => "Hello World!"
34
- ```
35
-
36
- ## Contributing
37
-
38
- 1. Fork it
39
- 2. Create your feature branch (`git checkout -b my-new-feature`)
40
- 3. Commit your changes (`git commit -am 'Add some feature'`)
41
- 4. Push to the branch (`git push origin my-new-feature`)
42
- 5. Create new Pull Request
43
-
44
- ## License
45
-
46
- Released under the MIT license.
47
-
48
- Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
49
- Copyright, 2019, by Huba Z. Nagy.
50
-
51
- Permission is hereby granted, free of charge, to any person obtaining a copy
52
- of this software and associated documentation files (the "Software"), to deal
53
- in the Software without restriction, including without limitation the rights
54
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55
- copies of the Software, and to permit persons to whom the Software is
56
- furnished to do so, subject to the following conditions:
57
-
58
- The above copyright notice and this permission notice shall be included in
59
- all copies or substantial portions of the Software.
60
-
61
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
67
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- Dir.glob('tasks/**/*.rake').each{|path| load(path)}
7
-
8
- RSpec::Core::RakeTask.new
9
-
10
- task :default => :spec
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- # Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
-
24
- require 'benchmark/ips'
25
-
26
- GC.disable
27
-
28
- def call(*arguments)
29
- arguments.size
30
- end
31
-
32
- Benchmark.ips do |benchmark|
33
- benchmark.time = 5
34
- benchmark.warmup = 1
35
-
36
- benchmark.report("*arguments") do |count|
37
- while count > 0
38
- arguments = ["foo", "bar", "baz"]
39
- call(*arguments)
40
-
41
- count -= 1
42
- end
43
- end
44
-
45
- benchmark.report("argument, *arguments") do |count|
46
- while count > 0
47
- arguments = ["bar", "baz"]
48
- call("foo", *arguments)
49
-
50
- count -= 1
51
- end
52
- end
53
-
54
- benchmark.compare!
55
- end
@@ -1,27 +0,0 @@
1
-
2
- require_relative 'lib/protocol/redis/version'
3
-
4
- Gem::Specification.new do |spec|
5
- spec.name = "protocol-redis"
6
- spec.version = Protocol::Redis::VERSION
7
- spec.authors = ["Samuel Williams", "Huba Nagy"]
8
- spec.email = ["samuel.williams@oriontransfer.co.nz", "12huba@gmail.com"]
9
-
10
- spec.summary = "A transport agnostic RESP protocol client/server."
11
- spec.homepage = "https://github.com/socketry/protocol-redis"
12
-
13
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
14
- f.match(%r{^(test|spec|features)/})
15
- end
16
-
17
- spec.require_paths = ["lib"]
18
-
19
- spec.add_development_dependency "async-http"
20
- spec.add_development_dependency "trenni"
21
- spec.add_development_dependency "benchmark-ips"
22
-
23
- spec.add_development_dependency "covered"
24
- spec.add_development_dependency "bundler"
25
- spec.add_development_dependency "rspec", "~> 3.6"
26
- spec.add_development_dependency "rake"
27
- end
@@ -1,174 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- # Copyright, 2018, by Huba Nagy.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
-
24
- require 'async'
25
-
26
- namespace :generate do
27
- def fetch_commands
28
- Async do
29
- internet = Async::HTTP::Internet.new
30
-
31
- response = internet.get("https://raw.githubusercontent.com/antirez/redis-doc/master/commands.json")
32
-
33
- JSON.parse(response.read, symbolize_names: true)
34
- ensure
35
- internet&.close
36
- end.wait
37
- end
38
-
39
- def normalize(sentence)
40
- return nil if sentence.nil?
41
-
42
- sentence = sentence.strip
43
-
44
- if sentence.end_with?(".")
45
- return sentence
46
- else
47
- return "#{sentence}."
48
- end
49
- end
50
-
51
- def module_name(group)
52
- group.split('_').collect(&:capitalize).join
53
- end
54
-
55
- task :commands do
56
- require 'async/http/internet'
57
- require 'json'
58
-
59
- @commands = fetch_commands
60
-
61
- @commands.each do |command, command_spec|
62
- method_name = command.to_s.downcase.split(/[\s\-_]+/).join('_')
63
- command_spec[:method_name] = method_name
64
- end
65
-
66
- # There is a bit of a discrepancy between how the groups appear in the JSON and how they appear in the compiled documentation, this is a mapping from `commands.json` to documentation:
67
- @groups = {
68
- 'generic' => 'generic',
69
- 'string' => 'strings',
70
- 'list' => 'lists',
71
- 'set' => 'sets',
72
- 'sorted_set' => 'sorted_sets',
73
- 'hash' => 'hashes',
74
- 'connection' => 'connection',
75
- 'server' => 'server',
76
- 'scripting' => 'scripting',
77
- 'hyperloglog' => 'counting',
78
- 'cluster' => 'cluster',
79
- 'geo' => 'geospatial',
80
- 'stream' => 'streams'
81
- }.freeze
82
- end
83
-
84
- task :methods => :commands do
85
- require 'trenni/template'
86
-
87
- template = Trenni::Template.load_file(File.expand_path("methods.trenni", __dir__))
88
-
89
- @groups.each_pair do |spec_group, group|
90
- puts "Processing #{spec_group}..."
91
-
92
- path = "lib/protocol/redis/methods/#{group}.rb"
93
-
94
- if File.exist?(path)
95
- puts "File already exists #{path}, skipping!"
96
- next
97
- end
98
-
99
- group_commands = @commands.select do |command, command_spec|
100
- command_spec[:group] == spec_group
101
- end
102
-
103
- output = template.to_string({
104
- module_name: module_name(group),
105
- group_commands: group_commands,
106
- })
107
-
108
- File.write(path, output)
109
-
110
- break
111
- end
112
- end
113
-
114
- task :documentation => :commands do
115
- @groups.each_pair do |spec_group, group|
116
- puts "Processing #{spec_group}..."
117
-
118
- path = "lib/protocol/redis/methods/#{group}.rb"
119
-
120
- unless File.exist?(path)
121
- puts "Could not find #{path}, skipping!"
122
- next
123
- end
124
-
125
- lines = File.readlines(path)
126
-
127
- group_commands = @commands.select do |command, command_spec|
128
- command_spec[:group] == spec_group
129
- end
130
-
131
- puts "\tFound #{group_commands.length} commands in this group."
132
-
133
- group_commands.each do |command, command_spec|
134
- puts "\tProcessing #{command}..."
135
-
136
- if offset = lines.find_index{|line| line.include?("def #{command_spec[:method_name]}")}
137
- puts "Found #{command} at line #{offset}."
138
-
139
- /(?<indentation>\s+)def/ =~ lines[offset]
140
-
141
- start = offset
142
- while true
143
- break unless lines[start-1] =~ /\s+#(.*?)\n/
144
- start -= 1
145
- end
146
-
147
- # Remove the comments:
148
- lines.slice!(start...offset)
149
-
150
- summary = [
151
- normalize(command_spec[:summary]),
152
- normalize(command_spec[:complexity])
153
- ].compact
154
-
155
- comments = [
156
- summary.join(' '),
157
- "@see https://redis.io/commands/#{command.to_s.downcase}"
158
- ]
159
-
160
- command_spec[:arguments]&.each do |argument|
161
- next if argument[:command] or argument[:type].nil? or argument[:type].is_a?(Array)
162
- comments << "@param #{argument[:name]} [#{argument[:type].capitalize}]"
163
- end
164
-
165
- lines.insert(start, comments.map{|comment| "#{indentation}\# #{comment}\n"})
166
- else
167
- puts "Could not find #{command} definition!"
168
- end
169
- end
170
-
171
- File.write(path, lines.join)
172
- end
173
- end
174
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- module Protocol
24
- module Redis
25
- module Methods
26
- module #{self[:module_name]}
27
- <?r
28
- first = true
29
- self[:group_commands].each do |command, command_spec|
30
- method_name = command.to_s.downcase.split(/[\s\-_]+/).join('_')
31
-
32
- unless first
33
- ?>
34
-
35
- <?r end ?>
36
- def #{method_name}(*arguments)
37
- call(#{command.to_s.dump}, *arguments)
38
- end
39
- <?r
40
- first = false
41
- end
42
- ?>
43
- end
44
- end
45
- end
46
- end