diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index e41b2f7..1dffac6 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: [2.5, 2.6, 2.7] + ruby-version: [3.4.1] steps: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index a1da2e5..9b6612e 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.5 + ruby-version: 3.4.1 bundler-cache: true - name: Run Rubocop Linter run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index 33c693c..c5bc3af 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.4.1 NewCops: enable SuggestExtensions: false diff --git a/Gemfile b/Gemfile index 8af95f3..0118558 100644 --- a/Gemfile +++ b/Gemfile @@ -4,3 +4,11 @@ source "https://rubygems.org" # Specify your gem's dependencies in potlock.gemspec gemspec + +group :development, :test do + gem "mock_redis", "~> 0.2" + gem "rake", "~> 13.0" + gem "rspec", "~> 3.0" + gem "rubocop", "~> 1.7" + gem "rubocop-rspec", "~> 2.4" +end diff --git a/Gemfile.lock b/Gemfile.lock index ee54080..2eba866 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,59 +1,79 @@ PATH remote: . specs: - potlock (0.3.0) + potlock (0.4.0) redlock (~> 1.3) GEM remote: https://rubygems.org/ specs: - ast (2.4.2) - connection_pool (2.4.1) - diff-lcs (1.4.4) - mock_redis (0.29.0) - ruby2_keywords - parallel (1.21.0) - parser (3.0.2.0) + ast (2.4.3) + connection_pool (2.5.3) + diff-lcs (1.6.2) + json (2.13.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + mock_redis (0.51.0) + redis (~> 5) + parallel (1.27.0) + parser (3.3.9.0) ast (~> 2.4.1) - rainbow (3.0.0) - rake (13.0.6) - redis (5.0.6) - redis-client (>= 0.9.0) - redis-client (0.14.1) + racc + prism (1.4.0) + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.0) + redis (5.4.1) + redis-client (>= 0.22.0) + redis-client (0.25.1) connection_pool redlock (1.3.2) redis (>= 3.0.0, < 6.0) - regexp_parser (2.1.1) - rexml (3.2.5) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + regexp_parser (2.11.0) + rspec (3.13.1) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.5) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.3) - rubocop (1.23.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.4) + rubocop (1.79.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.12.0, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.13.0) - parser (>= 3.0.1.1) - rubocop-rspec (2.6.0) - rubocop (~> 1.19) - ruby-progressbar (1.11.0) - ruby2_keywords (0.0.5) - unicode-display_width (2.1.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.46.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-capybara (2.22.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-factory_bot (2.27.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec (2.31.0) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.29.1) + rubocop (~> 1.61) + ruby-progressbar (1.13.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) PLATFORMS ruby @@ -67,4 +87,4 @@ DEPENDENCIES rubocop-rspec (~> 2.4) BUNDLED WITH - 2.2.26 + 2.6.2 diff --git a/lib/potlock/client.rb b/lib/potlock/client.rb index 937ae47..b639ef1 100644 --- a/lib/potlock/client.rb +++ b/lib/potlock/client.rb @@ -28,17 +28,19 @@ def get end def set(&block) - value = lock!(&block) - redis.set(key, value) - value + lock! do + value = block.call + redis.set(key, value) + value + end rescue Redlock::LockError => _e raise Potlock::LockError end private - def lock!(&block) - lock_manager.lock!(lock_key, retry_delay, &block) + def lock!(&) + lock_manager.lock!(lock_key, retry_delay, &) end def lock_manager diff --git a/lib/potlock/version.rb b/lib/potlock/version.rb index 15e881e..034c6f0 100644 --- a/lib/potlock/version.rb +++ b/lib/potlock/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Potlock - VERSION = "0.3.0" + VERSION = "0.4.0" end diff --git a/potlock.gemspec b/potlock.gemspec index 4444d43..8870168 100644 --- a/potlock.gemspec +++ b/potlock.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |spec| spec.description = "Potlock is redis based concurrent read-write lock distributed across processes." spec.homepage = "https://github.com/potloc/potlock" spec.license = "MIT" - spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0") + spec.required_ruby_version = Gem::Requirement.new(">= 3.4.1") spec.metadata = { "allowed_push_host" => "https://rubygems.org", "changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md", @@ -31,10 +31,4 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "redlock", "~> 1.3" - - spec.add_development_dependency "mock_redis", "~> 0.2" - spec.add_development_dependency "rake", "~> 13.0" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "rubocop", "~> 1.7" - spec.add_development_dependency "rubocop-rspec", "~> 2.4" end