settingify 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -2
- data/lib/settingify/builders/group.rb +37 -0
- data/lib/settingify/dsl.rb +31 -0
- data/lib/settingify/errors.rb +3 -0
- data/lib/settingify/group.rb +25 -0
- data/lib/settingify/reader.rb +4 -2
- data/lib/settingify/repo_item.rb +4 -0
- data/lib/settingify/repos/settings.rb +29 -0
- data/lib/settingify/setting.rb +8 -0
- data/lib/settingify/settings_preparable.rb +10 -0
- data/lib/settingify/version.rb +1 -1
- data/lib/settingify.rb +22 -9
- data/settingify.gemspec +3 -2
- data/spec/lib/settingify/db_syncer_spec.rb +3 -3
- data/spec/lib/settingify/group_spec.rb +20 -0
- data/spec/lib/settingify/reader_spec.rb +8 -1
- data/spec/lib/settingify/repo_item_spec.rb +7 -0
- data/spec/lib/settingify/{repo_spec.rb → repos/settings_spec.rb} +4 -4
- data/spec/lib/settingify/setting_builder_spec.rb +23 -11
- data/spec/lib/settingify/setting_spec.rb +17 -0
- data/spec/lib/settingify_spec.rb +31 -2
- metadata +36 -12
- data/lib/settingify/repo.rb +0 -27
- data/lib/settingify/setting_builder.rb +0 -20
- data/lib/settingify/settings_list.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94d92a3f44c051e69e85ffaec7d69028ec7ed1f8
|
4
|
+
data.tar.gz: 0ef9c8d16d8c5fc549fc30ac0867db0b4f6f3339
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59aae6e64a0de758d4c6b9ce48793ee44ff16bbea0e79fe422c68d310c540f2517ba5202ec331410178d90d2e91bab3e7f6123134e07ba412d1f0fd2482f2a31
|
7
|
+
data.tar.gz: 266e0dde7325e20dc718b49107048e86e3cca96201a51d38c8613d7c410bd88e74273777e7766bc765b362e829555d56e003a6face19b9b0fa4eb83b46a5407f
|
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.0.4'
|
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.0.4
|
28
28
|
|
29
29
|
### Post installation
|
30
30
|
|
@@ -96,6 +96,43 @@ the DB manually or run built-in rake task:
|
|
96
96
|
bundle exec rake settingify:sync
|
97
97
|
```
|
98
98
|
|
99
|
+
### Identifiing settings
|
100
|
+
|
101
|
+
For some reason, e.g. in admin panel, you need to list all available
|
102
|
+
settings. Also you want to provide humanized title and description for
|
103
|
+
each setting separately. So for this from now `#title` and `#description`
|
104
|
+
on `Settingify::Setting` exists. They provide localized values which can
|
105
|
+
be defined using following key structure:
|
106
|
+
|
107
|
+
```
|
108
|
+
settingify.settings.{KEY}.{title/description}
|
109
|
+
```
|
110
|
+
|
111
|
+
### Grouping settings
|
112
|
+
|
113
|
+
From _v0.0.4_ you can grouping settings. This feature does not affected
|
114
|
+
on API for reading setting, so you must to define uniq setting names
|
115
|
+
even in different groups. Grouping is a quite simple:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
Settingify.prepare_settings do
|
119
|
+
group :amazon_ses do
|
120
|
+
setting :amazon_ses_client_id
|
121
|
+
end
|
122
|
+
end
|
123
|
+
```
|
124
|
+
|
125
|
+
By calling `Settingify.groups` you can get all defined groups. For each
|
126
|
+
group you can get it's `#title` and defined `#settings` in concrete
|
127
|
+
group. Title is localized and key has the following structure:
|
128
|
+
|
129
|
+
```
|
130
|
+
settingify.groups.{KEY}.title
|
131
|
+
```
|
132
|
+
|
133
|
+
Grouping was coming mainly for to be able to more clear render settings
|
134
|
+
in admin panel but also with keeping in mind about next enhancements.
|
135
|
+
|
99
136
|
## Contributing
|
100
137
|
|
101
138
|
1. Fork it ( https://github.com/alterego-labs/settingify/fork )
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Settingify
|
2
|
+
module Builders
|
3
|
+
class Group < Struct.new(:name, :block)
|
4
|
+
include SettingsPreparable
|
5
|
+
|
6
|
+
def self.call(*opts, &block)
|
7
|
+
new(*opts).call(&block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(&block)
|
11
|
+
self.prepare_settings(&block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def setting(name, type: String, default: '')
|
15
|
+
attach_to_group(name)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def attach_to_group(setting_key)
|
22
|
+
group = fetch_group
|
23
|
+
group.add setting_key
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_group
|
27
|
+
Settingify.groups.find { |g| g.key == self.name } || define_new_group
|
28
|
+
end
|
29
|
+
|
30
|
+
def define_new_group
|
31
|
+
group = Settingify::Group.new(name)
|
32
|
+
Settingify.groups << group
|
33
|
+
group
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Settingify
|
2
|
+
module DSL
|
3
|
+
def setting(name, type: String, default: '')
|
4
|
+
setting_item = build_setting_item(name, type, default)
|
5
|
+
register_setting setting_item
|
6
|
+
define_setting setting_item
|
7
|
+
end
|
8
|
+
|
9
|
+
def group(name, &block)
|
10
|
+
Builders::Group.call(name, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def build_setting_item(name, type, default)
|
16
|
+
RepoItem.new(name, type, default)
|
17
|
+
end
|
18
|
+
|
19
|
+
def define_setting(setting_item)
|
20
|
+
Settingify.singleton_class.instance_eval do
|
21
|
+
define_method setting_item.name do
|
22
|
+
Reader.new(setting_item).call
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def register_setting(setting_item)
|
28
|
+
Settingify::Repos::Settings.instance.add setting_item
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Settingify
|
2
|
+
class Group
|
3
|
+
attr_reader :key, :setting_keys
|
4
|
+
|
5
|
+
def initialize(key)
|
6
|
+
@setting_keys = []
|
7
|
+
@key = key
|
8
|
+
end
|
9
|
+
|
10
|
+
def add(setting_key)
|
11
|
+
@setting_keys = @setting_keys
|
12
|
+
.insert(-1, setting_key.to_sym)
|
13
|
+
.uniq
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def title
|
18
|
+
I18n.t("settingify.groups.#{key}.title", self.key.to_s.humanize)
|
19
|
+
end
|
20
|
+
|
21
|
+
def settings
|
22
|
+
::Settingify::Setting.where(key: setting_keys)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/settingify/reader.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Settingify
|
2
|
-
class Reader < Struct.new(:
|
2
|
+
class Reader < Struct.new(:setting_item)
|
3
|
+
delegate :name, :type, :default, to: :setting_item
|
4
|
+
|
3
5
|
def call
|
4
6
|
return default unless table_exists?
|
5
7
|
Caster.new(type, db_value).call
|
@@ -12,7 +14,7 @@ module Settingify
|
|
12
14
|
end
|
13
15
|
|
14
16
|
def db_setting
|
15
|
-
DbReader.new(
|
17
|
+
DbReader.new(name, default).call
|
16
18
|
end
|
17
19
|
|
18
20
|
def db_value
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Settingify
|
4
|
+
module Repos
|
5
|
+
class Settings
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
def list
|
9
|
+
@settings_list ||= []
|
10
|
+
@settings_list
|
11
|
+
end
|
12
|
+
|
13
|
+
def add(item)
|
14
|
+
list << item
|
15
|
+
end
|
16
|
+
|
17
|
+
def clear!
|
18
|
+
list.each(&method(:undef_method_for))
|
19
|
+
list.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def undef_method_for(item)
|
25
|
+
Settingify.singleton_class.send :remove_method, item.name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/settingify/setting.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
module Settingify
|
2
2
|
class Setting < ActiveRecord::Base
|
3
3
|
self.table_name_prefix = 'settingify_'
|
4
|
+
|
5
|
+
def title
|
6
|
+
I18n.t("settingify.settings.#{self.key}.title", self.key.to_s.humanize)
|
7
|
+
end
|
8
|
+
|
9
|
+
def description
|
10
|
+
I18n.t("settingify.settings.#{self.key}.description", "Description for #{self.key} setting...")
|
11
|
+
end
|
4
12
|
end
|
5
13
|
end
|
data/lib/settingify/version.rb
CHANGED
data/lib/settingify.rb
CHANGED
@@ -5,33 +5,46 @@ require 'active_support/core_ext/module'
|
|
5
5
|
require "settingify/version"
|
6
6
|
|
7
7
|
require 'settingify/railtie' if defined?(Rails)
|
8
|
+
require 'settingify/errors'
|
8
9
|
|
9
10
|
module Settingify
|
10
11
|
extend ActiveSupport::Autoload
|
11
12
|
|
12
13
|
autoload :ContractExt
|
13
14
|
autoload :Setting
|
14
|
-
autoload :
|
15
|
-
autoload :SettingsList
|
15
|
+
autoload :DSL
|
16
16
|
autoload :Reader
|
17
17
|
autoload :Caster
|
18
18
|
autoload :DbReader
|
19
19
|
autoload :ActiveRecordHelpers
|
20
20
|
autoload :Constants
|
21
21
|
autoload :Repo
|
22
|
+
autoload :RepoItem
|
22
23
|
autoload :DbSyncer
|
24
|
+
autoload :SettingsPreparable
|
25
|
+
autoload :Group
|
23
26
|
|
24
|
-
|
25
|
-
|
27
|
+
module Builders
|
28
|
+
extend ActiveSupport::Autoload
|
26
29
|
|
27
|
-
|
30
|
+
autoload :Group
|
31
|
+
end
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
module Repos
|
34
|
+
extend ActiveSupport::Autoload
|
35
|
+
|
36
|
+
autoload :Settings
|
32
37
|
end
|
33
38
|
|
39
|
+
extend SettingsPreparable
|
40
|
+
|
41
|
+
include Constants
|
42
|
+
|
34
43
|
def self.registered_settings
|
35
|
-
|
44
|
+
Repos::Settings.instance.list
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.groups
|
48
|
+
@_groups ||= []
|
36
49
|
end
|
37
50
|
end
|
data/settingify.gemspec
CHANGED
@@ -25,8 +25,9 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.6"
|
27
27
|
spec.add_development_dependency "rake"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3.
|
29
|
-
spec.add_development_dependency "rspec-its", "1.0
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.4.0"
|
29
|
+
spec.add_development_dependency "rspec-its", "1.2.0"
|
30
30
|
spec.add_development_dependency "pry-nav", "0.2.3"
|
31
31
|
spec.add_development_dependency 'sqlite3'
|
32
|
+
spec.add_development_dependency 'json', '1.8.3'
|
32
33
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module SomeBuilder
|
4
|
-
extend Settingify::
|
4
|
+
extend Settingify::DSL
|
5
5
|
end
|
6
6
|
|
7
7
|
describe Settingify::DbSyncer do
|
@@ -9,12 +9,12 @@ describe Settingify::DbSyncer do
|
|
9
9
|
|
10
10
|
before do
|
11
11
|
Settingify::Setting.delete_all
|
12
|
-
Settingify::
|
12
|
+
Settingify::Repos::Settings.instance.clear!
|
13
13
|
SomeBuilder.setting :setting1, default: 'value1'
|
14
14
|
end
|
15
15
|
|
16
16
|
after do
|
17
|
-
Settingify::
|
17
|
+
Settingify::Repos::Settings.instance.clear!
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when setting does not exists in db' do
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Settingify::Group do
|
4
|
+
subject(:group) { described_class.new(:test_group) }
|
5
|
+
|
6
|
+
describe '#title' do
|
7
|
+
it 'provides localized title' do
|
8
|
+
expect(I18n).to receive(:t)
|
9
|
+
group.title
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add' do
|
14
|
+
it 'adds setting by key into group' do
|
15
|
+
group.add :grouped_setting
|
16
|
+
setting_keys = group.instance_variable_get("@setting_keys")
|
17
|
+
expect(setting_keys).to include(:grouped_setting)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,13 +1,20 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Settingify::Reader do
|
4
|
+
subject(:reader) { described_class.new(setting_item) }
|
5
|
+
|
6
|
+
let(:setting_item) { Settingify::RepoItem.new(key, type, default) }
|
7
|
+
|
4
8
|
let(:key) { 'reader_setting' }
|
5
9
|
let(:type) { String }
|
6
10
|
let(:default) { 'reader_value' }
|
7
11
|
|
8
|
-
subject(:reader) { described_class.new(key, type, default) }
|
9
12
|
|
10
13
|
context 'when table does not exists' do
|
14
|
+
before do
|
15
|
+
expect(reader).to receive(:table_exists?).and_return false
|
16
|
+
end
|
17
|
+
|
11
18
|
it 'returns default value' do
|
12
19
|
expect(reader.call).to eq default
|
13
20
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module SomeBuilder
|
4
|
-
extend Settingify::
|
4
|
+
extend Settingify::DSL
|
5
5
|
end
|
6
6
|
|
7
|
-
describe Settingify::
|
7
|
+
describe Settingify::Repos::Settings do
|
8
8
|
subject(:repo) { described_class.send :new }
|
9
9
|
|
10
10
|
describe '#list' do
|
@@ -33,7 +33,7 @@ describe Settingify::Repo do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe '#clear' do
|
36
|
+
describe '#clear!' do
|
37
37
|
before do
|
38
38
|
SomeBuilder.setting(:for_clear_setting)
|
39
39
|
end
|
@@ -41,7 +41,7 @@ describe Settingify::Repo do
|
|
41
41
|
it 'removes all settings' do
|
42
42
|
expect(Settingify).to respond_to :for_clear_setting
|
43
43
|
expect(Settingify.registered_settings).to_not be_empty
|
44
|
-
Settingify::
|
44
|
+
Settingify::Repos::Settings.instance.clear!
|
45
45
|
expect(Settingify).to_not respond_to :for_clear_setting
|
46
46
|
expect(Settingify.registered_settings).to be_empty
|
47
47
|
end
|
@@ -1,21 +1,33 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module SomeBuilder
|
4
|
-
extend Settingify::
|
4
|
+
extend Settingify::DSL
|
5
5
|
end
|
6
6
|
|
7
|
-
describe Settingify::
|
8
|
-
describe '
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
describe Settingify::DSL do
|
8
|
+
describe '#setting' do
|
9
|
+
describe 'defining settings' do
|
10
|
+
it 'successfully' do
|
11
|
+
SomeBuilder.setting(:some_setting)
|
12
|
+
expect(Settingify.some_setting).to eq ''
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
context 'when default is Integer' do
|
16
|
+
it 'returns integer value' do
|
17
|
+
SomeBuilder.setting :some_int_value, type: :integer, default: 12
|
18
|
+
expect(Settingify.some_int_value).to eq 12
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
23
|
+
|
24
|
+
describe '#group' do
|
25
|
+
let(:block) { ->{ } }
|
26
|
+
|
27
|
+
it 'calls group builder properly' do
|
28
|
+
expect(Settingify::Builders::Group).to receive(:call).with(:another_group)
|
29
|
+
|
30
|
+
SomeBuilder.group :another_group, &block
|
31
|
+
end
|
32
|
+
end
|
21
33
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Settingify::Setting do
|
4
|
+
subject(:setting) { described_class.new(key: :cool_setting) }
|
5
|
+
|
6
|
+
describe '#title' do
|
7
|
+
it 'returns setting title' do
|
8
|
+
expect(setting.title).to_not be_blank
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#description' do
|
13
|
+
it 'returns setting description' do
|
14
|
+
expect(setting.description).to_not be_blank
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/lib/settingify_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Settingify do
|
|
6
6
|
it 'raises exception' do
|
7
7
|
expect{
|
8
8
|
Settingify.prepare_settings
|
9
|
-
}.to
|
9
|
+
}.to raise_error(Settingify::PrepareSettingsWithoutBlockError)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -22,8 +22,37 @@ describe Settingify do
|
|
22
22
|
|
23
23
|
describe '.registered_settings' do
|
24
24
|
it 'calls list on repo' do
|
25
|
-
expect(Settingify::
|
25
|
+
expect(Settingify::Repos::Settings).to receive_message_chain(:instance, :list)
|
26
26
|
Settingify.registered_settings
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
context 'real testing' do
|
31
|
+
before(:each) do
|
32
|
+
Settingify::Repos::Settings.instance.clear!
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'grouped settings' do
|
36
|
+
before(:each) do
|
37
|
+
Settingify.prepare_settings do
|
38
|
+
setting :ungrouped_setting
|
39
|
+
|
40
|
+
group :group1 do
|
41
|
+
setting :grouped_setting, default: :grouped_value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'defines grouped setting as well as ungrouped one' do
|
47
|
+
expect(Settingify).to respond_to(:ungrouped_setting)
|
48
|
+
expect(Settingify).to respond_to(:grouped_setting)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'defines new group' do
|
52
|
+
expect(Settingify.groups.count).to eq 1
|
53
|
+
group = Settingify.groups.first
|
54
|
+
expect(group.key).to eq :group1
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
29
58
|
end
|
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.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Gernyak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -100,28 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.
|
103
|
+
version: 3.4.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 3.
|
110
|
+
version: 3.4.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec-its
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.0
|
117
|
+
version: 1.2.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.0
|
124
|
+
version: 1.2.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: pry-nav
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: json
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.8.3
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.8.3
|
153
167
|
description: System for managing global settings trough database
|
154
168
|
email:
|
155
169
|
- sergeg1990@gmail.com
|
@@ -167,25 +181,32 @@ files:
|
|
167
181
|
- lib/generators/settingify/install/templates/settingify.rb
|
168
182
|
- lib/settingify.rb
|
169
183
|
- lib/settingify/active_record_helpers.rb
|
184
|
+
- lib/settingify/builders/group.rb
|
170
185
|
- lib/settingify/caster.rb
|
171
186
|
- lib/settingify/constants.rb
|
172
187
|
- lib/settingify/contract_ext.rb
|
173
188
|
- lib/settingify/db_reader.rb
|
174
189
|
- lib/settingify/db_syncer.rb
|
190
|
+
- lib/settingify/dsl.rb
|
191
|
+
- lib/settingify/errors.rb
|
192
|
+
- lib/settingify/group.rb
|
175
193
|
- lib/settingify/railtie.rb
|
176
194
|
- lib/settingify/reader.rb
|
177
|
-
- lib/settingify/
|
195
|
+
- lib/settingify/repo_item.rb
|
196
|
+
- lib/settingify/repos/settings.rb
|
178
197
|
- lib/settingify/setting.rb
|
179
|
-
- lib/settingify/
|
180
|
-
- lib/settingify/settings_list.rb
|
198
|
+
- lib/settingify/settings_preparable.rb
|
181
199
|
- lib/settingify/tasks/settingify.rake
|
182
200
|
- lib/settingify/version.rb
|
183
201
|
- settingify.gemspec
|
184
202
|
- spec/db/schema.rb
|
185
203
|
- spec/lib/settingify/db_syncer_spec.rb
|
204
|
+
- spec/lib/settingify/group_spec.rb
|
186
205
|
- spec/lib/settingify/reader_spec.rb
|
187
|
-
- spec/lib/settingify/
|
206
|
+
- spec/lib/settingify/repo_item_spec.rb
|
207
|
+
- spec/lib/settingify/repos/settings_spec.rb
|
188
208
|
- spec/lib/settingify/setting_builder_spec.rb
|
209
|
+
- spec/lib/settingify/setting_spec.rb
|
189
210
|
- spec/lib/settingify_spec.rb
|
190
211
|
- spec/spec_helper.rb
|
191
212
|
homepage: https://github.com/alterego-labs/settingify
|
@@ -208,15 +229,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
229
|
version: '0'
|
209
230
|
requirements: []
|
210
231
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.4.
|
232
|
+
rubygems_version: 2.4.8
|
212
233
|
signing_key:
|
213
234
|
specification_version: 4
|
214
235
|
summary: Global setting system for Rails
|
215
236
|
test_files:
|
216
237
|
- spec/db/schema.rb
|
217
238
|
- spec/lib/settingify/db_syncer_spec.rb
|
239
|
+
- spec/lib/settingify/group_spec.rb
|
218
240
|
- spec/lib/settingify/reader_spec.rb
|
219
|
-
- spec/lib/settingify/
|
241
|
+
- spec/lib/settingify/repo_item_spec.rb
|
242
|
+
- spec/lib/settingify/repos/settings_spec.rb
|
220
243
|
- spec/lib/settingify/setting_builder_spec.rb
|
244
|
+
- spec/lib/settingify/setting_spec.rb
|
221
245
|
- spec/lib/settingify_spec.rb
|
222
246
|
- spec/spec_helper.rb
|
data/lib/settingify/repo.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
|
-
module Settingify
|
4
|
-
class Repo
|
5
|
-
include Singleton
|
6
|
-
|
7
|
-
def list
|
8
|
-
@settings_list ||= []
|
9
|
-
@settings_list
|
10
|
-
end
|
11
|
-
|
12
|
-
def add(item)
|
13
|
-
list << item
|
14
|
-
end
|
15
|
-
|
16
|
-
def clear!
|
17
|
-
list.each(&method(:undef_method_for))
|
18
|
-
list.clear
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def undef_method_for(item)
|
24
|
-
Settingify::SettingsList.send :remove_method, item.name
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Settingify
|
2
|
-
module SettingBuilder
|
3
|
-
def setting(name, type: String, default: '')
|
4
|
-
register_setting name, type, default
|
5
|
-
define_setting name, type, default
|
6
|
-
end
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def define_setting(name, type, default)
|
11
|
-
SettingsList.send :define_method, name do
|
12
|
-
Reader.new(name, type, default).call
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def register_setting(name, type, default)
|
17
|
-
Settingify::Repo.instance.add OpenStruct.new(name: name, type: type, default: default)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|