ruby-settings-cached 0.1 → 0.1.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
  SHA1:
3
- metadata.gz: ba4e9ee304a2b3dad3de28b7991da2385eb5f3e9
4
- data.tar.gz: 034bf0a2d72024d4ed6762ae83a753bb27ec9c52
3
+ metadata.gz: 44b8a94e6e94cec323aba916059713daa49020e3
4
+ data.tar.gz: ad4402274c659dfc06c1bccf5f563cb98479e1f5
5
5
  SHA512:
6
- metadata.gz: 5047728194298915cb178c2a93c7e1bb3d81375a905b152f8399cb87476d2458eb06e50d721850f92888b344d90dda492a508b2e6f66f211d0e4f03bd1e05194
7
- data.tar.gz: 125508ee57f87528a0c3a3c49be8f0b049c1656983f62b6d2985a448a15d96c58ce02bb1dbfcb404970a9c84b2ce7919f470d0ca974f44725c167ee547d13e50
6
+ metadata.gz: b3ff2bc6bf2e4fb9b93c683b71934ac3427de8d724a7d6b1b7735a2308eb2b83b9e1e8b980675ea1e5ea9b91335b5221647a099df6ab2142574c16a7df8e2def
7
+ data.tar.gz: 25f7a64b1181b9d7767684314d126e98eaaf385abb0b302e39f4942a98767e0a8c6cf64038aaaccbb4897a25a9ea7010ae4278632adadac43a20569169a53d56
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Settings Gem
2
2
 
3
- This is improved from [rails-settings](https://github.com/ledermann/rails-settings),
4
- added caching for all settings. Settings is a plugin that makes managing a table of
3
+ This is improved from [rails-settings-cached](https://github.com/huacnlee/rails-settings-cached),
4
+ remove rails dependency. Settings is a plugin that makes managing a table of
5
5
  global key, value pairs easy. Think of it like a global Hash stored in your database,
6
6
  that uses simple ActiveRecord like methods for manipulation. Keep track of any global
7
7
  setting that you dont want to hard code into your rails app. You can store any kind
@@ -9,7 +9,7 @@ of object. Strings, numbers, arrays, or any object.
9
9
 
10
10
  ## Status
11
11
 
12
- - [![Gem Version](https://badge.fury.io/rb/rails-settings-cached.png)](https://rubygems.org/gems/rails-settings-cached)
12
+ - [![Gem Version](https://badge.fury.io/rb/ruby-settings-cached.svg)](https://rubygems.org/gems/ruby-settings-cached)
13
13
  - [![CI Status](https://travis-ci.org/RobotJiang/ruby-settings-cached.svg)](https://travis-ci.org/RobotJiang/ruby-settings-cached)
14
14
 
15
15
  ## Setup
@@ -35,6 +35,12 @@ Now just put that migration in the database with:
35
35
  rake db:migrate
36
36
  ```
37
37
 
38
+ ```config
39
+ RubySettings.configure do |config|
40
+ # or memcached store, redis store, if you are using rails, the cache store is Rails.cache default, you need not to config it.
41
+ config.cache_store = ActiveSupport::Cache::MemoryStore.new
42
+ end
43
+ ```
38
44
  ## Usage
39
45
 
40
46
  The syntax is easy. First, lets create some settings to keep track of:
@@ -19,6 +19,9 @@ module RubySettings
19
19
  end
20
20
 
21
21
  class << self
22
+
23
+ include RubySettings::ConfigurationHelpers
24
+
22
25
  def cache_prefix(&block)
23
26
  @cache_prefix = block
24
27
  end
@@ -31,7 +34,7 @@ module RubySettings
31
34
  end
32
35
 
33
36
  def [](var_name)
34
- value = RubySettings.config.cache_store.fetch(cache_key(var_name, @object)) do
37
+ value = cache_store.fetch(cache_key(var_name, @object)) do
35
38
  super(var_name)
36
39
  end
37
40
 
@@ -22,7 +22,7 @@ module RubySettings
22
22
  extend ActiveSupport::Concern
23
23
 
24
24
  def cache_store
25
- @cache_store ||= (RubySettings.config.cache_store || ActiveSupport::Cache::MemoryStore.new)
25
+ @cache_store ||= (RubySettings.config.cache_store || (defined?(Rails) ? Rails.cache : ActiveSupport::Cache::MemoryStore.new))
26
26
  end
27
27
 
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-settings-cached
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Squeegy