idempotency 0.1.2 → 0.1.3
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 +4 -4
- data/.github/workflows/release.yml +12 -6
- data/Gemfile.lock +1 -1
- data/README.md +11 -0
- data/lib/idempotency/testing/helpers.rb +29 -0
- data/lib/idempotency/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f09805d7d2ec4b6d8e56f0d6ef0cc298dbe1a7df27e8cc542a45e401792b653
|
|
4
|
+
data.tar.gz: 7117efd37aed82f6e4edea29a2c7b45357262e3e31b2e1a7e348a37521c11af8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 400b2ed412cad240f18e305c1ce57cc80a96e90f5103db11f1bcb8053734c819c976512058ee9c72eff74891b817524e86d525815b32ef50642670ddffc16a54
|
|
7
|
+
data.tar.gz: e7924c51b71ac88ec1103888f45a43e9aa77da54f84395472b3b188a4c9f443045113d97385b7416c9e1cfb8bd364ed7daf95229c28c9800caf92df83e17cace
|
|
@@ -8,10 +8,16 @@ on:
|
|
|
8
8
|
jobs:
|
|
9
9
|
build:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
|
14
|
+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
|
|
15
|
+
|
|
11
16
|
steps:
|
|
12
|
-
- uses: actions/checkout@
|
|
13
|
-
- name:
|
|
14
|
-
uses:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
|
+
with:
|
|
21
|
+
bundler-cache: true
|
|
22
|
+
ruby-version: '3.4'
|
|
23
|
+
- uses: rubygems/release-gem@v1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -89,3 +89,14 @@ end
|
|
|
89
89
|
|
|
90
90
|
# Render your response
|
|
91
91
|
```
|
|
92
|
+
|
|
93
|
+
### Testing
|
|
94
|
+
|
|
95
|
+
For those using `mock_redis` gem, some methods that `idempotency` gem uses are not implemented (e.g. eval, evalsha), and this could cause test cases to fail. To get around this, the gem has a monkeypatch over `mock_redis` gem to override the missing methods. To use it, simply add following lines to your `spec_helper.rb`:
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
RSpec.configure do |config|
|
|
99
|
+
config.include Idempotency::Testing::Helpers
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'idempotency/cache'
|
|
4
|
+
|
|
5
|
+
class Idempotency
|
|
6
|
+
module Testing
|
|
7
|
+
module Helpers
|
|
8
|
+
def self.included(_base)
|
|
9
|
+
return unless defined?(MockRedis)
|
|
10
|
+
|
|
11
|
+
MockRedis.class_eval do
|
|
12
|
+
def evalsha(sha, keys:, argv:)
|
|
13
|
+
return unless sha == Idempotency::Cache::COMPARE_AND_DEL_SCRIPT_SHA
|
|
14
|
+
|
|
15
|
+
value = argv[0]
|
|
16
|
+
cached_value = get(keys[0])
|
|
17
|
+
|
|
18
|
+
if value == cached_value
|
|
19
|
+
del(keys[0])
|
|
20
|
+
value
|
|
21
|
+
else
|
|
22
|
+
cached_value
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/idempotency/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: idempotency
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vu Hoang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-01-
|
|
11
|
+
date: 2025-01-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -91,6 +91,7 @@ files:
|
|
|
91
91
|
- lib/idempotency/constants.rb
|
|
92
92
|
- lib/idempotency/hanami.rb
|
|
93
93
|
- lib/idempotency/rails.rb
|
|
94
|
+
- lib/idempotency/testing/helpers.rb
|
|
94
95
|
- lib/idempotency/version.rb
|
|
95
96
|
homepage: https://www.ascenda.com
|
|
96
97
|
licenses:
|