redis_eval 0.2.2 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 16236c0a6ea8bcbcc3928e5d51229b9659ffc995
4
- data.tar.gz: 1f3cd2d258cf767257072d383475423d1bb0d8ac
2
+ SHA256:
3
+ metadata.gz: a7813801dcf61d877300eb2ad00e6ff8723ba46314c8bbb776edaf63dcf85a95
4
+ data.tar.gz: 672a2bf10527362b15eb29635daa7dcba114f0e653f3d8fd992e613250295452
5
5
  SHA512:
6
- metadata.gz: 1c20a35f547a2e8de7a237ba19a97474c6de8f70cfc1d772e682a8110c859ac060e37ca06df64d16bae7609e56e7f838c6d160b6dd166f790ef026726bc9ed4d
7
- data.tar.gz: 7471481f48dcd325a0c89d9b6478a027d016946b88fb176b6cf22ce6fce6664ac233a5d1588b326e742b2a2ff78c9d31c76194a4722af24da47340cad14923fa
6
+ metadata.gz: 41c1ecd4e6ceed1e4e97b8f03fcd2968233b06cab191a4928476639ab447820cba1ae46dce7d71824fe225b5314d7282a0cd5b2547b459dbd31ab5b23687bef4
7
+ data.tar.gz: 31fac3fe265daedebfe389e95415045f302527c93c83e802b29a28586a75d4971db10471cde54a121019663a6e6c5de3920b3e400ea6e9a519b5e8d5b491ca77
@@ -0,0 +1,69 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: CI
9
+ on:
10
+ push:
11
+ branches: [ master ]
12
+ pull_request:
13
+ branches: [ master ]
14
+ jobs:
15
+ lint:
16
+ name: Rubocop
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - name: Check out code
20
+ uses: actions/checkout@v2
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: "2.7"
25
+ - name: Set up Gems
26
+ run: |
27
+ gem update --system --no-document
28
+ gem install bundler --no-document
29
+ bundle config set path .bundle
30
+ bundle install -j 4
31
+ - name: Lint
32
+ run: bundle exec rubocop
33
+ test:
34
+ name: Test
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ ruby: ["3.0", "2.7", "2.6"]
39
+ runs-on: ubuntu-latest
40
+ services:
41
+ redis:
42
+ image: redis
43
+ options: >-
44
+ --health-cmd "redis-cli ping"
45
+ --health-interval 10s
46
+ --health-timeout 5s
47
+ --health-retries 5
48
+ ports:
49
+ - 6379:6379
50
+ steps:
51
+ - name: Check out code
52
+ uses: actions/checkout@v2
53
+ - name: Set up Ruby
54
+ uses: ruby/setup-ruby@v1
55
+ with:
56
+ ruby-version: ${{ matrix.ruby }}
57
+ - name: Cache dependent gems
58
+ uses: actions/cache@v1
59
+ with:
60
+ path: .bundle
61
+ key: "local-bundle-ruby-${{ matrix.ruby }}-0001"
62
+ - name: Install dependencies
63
+ run: |
64
+ gem update --system --no-document
65
+ gem install bundler --no-document
66
+ bundle config set path .bundle
67
+ bundle install -j 4
68
+ - name: Run tests
69
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -1,10 +1,12 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
10
- .DS_Store
9
+ /Gemfile.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,170 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 2.6
4
+ Exclude:
5
+ - "node_modules/**/*"
6
+ - "vendor/**/*"
7
+ - "test/**/*"
8
+
9
+ Layout/EmptyLineBetweenDefs:
10
+ Exclude:
11
+ - "lib/schema_serializer/errors.rb"
12
+
13
+ # Private methods indent.
14
+ Layout/IndentationConsistency:
15
+ EnforcedStyle: indented_internal_methods
16
+
17
+ # Warning: 120 characters
18
+ # Error: 160 characters
19
+ # Make the library more restrictive.
20
+ Layout/LineLength:
21
+ Max: 120
22
+
23
+ # Multi-line indentation with receiver.
24
+ Layout/MultilineMethodCallIndentation:
25
+ EnforcedStyle: indented_relative_to_receiver
26
+
27
+ Lint/AmbiguousBlockAssociation:
28
+ Exclude:
29
+ - "spec/**/*_spec.rb"
30
+
31
+ # May define constants within the block in spec.
32
+ Lint/ConstantDefinitionInBlock:
33
+ Exclude:
34
+ - "spec/**/*_spec.rb"
35
+
36
+ Lint/InheritException:
37
+ EnforcedStyle: standard_error
38
+
39
+ Lint/UnderscorePrefixedVariableName:
40
+ Enabled: false
41
+
42
+ Lint/UnusedMethodArgument:
43
+ Enabled: false
44
+
45
+ Metrics/AbcSize:
46
+ Max: 24
47
+
48
+ Metrics/BlockLength:
49
+ Exclude:
50
+ - "spec/**/*.rb"
51
+ - "Gemfile"
52
+ - "*.gemspec"
53
+
54
+ Metrics/CyclomaticComplexity:
55
+ Max: 10
56
+
57
+ Metrics/MethodLength:
58
+ Max: 20
59
+
60
+ Security/YAMLLoad:
61
+ Enabled: false
62
+
63
+ Style/Alias:
64
+ EnforcedStyle: prefer_alias_method
65
+
66
+ Style/AndOr:
67
+ EnforcedStyle: conditionals
68
+
69
+ Style/AsciiComments:
70
+ Enabled: false
71
+
72
+ Style/BlockDelimiters:
73
+ Enabled: false
74
+
75
+ Style/ClassAndModuleChildren:
76
+ Enabled: false
77
+
78
+ Style/CollectionMethods:
79
+ PreferredMethods:
80
+ detect: "detect"
81
+ find: "detect"
82
+ inject: "inject"
83
+ reduce: "inject"
84
+
85
+ Style/Documentation:
86
+ Enabled: false
87
+
88
+ Style/DoubleNegation:
89
+ Enabled: false
90
+
91
+ Style/EmptyCaseCondition:
92
+ Enabled: false
93
+
94
+ Style/EmptyElse:
95
+ EnforcedStyle: empty
96
+
97
+ Style/EmptyMethod:
98
+ EnforcedStyle: expanded
99
+
100
+ Style/FormatString:
101
+ EnforcedStyle: percent
102
+
103
+ # Do not use frozen_string_literal comment.
104
+ Style/FrozenStringLiteralComment:
105
+ Enabled: false
106
+
107
+ Style/HashSyntax:
108
+ Exclude:
109
+ - "Rakefile"
110
+
111
+ Style/MultilineBlockChain:
112
+ Enabled: false
113
+
114
+ Style/MixinUsage:
115
+ Exclude:
116
+ - "bin/setup"
117
+
118
+ # Use _ when 7 digits or more.
119
+ Style/NumericLiterals:
120
+ MinDigits: 7
121
+ Strict: true
122
+
123
+ Style/NumericPredicate:
124
+ Enabled: false
125
+
126
+ Style/OrAssignment:
127
+ Enabled: false
128
+
129
+ Style/PercentLiteralDelimiters:
130
+ Enabled: false
131
+
132
+ # `has_xxx?` is more readable.
133
+ Style/PreferredHashMethods:
134
+ EnforcedStyle: verbose
135
+
136
+ # Do not use unnecessary returns. (Allow to return multiple values.)
137
+ Style/RedundantReturn:
138
+ AllowMultipleReturnValues: true
139
+
140
+ # Do not specify error class when rescuing StandardError.
141
+ Style/RescueStandardError:
142
+ EnforcedStyle: implicit
143
+
144
+ # String literals use double quotes.
145
+ Style/StringLiterals:
146
+ EnforcedStyle: double_quotes
147
+
148
+ # String literal inside the string interpolation use double quotes too.
149
+ Style/StringLiteralsInInterpolation:
150
+ EnforcedStyle: double_quotes
151
+
152
+ # Percent(`%i(a b)`) and brackets(`[:a, :b]`) are acceptable.
153
+ Style/SymbolArray:
154
+ Enabled: false
155
+
156
+ # Put a trailing comma in argument list.
157
+ Style/TrailingCommaInArguments:
158
+ EnforcedStyleForMultiline: comma
159
+
160
+ # Put a trailing comma in Array literal.
161
+ Style/TrailingCommaInArrayLiteral:
162
+ EnforcedStyleForMultiline: comma
163
+
164
+ # Put a trailing comma in Hash literal.
165
+ Style/TrailingCommaInHashLiteral:
166
+ EnforcedStyleForMultiline: comma
167
+
168
+ # Percent(`%w(a b)`) and brackets(`["a", "b"]`) are acceptable.
169
+ Style/WordArray:
170
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.2
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 i2bskn
3
+ Copyright (c) 2015 Ken Iiboshi
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # RedisEval
2
2
 
3
- [![Build Status](https://travis-ci.org/i2bskn/redis_eval.svg)](https://travis-ci.org/i2bskn/redis_eval)
4
- [![codecov](https://codecov.io/gh/i2bskn/redis_eval/branch/master/graph/badge.svg)](https://codecov.io/gh/i2bskn/redis_eval)
3
+ [![Gem Version](https://badge.fury.io/rb/redis_eval.svg)](https://badge.fury.io/rb/redis_eval)
4
+ [![CI](https://github.com/i2bskn/redis_eval/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/i2bskn/redis_eval/actions?query=workflow%3ACI)
5
5
 
6
6
  Evaluate Lua scripts with Redis.
7
7
 
data/Rakefile CHANGED
@@ -1,10 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
- require "rake/testtask"
2
+ require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
3
4
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new
9
7
 
10
- task :default => :test
8
+ task :default => %i(spec rubocop)
@@ -2,9 +2,10 @@ module RedisEval
2
2
  class Script
3
3
  attr_accessor :parent
4
4
  attr_reader :source, :sha
5
+ attr_writer :redis
5
6
 
6
7
  def self.build_from_parent(src, parent, with_load: true)
7
- script = new(src, with_load: false)
8
+ script = new(src, with_load: false)
8
9
  script.parent = parent
9
10
  script.load if with_load
10
11
  script
@@ -12,8 +13,7 @@ module RedisEval
12
13
 
13
14
  def initialize(src, with_load: true)
14
15
  @source = src
15
- @sha = Digest::SHA1.hexdigest(@source)
16
- @redis = nil
16
+ @sha = Digest::SHA1.hexdigest(@source)
17
17
  self.load if with_load
18
18
  end
19
19
 
@@ -28,20 +28,16 @@ module RedisEval
28
28
  def execute(keys = [], argv = [])
29
29
  redis.evalsha(sha, Array(keys), Array(argv))
30
30
  rescue Redis::CommandError => e
31
- if e.message =~ /NOSCRIPT/
32
- redis.eval(source, Array(keys), Array(argv))
33
- else
34
- raise
35
- end
31
+ raise unless e.message =~ /NOSCRIPT/
32
+
33
+ redis.eval(source, Array(keys), Array(argv))
36
34
  end
37
35
 
38
36
  def redis
39
- return @redis if @redis
40
- parent ? parent.redis : Redis.current
41
- end
37
+ return @redis if instance_variable_defined?(:@redis)
38
+ return parent.redis unless parent.nil?
42
39
 
43
- def redis=(conn)
44
- @redis = conn
40
+ Redis.current
45
41
  end
46
42
 
47
43
  private
@@ -2,15 +2,15 @@ module RedisEval
2
2
  class ScriptSet
3
3
  attr_reader :path
4
4
 
5
- SCRIPT_SUFFIX = ".lua"
5
+ SCRIPT_SUFFIX = ".lua".freeze
6
6
 
7
7
  def initialize(target_path, conn = nil)
8
- @path = pathname(target_path)
8
+ @path = pathname(target_path)
9
9
  @redis = conn
10
10
  end
11
11
 
12
12
  def load(name)
13
- source = ERB.new(script_path(name).read).result
13
+ source = ERB.new(script_path(name).read).result(__binding__)
14
14
  loaded_scripts[name.to_s] ||= RedisEval::Script.build_from_parent(source, self)
15
15
  end
16
16
 
@@ -23,9 +23,7 @@ module RedisEval
23
23
  @redis || Redis.current
24
24
  end
25
25
 
26
- def redis=(conn)
27
- @redis = conn
28
- end
26
+ attr_writer :redis
29
27
 
30
28
  private
31
29
 
@@ -45,7 +43,7 @@ module RedisEval
45
43
  super unless respond_to?(name)
46
44
 
47
45
  self.load(name)
48
- define_singleton_method(name) { |*a, &b| loaded_scripts[name.to_s] }
46
+ define_singleton_method(name) { |*_a| loaded_scripts[name.to_s] }
49
47
  send(name, *args, &block)
50
48
  end
51
49
 
@@ -1,3 +1,3 @@
1
1
  module RedisEval
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0".freeze
3
3
  end
data/redis_eval.gemspec CHANGED
@@ -1,5 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "redis_eval/version"
5
4
 
@@ -7,24 +6,27 @@ Gem::Specification.new do |spec|
7
6
  spec.name = "redis_eval"
8
7
  spec.version = RedisEval::VERSION
9
8
  spec.authors = ["i2bskn"]
10
- spec.email = ["i2bskn@gmail.com"]
9
+ spec.email = ["iiboshi@craftake.co.jp"]
11
10
 
12
- spec.summary = %q{Evaluate Lua scripts with Redis.}
13
- spec.description = %q{Evaluate Lua scripts with Redis.}
11
+ spec.summary = "Evaluate Lua scripts with Redis."
12
+ spec.description = "Evaluate Lua scripts with Redis."
14
13
  spec.homepage = "https://github.com/i2bskn/redis_eval"
15
14
  spec.license = "MIT"
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
17
  f.match(%r{^(test|spec|features)/})
19
18
  end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
21
  spec.require_paths = ["lib"]
21
22
 
23
+ spec.required_ruby_version = ">= 2.6"
24
+
22
25
  spec.add_dependency "redis"
23
26
 
24
- spec.add_development_dependency "bundler", "~> 1.14"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "minitest", "~> 5.0"
27
- spec.add_development_dependency "pry"
28
- spec.add_development_dependency "codecov"
29
- spec.add_development_dependency "simplecov"
27
+ spec.add_development_dependency "bundler", ">= 2.1.0"
28
+ spec.add_development_dependency "pry", "~> 0.14.0"
29
+ spec.add_development_dependency "rake", "~> 13.0.0"
30
+ spec.add_development_dependency "rspec", "~> 3.10.0"
31
+ spec.add_development_dependency "rubocop", "~> 1.11.0"
30
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_eval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - i2bskn
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2021-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -28,97 +28,86 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: 2.1.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.14'
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: 0.14.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: 0.14.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
61
+ version: 13.0.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
68
+ version: 13.0.0
83
69
  - !ruby/object:Gem::Dependency
84
- name: codecov
70
+ name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: 3.10.0
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: 3.10.0
97
83
  - !ruby/object:Gem::Dependency
98
- name: simplecov
84
+ name: rubocop
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
89
+ version: 1.11.0
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: 1.11.0
111
97
  description: Evaluate Lua scripts with Redis.
112
98
  email:
113
- - i2bskn@gmail.com
99
+ - iiboshi@craftake.co.jp
114
100
  executables: []
115
101
  extensions: []
116
102
  extra_rdoc_files: []
117
103
  files:
104
+ - ".github/workflows/ci.yml"
118
105
  - ".gitignore"
119
- - ".travis.yml"
106
+ - ".rspec"
107
+ - ".rubocop.yml"
108
+ - ".ruby-version"
120
109
  - Gemfile
121
- - LICENSE.txt
110
+ - LICENSE
122
111
  - README.md
123
112
  - Rakefile
124
113
  - lib/redis_eval.rb
@@ -130,7 +119,7 @@ homepage: https://github.com/i2bskn/redis_eval
130
119
  licenses:
131
120
  - MIT
132
121
  metadata: {}
133
- post_install_message:
122
+ post_install_message:
134
123
  rdoc_options: []
135
124
  require_paths:
136
125
  - lib
@@ -138,16 +127,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
127
  requirements:
139
128
  - - ">="
140
129
  - !ruby/object:Gem::Version
141
- version: '0'
130
+ version: '2.6'
142
131
  required_rubygems_version: !ruby/object:Gem::Requirement
143
132
  requirements:
144
133
  - - ">="
145
134
  - !ruby/object:Gem::Version
146
135
  version: '0'
147
136
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 2.6.11
150
- signing_key:
137
+ rubygems_version: 3.1.4
138
+ signing_key:
151
139
  specification_version: 4
152
140
  summary: Evaluate Lua scripts with Redis.
153
141
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.3
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.14.6
6
- services:
7
- - redis-server