settingify 0.0.5 → 0.1.0
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/README.md +2 -2
- data/lib/settingify/db_syncer.rb +14 -4
- data/lib/settingify/version.rb +1 -1
- data/spec/localized_settingify_spec.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26524c7474e3efeea94a93c959acf238662eb184
|
4
|
+
data.tar.gz: 81bb1e0394729b2d9c462b662d2dba7b3f7c5bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 805f34e8d54668980b5e0f9e54579f7d917496a8c5b2144658830123d1521f2edea7aa7182fb6cf67d3a86ee455ac715f3eb7bddc0a47d142a09b2a14b3bfbd5
|
7
|
+
data.tar.gz: af903099f32d29d3f6adff3f5f355b436801737e19bd9ba7d679990b788aa448c535d1a9804cae69b838b6bf777212805d2b02e7e8e36246aee0b0a437d3b1d4
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ rails g active_admin:resource Settingify::Setting
|
|
16
16
|
|
17
17
|
Add this line to your application's Gemfile:
|
18
18
|
|
19
|
-
gem 'settingify', '0.0
|
19
|
+
gem 'settingify', '0.1.0'
|
20
20
|
|
21
21
|
And then execute:
|
22
22
|
|
@@ -24,7 +24,7 @@ And then execute:
|
|
24
24
|
|
25
25
|
Or install it yourself as:
|
26
26
|
|
27
|
-
$ gem install settingify -v 0.0
|
27
|
+
$ gem install settingify -v 0.1.0
|
28
28
|
|
29
29
|
### Post installation
|
30
30
|
|
data/lib/settingify/db_syncer.rb
CHANGED
@@ -33,10 +33,20 @@ module Settingify
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_record_for(setting)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
values = create_value_parameters(setting.default)
|
37
|
+
Settingify::Setting.create values.merge(key: setting.name)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def create_value_parameters(default)
|
43
|
+
if Settingify.config.localization.active
|
44
|
+
Settingify.config.localization.available_locales.each_with_object({}) do |locale, hash|
|
45
|
+
hash["value_#{locale}"] = default
|
46
|
+
end
|
47
|
+
else
|
48
|
+
{value: default}
|
49
|
+
end
|
40
50
|
end
|
41
51
|
end
|
42
52
|
end
|
data/lib/settingify/version.rb
CHANGED
@@ -8,6 +8,7 @@ describe Settingify do
|
|
8
8
|
context 'localized feature' do
|
9
9
|
before do
|
10
10
|
load 'spec/db/localized_schema.rb'
|
11
|
+
I18n.config.available_locales = [:en, :fr, :nl]
|
11
12
|
Settingify.config do |config|
|
12
13
|
config.localization do |localization|
|
13
14
|
localization.active = true
|
@@ -15,7 +16,7 @@ describe Settingify do
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
Settingify::Repos::Settings.instance.clear!
|
18
|
-
I18n.locale =
|
19
|
+
I18n.locale = 'fr'
|
19
20
|
Settingify::Setting.create(key: :localized, value: :fr_localized)
|
20
21
|
Settingify.prepare_settings do
|
21
22
|
setting :localized, default: :unlocalized
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: settingify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Gernyak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: traco
|
@@ -284,3 +284,4 @@ test_files:
|
|
284
284
|
- spec/lib/settingify_spec.rb
|
285
285
|
- spec/localized_settingify_spec.rb
|
286
286
|
- spec/spec_helper.rb
|
287
|
+
has_rdoc:
|