redis-prescription 1.0.0 → 2.5.0

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: e4c70dac256ca079b9af76b03cefc189db30507860c0a6816ddd519da7bdd75a
4
- data.tar.gz: a1c5e2fe3645bd592f26a00a16accf2be1d0340468c4f824e06c7da51f1d29eb
3
+ metadata.gz: 102d72bbeaeed7fb1280168260f9f0f93db29aa4629975fef16738cb34d6a412
4
+ data.tar.gz: 8012996f4f92d95d082df58df434844a31e8423d066e71b57adcad6b23917aa3
5
5
  SHA512:
6
- metadata.gz: a1f3988eb35db89865af75881b7bd0e33cb4a922fa468589f8f9de3396ac88118405b400ac8999995648ed92a224f768f2fc88a19d3a75d6c54145c9f01488b1
7
- data.tar.gz: 19a72258d2adf1bef91b436965ebcea477a886cc4c9e269e81f5cffe489b406811f9fc7c46088bfc02071c720fecc016c819b48e297bd8b602e6ce11d21d31fd
6
+ metadata.gz: 6387dd02ae632d8eb0f7e0dbbf2c769bb0349b390c869f0b0f94bfc35123a825bdb0eb529ec06913ac57d23c8fac0513f993aa01db988dab4b3aea5e97f23e5c
7
+ data.tar.gz: cabe06b0ec13367f176ea56071547e9881e5fa764398953417e5e4da9e705109d7136d176e3b964a92530cef1d9c7ca2e75334603b3a45c461fc31c6dc3b7e2a
data/LICENSE.txt CHANGED
@@ -1,6 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Alexey Zapparov
3
+ Copyright (c) 2020-2023 Alexey Zapparov
4
+ Copyright (c) 2018 SensorTower Inc.
4
5
 
5
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
7
  of this software and associated documentation files (the "Software"), to deal
@@ -1,48 +1,65 @@
1
- # Redis::Prescription
1
+ = Redis::Prescription
2
2
 
3
3
  Redis LUA stored procedure runner. Preloads (and reloads when needed, e.g. when
4
4
  scripts were flushed away) script and then runs it with `EVALSHA`.
5
5
 
6
6
 
7
- ## Installation
7
+ == Installation
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- ```ruby
12
- gem "redis-prescription"
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
11
+ $ bundle add redis-prescription
18
12
 
19
13
  Or install it yourself as:
20
14
 
21
15
  $ gem install redis-prescription
22
16
 
23
17
 
24
- ## Usage
18
+ == Usage
25
19
 
26
- ``` ruby
27
- script = Redis::Prescription.new <<~LUA
20
+ [source,ruby]
21
+ ----
22
+ script = RedisPrescription.new <<~LUA
28
23
  return tonumber(redis.call('GET', KEYS[1]) or 42)
29
24
  LUA
30
25
 
31
- script.eval(Redis.current, :xxx) # => 42
32
-
33
- Redis.current.set(:xxx, 123)
34
- script.eval(Redis.current, :xxx) # => 123
35
- ```
36
-
37
-
38
- ## Supported Ruby Versions
39
-
40
- This library aims to support and is [tested against][1] the following Ruby
41
- versions:
42
-
43
- * Ruby 2.3.x
44
- * Ruby 2.4.x
45
- * Ruby 2.5.x
26
+ redis = Redis.new
27
+ script.call(redis, keys: [:xxx]) # => 42
28
+
29
+ redis.set(:xxx, 123)
30
+ script.call(redis, keys: [:xxx]) # => 123
31
+ ----
32
+
33
+
34
+ == Compatibility
35
+
36
+ This library aims to support and is tested against:
37
+
38
+ * https://www.ruby-lang.org[Ruby]
39
+ ** MRI 2.7.x
40
+ ** MRI 3.0.x
41
+ ** MRI 3.1.x
42
+ ** MRI 3.2.x
43
+ * https://redis.io[Redis Server]
44
+ ** 6.0.x
45
+ ** 6.2.x
46
+ ** 7.0.x
47
+ * https://github.com/redis/redis-rb[redis-rb]
48
+ ** 4.1.x
49
+ ** 4.2.x
50
+ ** 4.3.x
51
+ ** 4.4.x
52
+ ** 4.5.x
53
+ ** 4.6.x
54
+ ** 4.7.x
55
+ ** 4.8.x
56
+ ** 5.0.x
57
+ * https://github.com/resque/redis-namespace[redis-namespace]
58
+ ** 1.10.x
59
+ * https://github.com/redis-rb/redis-client[redis-client]
60
+ ** 0.12.x
61
+ ** 0.13.x
62
+ ** 0.14.x
46
63
 
47
64
  If something doesn't work on one of these versions, it's a bug.
48
65
 
@@ -57,33 +74,27 @@ patches in a timely fashion. If critical issues for a particular implementation
57
74
  exist at the time of a major release, support for that Ruby version may be
58
75
  dropped.
59
76
 
77
+ The same applies to *Redis Server*, *redis-rb*, *redis-namespace*,
78
+ and *redis-client* support.
79
+
60
80
 
61
- ## Development
81
+ == Similar Projects
62
82
 
63
- After checking out the repo, run `bundle install` to install dependencies.
64
- Then, run `bundle exec rake spec` to run the tests with ruby-rb client.
83
+ * https://github.com/Shopify/wolverine
65
84
 
66
- To install this gem onto your local machine, run `bundle exec rake install`.
67
- To release a new version, update the version number in `version.rb`, and then
68
- run `bundle exec rake release`, which will create a git tag for the version,
69
- push git commits and tags, and push the `.gem` file to [rubygems.org][2].
70
85
 
86
+ == Development
71
87
 
72
- ## Contributing
88
+ scripts/update-gemfiles
89
+ scripts/run-rspec
90
+ bundle exec rubocop
73
91
 
74
- * Fork sidekiq-throttled on GitHub
92
+
93
+ == Contributing
94
+
95
+ * Fork redis-prescription
75
96
  * Make your changes
76
97
  * Ensure all tests pass (`bundle exec rake`)
77
- * Send a pull request
98
+ * Send a merge request
78
99
  * If we like them we'll merge them
79
100
  * If we've accepted a patch, feel free to ask for commit access!
80
-
81
-
82
- ## Copyright
83
-
84
- Copyright (c) 2018 SensorTower Inc.
85
- See LICENSE.md for further details.
86
-
87
-
88
- [1]: http://travis-ci.org/sensortower/redis-prescription
89
- [2]: https://rubygems.org
@@ -1,90 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "prescription/version"
3
+ require_relative "../redis_prescription"
4
4
 
5
- # @see https://github.com/redis/redis-rb
6
5
  class Redis
7
- # Lua script executor for redis.
8
- #
9
- # Instead of executing script with `EVAL` everytime - loads script once
10
- # and then runs it with `EVALSHA`.
11
- #
12
- # @example Usage
13
- #
14
- # script = Redis::Prescription.new("return ARGV[1] + ARGV[2]")
15
- # script.eval(Redis.current, :argv => [2, 2]) # => 2
16
- class Prescription
17
- # Script load command.
18
- LOAD = "load"
19
- private_constant :LOAD
20
-
21
- # Redis error fired when script ID is unkown.
22
- NOSCRIPT = "NOSCRIPT"
23
- private_constant :NOSCRIPT
24
-
25
- # LUA script source.
26
- # @return [String]
27
- attr_reader :source
28
-
29
- # LUA script SHA1 digest.
30
- # @return [String]
31
- attr_reader :digest
32
-
33
- # @param source [#to_s] Lua script.
34
- def initialize(source)
35
- @source = source.to_s.strip.freeze
36
- @digest = Digest::SHA1.hexdigest(@source).freeze
6
+ # @deprecated Use ::RedisPrescription
7
+ class Prescription < RedisPrescription
8
+ class << self
9
+ # Controls if deprecation warnings should be silenced or not.
10
+ # Defaults to `false`.
11
+ #
12
+ # @return [Boolean]
13
+ attr_accessor :silence_deprecation_warning
37
14
  end
38
15
 
39
- # Loads script to redis.
40
- # @param redis (see #namespaceless)
41
- # @return [void]
42
- def bootstrap!(redis)
43
- digest = namespaceless(redis).script(LOAD, @source)
44
- return if @digest == digest
45
-
46
- # XXX: this may happen **ONLY** if script digesting will be
47
- # changed in redis, which is not likely gonna happen.
48
- warn "[#{self.class}] Unexpected digest: " \
49
- "#{digest.inspect} (expected: #{@digest.inspect})"
16
+ self.silence_deprecation_warning = false
50
17
 
51
- @digest = digest.freeze
52
- end
53
-
54
- # Executes script and returns result of execution.
55
- # @param redis (see #namespaceless)
56
- # @param keys [Array] keys to pass to the script
57
- # @param argv [Array] arguments to pass to the script
58
- # @return depends on the script
59
- def eval(redis, keys: [], argv: [])
60
- redis.evalsha(@digest, keys, argv)
61
- rescue => e
62
- raise unless e.message.include? NOSCRIPT
63
-
64
- bootstrap!(redis)
65
- redis.evalsha(@digest, keys, argv)
66
- end
67
-
68
- # Reads given file and returns new {Prescription} with its contents.
69
- # @param file [String]
70
- # @return [Prescription]
71
- def self.read(file)
72
- new File.read file
73
- end
18
+ def initialize(*)
19
+ super
74
20
 
75
- private
21
+ return if self.class.silence_deprecation_warning
76
22
 
77
- # Yields real namespace-less redis client.
78
- # @param redis [Redis, Redis::Namespace]
79
- # @return [Redis]
80
- def namespaceless(redis)
81
- if redis.is_a?(Redis)
82
- redis
83
- elsif defined?(Redis::Namespace) && redis.is_a?(Redis::Namespace)
84
- redis.redis
85
- else
86
- raise TypeError, "Unsupported redis client type: #{redis.class}"
87
- end
23
+ warn "#{self.class} usage was deprecated, please use RedisPrescription instead"
88
24
  end
89
25
  end
90
26
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "redis_prescription"
4
+ require_relative "redis/prescription"
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../errors"
4
+
5
+ class RedisPrescription
6
+ module Adapters
7
+ # redis-rb adapter
8
+ class Redis
9
+ def self.adapts?(redis)
10
+ defined?(::Redis) && redis.is_a?(::Redis)
11
+ end
12
+
13
+ def initialize(redis)
14
+ @redis = redis
15
+ end
16
+
17
+ def eval(script, keys, argv)
18
+ @redis.eval(script, keys, argv)
19
+ rescue ::Redis::CommandError => e
20
+ raise CommandError, e.message
21
+ end
22
+
23
+ def evalsha(digest, keys, argv)
24
+ @redis.evalsha(digest, keys, argv)
25
+ rescue ::Redis::CommandError => e
26
+ raise CommandError, e.message
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../errors"
4
+
5
+ class RedisPrescription
6
+ module Adapters
7
+ # redis-client adapter
8
+ class RedisClient
9
+ def self.adapts?(redis)
10
+ return true if defined?(::RedisClient) && redis.is_a?(::RedisClient)
11
+ return true if defined?(::RedisClient::Decorator::Client) && redis.is_a?(::RedisClient::Decorator::Client)
12
+
13
+ false
14
+ end
15
+
16
+ def initialize(redis)
17
+ @redis = redis
18
+ end
19
+
20
+ def eval(script, keys, argv)
21
+ @redis.call("EVAL", script, keys.size, *keys, *argv)
22
+ rescue ::RedisClient::CommandError => e
23
+ raise CommandError, e.message
24
+ end
25
+
26
+ def evalsha(digest, keys, argv)
27
+ @redis.call("EVALSHA", digest, keys.size, *keys, *argv)
28
+ rescue ::RedisClient::CommandError => e
29
+ raise CommandError, e.message
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../errors"
4
+
5
+ class RedisPrescription
6
+ module Adapters
7
+ # redis-namespace adapter
8
+ class RedisNamespace
9
+ def self.adapts?(redis)
10
+ defined?(::Redis::Namespace) && redis.is_a?(::Redis::Namespace)
11
+ end
12
+
13
+ def initialize(redis)
14
+ @redis = redis
15
+ end
16
+
17
+ def eval(script, keys, argv)
18
+ @redis.eval(script, keys, argv)
19
+ rescue ::Redis::CommandError => e
20
+ raise CommandError, e.message
21
+ end
22
+
23
+ def evalsha(digest, keys, argv)
24
+ @redis.evalsha(digest, keys, argv)
25
+ rescue ::Redis::CommandError => e
26
+ raise CommandError, e.message
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./adapters/redis"
4
+ require_relative "./adapters/redis_client"
5
+ require_relative "./adapters/redis_namespace"
6
+
7
+ class RedisPrescription
8
+ # @api internal
9
+ module Adapters
10
+ class << self
11
+ def [](redis)
12
+ return Adapters::Redis.new(redis) if Adapters::Redis.adapts?(redis)
13
+ return Adapters::RedisClient.new(redis) if Adapters::RedisClient.adapts?(redis)
14
+ return Adapters::RedisNamespace.new(redis) if Adapters::RedisNamespace.adapts?(redis)
15
+
16
+ raise TypeError, "Unsupported redis client: #{redis.class}"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RedisPrescription
4
+ # Top-level error class for all RedisPrescription errors
5
+ class Error < StandardError; end
6
+
7
+ # Redis command error wrapper, `#cause` will be `Redis::CommandError` or
8
+ # `RedisClient::CommandError`.
9
+ class CommandError < Error; end
10
+
11
+ # Lua script eval/evalsha failure
12
+ class ScriptError < Error
13
+ # rubocop:disable Layout/LineLength
14
+ LUA_ERROR_MESSAGE = %r{
15
+ # * Error compiling script:
16
+ # ** Redis 6.0, 6.2, 7.0
17
+ # *** ERR Error compiling script (new function): user_script:7: unexpected symbol near '!'
18
+ # * Error running script:
19
+ # ** Redis 6.0, 6.2
20
+ # *** ERR Error running script (call to f_64203334c42d5690c2d008a78aa7789f5b83e5bb): @user_script:4: user_script:4: attempt to perform arithmetic on a string value
21
+ # ** Redis 7.0
22
+ # *** ERR user_script:4: attempt to perform arithmetic on a string value script: 64203334c42d5690c2d008a78aa7789f5b83e5bb, on @user_script:4.
23
+ \A
24
+ ERR\s
25
+ (?:
26
+ Error\scompiling\sscript\s\([^)]+\):\s # Redis 6.0, 6.2, 7.0
27
+ .+:(?<loc>\d+):\s # Redis 6.0, 6.2, 7.0
28
+ (?<message>.+) # Redis 6.0, 6.2, 7.0
29
+ |
30
+ (?:Error\srunning\sscript\s\([^)]+\):\s@\S+\s)? # Redis 6.0, 6.2
31
+ .+:(?<loc>\d+):\s # Redis 6.0, 6.2, 7.0
32
+ (?<message>.+?) # Redis 6.0, 6.2, 7.0
33
+ (?::\s\h+,\son\s@[^:]+:\d+\.)? # Redis 7.0
34
+ )
35
+ \z
36
+ }x.freeze
37
+ private_constant :LUA_ERROR_MESSAGE
38
+ # rubocop:enable Layout/LineLength
39
+
40
+ # Lua script source
41
+ #
42
+ # @return [String]
43
+ attr_reader :source
44
+
45
+ # Line of code where error was encountered
46
+ #
47
+ # @return [Integer?]
48
+ attr_reader :loc
49
+
50
+ # @param message [String]
51
+ # @param source [#to_s]
52
+ def initialize(message, source)
53
+ @source = -source.to_s
54
+
55
+ if (parsed = LUA_ERROR_MESSAGE.match(message))
56
+ @loc = parsed[:loc].to_i
57
+ message = [parsed[:message], excerpt(@source, @loc)].compact.join("\n\n")
58
+ end
59
+
60
+ super(message)
61
+ end
62
+
63
+ private
64
+
65
+ def excerpt(source, loc)
66
+ lines = excerpt_lines(source, loc)
67
+ gutter = lines.map(&:first).max.to_s.length
68
+
69
+ lines.map! do |(pos, line)|
70
+ format(pos == loc ? "\t%#{gutter}d > %s" : "\t%#{gutter}d | %s", pos, line).rstrip
71
+ end
72
+
73
+ lines.join("\n")
74
+ rescue => e
75
+ warn "Failed extracting source excerpt: #{e.message}"
76
+ nil
77
+ end
78
+
79
+ def excerpt_lines(source, loc)
80
+ lines = source.lines
81
+ pos = loc - 1 # reported line of code is 1-offset
82
+ min = pos - 2 # 2 lines of head context
83
+ max = pos + 2 # 2 lines of tail context
84
+
85
+ min = 0 if min.negative?
86
+ max = lines.size - 1 if lines.size <= max
87
+
88
+ (min..max).map { |i| [i.succ, lines[i]] }
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class RedisPrescription
4
+ # Gem version.
5
+ VERSION = "2.5.0"
6
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest/sha1"
4
+
5
+ require_relative "./redis_prescription/adapters"
6
+ require_relative "./redis_prescription/errors"
7
+ require_relative "./redis_prescription/version"
8
+
9
+ # Lua script executor for redis.
10
+ #
11
+ # Instead of executing script with `EVAL` everytime - loads script once
12
+ # and then runs it with `EVALSHA`.
13
+ #
14
+ # @example Usage
15
+ #
16
+ # redis = Redis.new
17
+ # script = RedisPrescription.new("return ARGV[1] + ARGV[2]")
18
+ # script.call(redis, argv: [2, 2]) # => 4
19
+ class RedisPrescription
20
+ # Redis error fired when script ID is unkown.
21
+ NOSCRIPT = "NOSCRIPT"
22
+ private_constant :NOSCRIPT
23
+
24
+ EMPTY_LIST = [].freeze
25
+ private_constant :EMPTY_LIST
26
+
27
+ # Lua script source.
28
+ # @return [String]
29
+ attr_reader :source
30
+
31
+ # Lua script SHA1 digest.
32
+ # @return [String]
33
+ attr_reader :digest
34
+
35
+ # @param source [#to_s] Lua script
36
+ def initialize(source)
37
+ @source = -source.to_s
38
+ @digest = Digest::SHA1.hexdigest(@source).freeze
39
+ end
40
+
41
+ # Executes script and return result of execution.
42
+ # @param redis [Redis, RedisClient]
43
+ # @param keys [Array] keys to pass to the script
44
+ # @param argv [Array] arguments to pass to the script
45
+ # @raise [TypeError] if given redis client is not supported
46
+ # @raise [ScriptError] if script execution failed
47
+ # @return depends on the script
48
+ def call(redis, keys: EMPTY_LIST, argv: EMPTY_LIST)
49
+ evalsha_with_fallback(Adapters[redis], keys, argv)
50
+ rescue CommandError => e
51
+ raise ScriptError.new(e.message, @source)
52
+ end
53
+
54
+ private
55
+
56
+ def evalsha_with_fallback(redis, keys, argv)
57
+ redis.evalsha(@digest, keys, argv)
58
+ rescue CommandError => e
59
+ raise unless e.message.include?(NOSCRIPT)
60
+
61
+ redis.eval(@source, keys, argv)
62
+ end
63
+ end
metadata CHANGED
@@ -1,56 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-prescription
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Zapparov
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-11 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.16'
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: |
28
- Preloads (and reloads when needed, e.g. when scripts
29
- were flushed away) script and then runs it with `EVALSHA`.
14
+ Preloads (and reloads when needed, e.g. when scripts were flushed away)
15
+ script and then runs it with `EVALSHA`.
30
16
  email:
31
- - ixti@member.fsf.org
17
+ - alexey@zapparov.com
32
18
  executables: []
33
19
  extensions: []
34
20
  extra_rdoc_files: []
35
21
  files:
36
- - ".gitignore"
37
- - ".rspec"
38
- - ".rubocop.yml"
39
- - ".travis.yml"
40
- - ".yardopts"
41
- - Gemfile
42
- - Guardfile
43
22
  - LICENSE.txt
44
- - README.md
45
- - Rakefile
23
+ - README.adoc
24
+ - lib/redis-prescription.rb
46
25
  - lib/redis/prescription.rb
47
- - lib/redis/prescription/version.rb
48
- - redis-prescription.gemspec
49
- homepage: https://github.com/ixti/redis-prescription
26
+ - lib/redis_prescription.rb
27
+ - lib/redis_prescription/adapters.rb
28
+ - lib/redis_prescription/adapters/redis.rb
29
+ - lib/redis_prescription/adapters/redis_client.rb
30
+ - lib/redis_prescription/adapters/redis_namespace.rb
31
+ - lib/redis_prescription/errors.rb
32
+ - lib/redis_prescription/version.rb
33
+ homepage: https://gitlab.com/ixti/redis-prescription
50
34
  licenses:
51
35
  - MIT
52
- metadata: {}
53
- post_install_message:
36
+ metadata:
37
+ homepage_uri: https://gitlab.com/ixti/redis-prescription
38
+ source_code_uri: https://gitlab.com/ixti/redis-prescription
39
+ bug_tracker_uri: https://gitlab.com/ixti/redis-prescription/issues
40
+ changelog_uri: https://gitlab.com/ixti/redis-prescription/blob/v2.5.0/CHANGES.md
41
+ rubygems_mfa_required: 'true'
42
+ post_install_message:
54
43
  rdoc_options: []
55
44
  require_paths:
56
45
  - lib
@@ -58,16 +47,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
47
  requirements:
59
48
  - - ">="
60
49
  - !ruby/object:Gem::Version
61
- version: '0'
50
+ version: '2.7'
62
51
  required_rubygems_version: !ruby/object:Gem::Requirement
63
52
  requirements:
64
53
  - - ">="
65
54
  - !ruby/object:Gem::Version
66
55
  version: '0'
67
56
  requirements: []
68
- rubyforge_project:
69
- rubygems_version: 2.7.3
70
- signing_key:
57
+ rubygems_version: 3.3.26
58
+ signing_key:
71
59
  specification_version: 4
72
60
  summary: Redis LUA stored procedure runner.
73
61
  test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /Gemfile.lock
2
-
3
- /.autoenv.zsh
4
- /.bundle
5
- /.yardoc
6
- /_yardoc
7
- /coverage
8
- /doc
9
- /pkg
10
- /tmp
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,40 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.3
3
- DisplayCopNames: true
4
-
5
-
6
- ## Layout ######################################################################
7
-
8
- Layout/DotPosition:
9
- EnforcedStyle: trailing
10
-
11
- Layout/IndentArray:
12
- EnforcedStyle: consistent
13
-
14
-
15
- ## Metrics #####################################################################
16
-
17
- Metrics/BlockLength:
18
- Exclude:
19
- - "spec/**/*"
20
-
21
-
22
- ## Style #######################################################################
23
-
24
- Style/HashSyntax:
25
- EnforcedStyle: hash_rockets
26
-
27
- Style/RegexpLiteral:
28
- EnforcedStyle: percent_r
29
-
30
- Style/RescueStandardError:
31
- EnforcedStyle: implicit
32
-
33
- Style/SafeNavigation:
34
- Enabled: false
35
-
36
- Style/StringLiterals:
37
- EnforcedStyle: double_quotes
38
-
39
- Style/YodaCondition:
40
- Enabled: false
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- language: ruby
2
- sudo: false
3
-
4
- services:
5
- - redis-server
6
-
7
- cache: bundler
8
-
9
- rvm:
10
- - 2.3
11
- - 2.4
12
- - 2.5
13
-
14
- matrix:
15
- fast_finish: true
16
- include:
17
- - rvm: 2.4
18
- env: TEST_SUITE="rubocop"
19
-
20
- before_install:
21
- - gem update --system
22
- - gem --version
23
- - gem install bundler --no-rdoc --no-ri
24
- - bundle --version
25
-
26
- install: bundle install --without development doc
27
-
28
- script: bundle exec rake $TEST_SUITE
data/.yardopts DELETED
@@ -1,2 +0,0 @@
1
- --markup-provider=redcarpet
2
- --markup=markdown
data/Gemfile DELETED
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
- ruby RUBY_VERSION
5
-
6
- gem "rake"
7
- gem "rspec"
8
- gem "rubocop", "~> 0.52.0", :require => false
9
-
10
- gem "redis"
11
- gem "redis-namespace"
12
-
13
- group :development do
14
- gem "guard", :require => false
15
- gem "guard-rspec", :require => false
16
- gem "guard-rubocop", :require => false
17
- gem "pry", :require => false
18
- end
19
-
20
- group :test do
21
- gem "codecov", :require => false
22
- gem "simplecov", :require => false
23
- end
24
-
25
- group :doc do
26
- gem "redcarpet"
27
- gem "yard"
28
- end
29
-
30
- # Specify your gem's dependencies in redis-prescription.gemspec
31
- gemspec
data/Guardfile DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- guard :rspec, :cmd => "bundle exec rspec" do
4
- require "guard/rspec/dsl"
5
- dsl = Guard::RSpec::Dsl.new(self)
6
-
7
- # RSpec files
8
- rspec = dsl.rspec
9
- watch(rspec.spec_helper) { rspec.spec_dir }
10
- watch(rspec.spec_support) { rspec.spec_dir }
11
- watch(rspec.spec_files)
12
-
13
- # Ruby files
14
- ruby = dsl.ruby
15
- dsl.watch_spec_files_for(ruby.lib_files)
16
- end
17
-
18
- guard :rubocop do
19
- watch(%r{.+\.rb$})
20
- watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
21
- end
data/Rakefile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
-
5
- require "rspec/core/rake_task"
6
- RSpec::Core::RakeTask.new
7
-
8
- require "rubocop/rake_task"
9
- RuboCop::RakeTask.new
10
-
11
- if ENV["CI"]
12
- task :default => :spec
13
- else
14
- task :default => %i[rubocop spec]
15
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Redis
4
- class Prescription
5
- # Gem version.
6
- VERSION = "1.0.0"
7
- end
8
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require "redis/prescription/version"
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = "redis-prescription"
10
- spec.version = Redis::Prescription::VERSION
11
- spec.authors = ["Alexey Zapparov"]
12
- spec.email = ["ixti@member.fsf.org"]
13
-
14
- spec.summary = "Redis LUA stored procedure runner."
15
- spec.description = <<~DESCRIPTION
16
- Preloads (and reloads when needed, e.g. when scripts
17
- were flushed away) script and then runs it with `EVALSHA`.
18
- DESCRIPTION
19
-
20
- spec.homepage = "https://github.com/ixti/redis-prescription"
21
- spec.license = "MIT"
22
-
23
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
- f.match(%r{^(test|spec|features)/})
25
- end
26
-
27
- spec.require_paths = ["lib"]
28
-
29
- spec.add_development_dependency "bundler", "~> 1.16"
30
- end