rails-settings-cached 2.4.0 → 2.4.1

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: 603b7101883a17d76bfb33682ce421b7259101bfc7d3b0fea450d02466adcb03
4
- data.tar.gz: '088348b905fba8727569b052468ca194c74fcde740976e0d4cfe6b780063144f'
3
+ metadata.gz: 11dbf6161605ff3aed324a9ac29600d47918cd5fad1b8a5abfadaeddd9636c57
4
+ data.tar.gz: 8056da8c1b7441dd6fc78117013b06c0d67b53bfb06497d1e2343b1417503b95
5
5
  SHA512:
6
- metadata.gz: eeaed942036ec6c70fbd0f8a687000032e87cbef17324eca6329c32e1f7b69b6f38a7d295ec00441ec1fd1601f53c8cbe162df33e0f5d4f518658f6cb3236835
7
- data.tar.gz: 13f87d6cac9234fcf48b50b3e67723aac4977d4a9e8fb71528bf8d12fd29eb27372d9b5705a496f694550ad988dba613f9dc3bf069fa699a910ebd1f4c5b8506
6
+ metadata.gz: 61579ae6068bdd643c4741ac07855c0802220f11be06709910efae5f653dc69db7d7b039cb265bc4229a5121aef90ee9de92d6da700aea87cec33bfb9c4800f3
7
+ data.tar.gz: 2fbd8d62d15ac420abc0ac96ca2aea53eb6d78c9072a1f19fa942f86fd89a8253e829ec827251909dc2cd8f2082e65e890737ba7588d4cf960ebad85fdc76269
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Rails Settings Cached
2
2
 
3
- This a plugin that makes managing a table of
4
- а global key, value pairs easy. Think of it like a global Hash stored in your database,
5
- that uses simple ActiveRecord like methods for manipulation. Keep track of any global
6
- setting that you don't want to hard code into your rails app. You can store any kind
7
- of object. Strings, numbers, arrays, or any object.
3
+ The best solution for store global settings in Rails applications.
4
+
5
+ This gem will managing a table of а global key, value pairs easy. Think of it like a global Hash stored in your database, that uses simple ActiveRecord like methods for manipulation. Keep track of any global setting that you don't want to hard code into your rails app.
6
+
7
+ You can store any kind of object. Strings, numbers, arrays, booleans, or any object.
8
8
 
9
9
  [![Gem Version](https://badge.fury.io/rb/rails-settings-cached.svg)](https://rubygems.org/gems/rails-settings-cached) [![CI Status](https://travis-ci.org/huacnlee/rails-settings-cached.svg)](http://travis-ci.org/huacnlee/rails-settings-cached) [![codecov.io](https://codecov.io/github/huacnlee/rails-settings-cached/coverage.svg?branch=master)](https://codecov.io/github/huacnlee/rails-settings-cached?branch=master)
10
10
 
@@ -53,7 +53,7 @@ class Setting < RailsSettings::Base
53
53
  end
54
54
  ```
55
55
 
56
- You must use `field` method to statement the setting keys, otherwise you can't use it.
56
+ You must use the `field` method to statement the setting keys, otherwise you can't use it.
57
57
 
58
58
  Now just put that migration in the database with:
59
59
 
@@ -152,7 +152,7 @@ Setting.get_field("app_name")
152
152
 
153
153
  ## Use Setting in Rails initializing:
154
154
 
155
- In `version 2.3+` we allows you to use Setting before Rails is initialized.
155
+ In `version 2.3+` you can use Setting before Rails is initialized.
156
156
 
157
157
  For example `config/initializers/devise.rb`
158
158
 
@@ -349,8 +349,11 @@ end
349
349
  - [forem/forem](https://github.com/forem/forem) - 2.x
350
350
  - [siwapp/siwapp](https://github.com/siwapp/siwapp) - 2.x
351
351
  - [aidewoode/black_candy](https://github.com/aidewoode/black_candy) - 2.x
352
- - [thebluedoc/bluedoc](https://github.com/thebluedoc/bluedoc/blob/master/app/models/setting.rb) - 2.x
352
+ - [huacnlee/bluedoc](https://github.com/huacnlee/bluedoc) - 2.x
353
+ - [getzealot/zealot](https://github.com/getzealot/zealot) - 2.x
354
+ - [kaishuu0123/rebacklogs](https://github.com/kaishuu0123/rebacklogs) - 2.x
353
355
  - [tootsuite/mastodon](https://github.com/tootsuite/mastodon) - 0.6.x
354
356
  - [helpyio/helpy](https://github.com/helpyio/helpy) - 0.5.x
357
+ - [daqing/rabel](https://github.com/daqing/rabel) - 0.4.x
355
358
 
356
359
  And more than [1K repositories](https://github.com/huacnlee/rails-settings-cached/network/dependents) used.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "rails-settings/base"
4
- require_relative "rails-settings/request_store"
4
+ require_relative "rails-settings/request_cache"
5
5
  require_relative "rails-settings/railtie"
6
6
  require_relative "rails-settings/version"
7
7
 
@@ -23,7 +23,7 @@ module RailsSettings
23
23
 
24
24
  class << self
25
25
  def clear_cache
26
- RequestStore.reset
26
+ RequestCache.reset
27
27
  Rails.cache.delete(cache_key)
28
28
  end
29
29
 
@@ -160,7 +160,7 @@ module RailsSettings
160
160
  end
161
161
 
162
162
  def _all_settings
163
- RequestStore.settings ||= begin
163
+ RequestCache.settings ||= begin
164
164
  Rails.cache.fetch(cache_key, expires_in: 1.week) do
165
165
  vars = unscoped.select("var, value")
166
166
  result = {}
@@ -0,0 +1,30 @@
1
+ module RailsSettings
2
+ if defined? ActiveSupport::CurrentAttributes
3
+ # For storage all settings in Current, it will reset after per request completed.
4
+ # Base on ActiveSupport::CurrentAttributes
5
+ # https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html
6
+ class RequestCache < ActiveSupport::CurrentAttributes
7
+ attribute :settings
8
+ end
9
+ else
10
+ # https://github.com/steveklabnik/request_store
11
+ # For Rails 5.0
12
+ require "request_store"
13
+
14
+ class RequestCache
15
+ class << self
16
+ def reset
17
+ self.settings = nil
18
+ end
19
+
20
+ def settings
21
+ RequestStore.store[:rails_settings_all_settings]
22
+ end
23
+
24
+ def settings=(val)
25
+ RequestStore.store[:rails_settings_all_settings]
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -3,7 +3,7 @@
3
3
  module RailsSettings
4
4
  class << self
5
5
  def version
6
- "2.4.0"
6
+ "2.4.1"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-settings-cached
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-03 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0
19
+ version: 5.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.0
26
+ version: 5.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: codecov
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,11 +108,11 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: "\n This is improved from rails-settings, added caching.\n Settings
112
- plugin for Rails that makes managing a table of global key,\n value pairs easy.
113
- Think of it like a global Hash stored in you database,\n that uses simple ActiveRecord
114
- like methods for manipulation.\n\n Keep track of any global setting that you dont
115
- want to hard code into your rails app.\n You can store any kind of object. Strings,
111
+ description: "\n The best solution for store global settings in Rails applications.\n\n
112
+ \ This gem will managing a table of а global key, value pairs easy. Think of it
113
+ like a \n global Hash stored in your database, that uses simple ActiveRecord like
114
+ methods for manipulation.\n\n Keep track of any global setting that you dont want
115
+ to hard code into your rails app.\n You can store any kind of object. Strings,
116
116
  numbers, arrays, or any object.\n "
117
117
  email: huacnlee@gmail.com
118
118
  executables: []
@@ -128,7 +128,7 @@ files:
128
128
  - lib/rails-settings-cached.rb
129
129
  - lib/rails-settings/base.rb
130
130
  - lib/rails-settings/railtie.rb
131
- - lib/rails-settings/request_store.rb
131
+ - lib/rails-settings/request_cache.rb
132
132
  - lib/rails-settings/version.rb
133
133
  homepage: https://github.com/huacnlee/rails-settings-cached
134
134
  licenses:
@@ -152,5 +152,5 @@ requirements: []
152
152
  rubygems_version: 3.1.2
153
153
  signing_key:
154
154
  specification_version: 4
155
- summary: Settings plugin for Rails that makes managing a table of global keys.
155
+ summary: The best solution for store global settings in Rails applications.
156
156
  test_files: []
@@ -1,8 +0,0 @@
1
- module RailsSettings
2
- # For storage all settings in Current, it will reset after per request completed.
3
- # Base on ActiveSupport::CurrentAttributes
4
- # https://api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html
5
- class RequestStore < ActiveSupport::CurrentAttributes
6
- attribute :settings
7
- end
8
- end