request_store 1.5.1 → 1.6.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: a8829219a616f7288e08e65fe5d39d491b1693cb31ca5632355a4a4216167a21
4
- data.tar.gz: 1f151729fdffa5b98422b359ab3f145caf8a19943bb075f0b5d2b13999b318b3
3
+ metadata.gz: e791505be9e9e0f6f8bf0b3229cb7840f473f71fdb6a4bb7f4d7375a06d11cdf
4
+ data.tar.gz: b8866d3e58f810f96e3ea1b4ef7b4491b69cdf0bc6df06e5610c6d8f3312e8dd
5
5
  SHA512:
6
- metadata.gz: bc75042c21655c31f3392520e49a7bc816a157a5ac60ba783b73436d5293b88379ac08c0dc94ba352b7f4819c6d48cebccd60315a930a1d600c2a65148f14ae8
7
- data.tar.gz: d70cb3dbb0868d4311cdb1ff6b710c9bab96c698acdd0d6d4c409ea133dafe119a43bd9d1eee41eea819350e5187aa4338fb4fda3d69613d6a128f9cbd86c7ea
6
+ metadata.gz: c76ab30766f74dda033ce70567b47df54128775dca712737a946a0c5263a7c668f3e039941efda725749070bc93745f7654f62cdccd695004f4dd84852fcb930
7
+ data.tar.gz: 771cc8e824566de385f8d266fe233ea43313dac648bc4d9fbbf8b7e2fe0e1cdabfc5c0633dc09c386a2966e4cccd978dc3e37d38f135574832919641861f29af
@@ -0,0 +1,33 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ push:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby:
15
+ - 3.0
16
+ - 3.1
17
+ - 3.2
18
+ - 3.3
19
+ - ruby-head
20
+ - jruby-9.1
21
+ - jruby-9.2
22
+ - jruby-9.3
23
+ - jruby-head
24
+ - truffleruby-head
25
+
26
+ steps:
27
+ - uses: actions/checkout@v1
28
+ - uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ bundler-cache: true # 'bundle install' and cache
32
+ - name: Test
33
+ run: bundle exec rake
data/Gemfile CHANGED
@@ -2,3 +2,12 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in request_store.gemspec
4
4
  gemspec
5
+
6
+ case Gem::Version.new(RUBY_VERSION.dup)
7
+ when ->(ruby_version) { ruby_version >= Gem::Version.new('2.2.0') }
8
+ gem 'rake', '~> 13'
9
+ when ->(ruby_version) { ruby_version >= Gem::Version.new('2.0.0') }
10
+ gem 'rake', '~> 12.3.3'
11
+ else
12
+ gem 'rake', '~> 11'
13
+ end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RequestStore [![build status](https://travis-ci.org/steveklabnik/request_store.svg?branch=master)](https://travis-ci.org/steveklabnik/request_store) [![Code Climate](https://codeclimate.com/github/steveklabnik/request_store.svg)](https://codeclimate.com/github/steveklabnik/request_store)
1
+ # RequestStore [![CI](https://github.com/steveklabnik/request_store/actions/workflows/ci.yml/badge.svg)](https://github.com/steveklabnik/request_store/actions/workflows/ci.yml) [![Code Climate](https://codeclimate.com/github/steveklabnik/request_store.svg)](https://codeclimate.com/github/steveklabnik/request_store)
2
2
 
3
3
  Ever needed to use a global variable in Rails? Ugh, that's the worst. If you
4
4
  need global state, you've probably reached for `Thread.current`. Like this:
@@ -1,3 +1,3 @@
1
1
  module RequestStore
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
data/lib/request_store.rb CHANGED
@@ -3,28 +3,38 @@ require "request_store/middleware"
3
3
  require "request_store/railtie" if defined?(Rails::Railtie)
4
4
 
5
5
  module RequestStore
6
+ if Fiber.respond_to?(:[])
7
+ def self.scope
8
+ Fiber
9
+ end
10
+ else
11
+ def self.scope
12
+ Thread.current
13
+ end
14
+ end
15
+
6
16
  def self.store
7
- Thread.current[:request_store] ||= {}
17
+ scope[:request_store] ||= {}
8
18
  end
9
19
 
10
20
  def self.store=(store)
11
- Thread.current[:request_store] = store
21
+ scope[:request_store] = store
12
22
  end
13
23
 
14
24
  def self.clear!
15
- Thread.current[:request_store] = {}
25
+ scope[:request_store] = {}
16
26
  end
17
27
 
18
28
  def self.begin!
19
- Thread.current[:request_store_active] = true
29
+ scope[:request_store_active] = true
20
30
  end
21
31
 
22
32
  def self.end!
23
- Thread.current[:request_store_active] = false
33
+ scope[:request_store_active] = false
24
34
  end
25
35
 
26
36
  def self.active?
27
- Thread.current[:request_store_active] || false
37
+ scope[:request_store_active] || false
28
38
  end
29
39
 
30
40
  def self.read(key)
@@ -14,12 +14,11 @@ Gem::Specification.new do |gem|
14
14
  gem.licenses = ["MIT"]
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
18
  gem.require_paths = ["lib"]
20
19
 
21
20
  gem.add_dependency "rack", ">= 1.4"
22
21
 
23
- gem.add_development_dependency "rake", "~> 10.5"
22
+ gem.add_development_dependency "rake"
24
23
  gem.add_development_dependency "minitest", "~> 5.0"
25
24
  end
@@ -63,9 +63,9 @@ class RequestStoreTest < Minitest::Test
63
63
  assert_equal 4, RequestStore.delete(:foo) { 2 + 2 }
64
64
  end
65
65
 
66
- def test_delegates_to_thread
66
+ def test_delegates_to_scope
67
67
  RequestStore.store[:foo] = 1
68
- assert_equal 1, Thread.current[:request_store][:foo]
68
+ assert_equal 1, RequestStore.scope[:request_store][:foo]
69
69
  end
70
70
 
71
71
  def test_active_state
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: request_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Klabnik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-18 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.5'
33
+ version: '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: '10.5'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -59,8 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/ci.yml"
62
63
  - ".gitignore"
63
- - ".travis.yml"
64
64
  - Gemfile
65
65
  - LICENSE.txt
66
66
  - README.md
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
- - 2.2.3
7
- - 2.4.9
8
- - 2.5.7
9
- - 2.6.5
10
- - jruby-18mode
11
- - jruby-19mode
12
- - ruby-head
13
- - jruby-head
14
- - truffleruby-head
15
- matrix:
16
- allow_failures:
17
- - rvm: ruby-head
18
- - rvm: jruby-head