settingify 0.0.5 → 0.1.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: 78917b39693aa3208f0b77624d23c7d516fb05f4
4
- data.tar.gz: 61fc063e16226665cac720deec8892c47c5c773b
3
+ metadata.gz: 26524c7474e3efeea94a93c959acf238662eb184
4
+ data.tar.gz: 81bb1e0394729b2d9c462b662d2dba7b3f7c5bf1
5
5
  SHA512:
6
- metadata.gz: 483dd18811eaa3a63c23bc641a2e01c9619afbecfb62ceb94bd7e3d07054163af91fb33219ea289b890c6f2ca0560ee34ce5016261b2f066f6e984264354362d
7
- data.tar.gz: 58f61a3f792544c114b4adf814c282ea570aa2498f615366bcf14f72751ef6ee489f1e5345e1686964cc924aa7d699e41c174783991b85935e00be6828d0aa27
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.5'
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.5
27
+ $ gem install settingify -v 0.1.0
28
28
 
29
29
  ### Post installation
30
30
 
@@ -33,10 +33,20 @@ module Settingify
33
33
  end
34
34
 
35
35
  def add_record_for(setting)
36
- Settingify::Setting.create(
37
- key: setting.name,
38
- value: setting.default
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
@@ -1,3 +1,3 @@
1
1
  module Settingify
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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 = :fr
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.5
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-01-16 00:00:00.000000000 Z
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: