ez-settings 0.1.2 → 0.2.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be3bd03f40194cdc8bd570214d5121880903ef6b
|
4
|
+
data.tar.gz: d5b04f355d81a0e989e7193913aa35903c52b884
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25c0825d1ef0d9f52751b5ecef718351f0c57ad2ba5522e949eba9d9e44f4651f865c656aa5a9530f02a7ca7a23e28b27ee89dd7efddfd96ec3f63b0dcbfbd63
|
7
|
+
data.tar.gz: 37f1727dc7ad0f7eac6505b91f66ee7ed31d3f3ae7425fbfc932ba77b68deae84c7d145e61fb26b8548b4d3ee9921ebd7e413e4b117a93b5642bf0f660295bd1
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Ez::Settings
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/ez-settings.svg)](https://badge.fury.io/rb/ez-settings)
|
3
4
|
[![Build Status](https://travis-ci.org/ez-engines/ez-settings.svg?branch=master)](https://travis-ci.org/ez-engines/ez-settings)
|
4
5
|
|
5
6
|
**Ez Settings** (read as "easy settings") - one of the [ez-engines](https://github.com/ez-engines) collection that helps easily add settings interface to your [Rails](http://rubyonrails.org/) application.
|
@@ -75,8 +76,10 @@ end
|
|
75
76
|
|
76
77
|
# After defining settings interface groups/keys you need to configure it:
|
77
78
|
app.configure do |config|
|
78
|
-
# Backend adapter to store all settings
|
79
|
+
# Backend adapter to store all settings
|
79
80
|
config.backend = Ez::Settings::Backend::FileSystem.new(Rails.root.join('config', 'settings.yml'))
|
81
|
+
# Redis is also supported:
|
82
|
+
# config.backend = Ez::Settings::Backend::Redis.new('config')
|
80
83
|
|
81
84
|
# Default path for redirect in controller
|
82
85
|
config.default_path = '/admin/settings'
|
@@ -103,7 +106,6 @@ app.configure do |config|
|
|
103
106
|
# group_page_form_boolean_wrapper: 'ez-settings-group-form-boolean-wrapper',
|
104
107
|
# group_page_form_select_wrapper: 'ez-settings-group-form-select-wrapper',
|
105
108
|
# group_page_actions_wrapper: 'ez-settings-group-actions-wrapper',
|
106
|
-
# group_page_actions_wrapper: 'ez-settings-group-actions-wrapper',
|
107
109
|
# group_page_actions_save_button: 'ez-settings-group-actions-save-btn',
|
108
110
|
# group_page_actions_cancel_link: 'ez-settings-group-actions-cancel-link'
|
109
111
|
# }
|
@@ -62,7 +62,6 @@ module Ez::Settings
|
|
62
62
|
group_page_form_boolean_wrapper: 'ez-settings-group-form-boolean-wrapper',
|
63
63
|
group_page_form_select_wrapper: 'ez-settings-group-form-select-wrapper',
|
64
64
|
group_page_actions_wrapper: 'ez-settings-group-actions-wrapper',
|
65
|
-
group_page_actions_wrapper: 'ez-settings-group-actions-wrapper',
|
66
65
|
group_page_actions_save_button: 'ez-settings-group-actions-save-btn',
|
67
66
|
group_page_actions_cancel_link: 'ez-settings-group-actions-cancel-link',
|
68
67
|
}.merge(interface.config.custom_css_map)
|
@@ -13,8 +13,8 @@ module Ez::Settings
|
|
13
13
|
collection: model.collection,
|
14
14
|
include_blank: model.default.present?,
|
15
15
|
required: model.required?,
|
16
|
-
checked_value:
|
17
|
-
unchecked_value:
|
16
|
+
checked_value: true.to_s,
|
17
|
+
unchecked_value: false.to_s
|
18
18
|
}.merge(model.options)
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'redis'
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
4
|
+
|
5
|
+
module Ez::Settings
|
6
|
+
module Backend
|
7
|
+
class Redis
|
8
|
+
PREFIX = 'ez:settings'
|
9
|
+
|
10
|
+
def initialize(namespace)
|
11
|
+
@namespace = namespace
|
12
|
+
end
|
13
|
+
|
14
|
+
def read
|
15
|
+
value = client.get(key)
|
16
|
+
value.nil? ? {} : JSON.parse(value).deep_symbolize_keys
|
17
|
+
end
|
18
|
+
|
19
|
+
def write(data)
|
20
|
+
new_data = read.merge(data)
|
21
|
+
client.set(key, JSON.generate(new_data))
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :namespace
|
27
|
+
|
28
|
+
def key
|
29
|
+
@key ||= "#{PREFIX}:#{namespace}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def client
|
33
|
+
@client ||= ::Redis.current
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/ez/settings/version.rb
CHANGED
@@ -38,8 +38,10 @@ end
|
|
38
38
|
|
39
39
|
# After defining settings interface groups/keys you need to configure it:
|
40
40
|
app.configure do |config|
|
41
|
-
# Backend adapter to store all settings
|
41
|
+
# Backend adapter to store all settings
|
42
42
|
config.backend = Ez::Settings::Backend::FileSystem.new(Rails.root.join('config', 'settings.yml'))
|
43
|
+
# Redis is also supported:
|
44
|
+
# config.backend = Ez::Settings::Backend::Redis.new('config')
|
43
45
|
|
44
46
|
# Default path for redirect in controller
|
45
47
|
config.default_path = '/admin/settings'
|
@@ -66,7 +68,6 @@ app.configure do |config|
|
|
66
68
|
# group_page_form_boolean_wrapper: 'ez-settings-group-form-boolean-wrapper',
|
67
69
|
# group_page_form_select_wrapper: 'ez-settings-group-form-select-wrapper',
|
68
70
|
# group_page_actions_wrapper: 'ez-settings-group-actions-wrapper',
|
69
|
-
# group_page_actions_wrapper: 'ez-settings-group-actions-wrapper',
|
70
71
|
# group_page_actions_save_button: 'ez-settings-group-actions-save-btn',
|
71
72
|
# group_page_actions_cancel_link: 'ez-settings-group-actions-cancel-link'
|
72
73
|
# }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ez-settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volodya Sveredyuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ez-core
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.0.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: redis
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: simple_form
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +220,20 @@ dependencies:
|
|
206
220
|
- - ">="
|
207
221
|
- !ruby/object:Gem::Version
|
208
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: fakeredis
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
209
237
|
description: Easy settings engine for Rails app.
|
210
238
|
email:
|
211
239
|
- sveredyuk@gmail.com
|
@@ -236,6 +264,7 @@ files:
|
|
236
264
|
- lib/ez/settings.rb
|
237
265
|
- lib/ez/settings/accessors.rb
|
238
266
|
- lib/ez/settings/backend/file_system.rb
|
267
|
+
- lib/ez/settings/backend/redis.rb
|
239
268
|
- lib/ez/settings/config.rb
|
240
269
|
- lib/ez/settings/engine.rb
|
241
270
|
- lib/ez/settings/interface.rb
|