feature_setting 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/LICENSE +9 -0
- data/README.md +6 -7
- data/feature_setting.gemspec +3 -12
- data/lib/feature_setting/orm/active_record/fs_feature.rb +2 -2
- data/lib/feature_setting/orm/active_record/fs_setting.rb +9 -7
- data/lib/feature_setting/version.rb +1 -1
- data/lib/generators/feature_setting/install/install_generator.rb +0 -2
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18ca75fc887ba02f7803b8702d72c8adc720cf80
|
4
|
+
data.tar.gz: 1c4a9ac3f0697cca4f6784bcd34ab9395f39f94e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5387df7acbec72b6d024fd3b542674276829f751df3f38218c59689ef9a76554b2c97ee7e206432be88aed1ed1324a478caf9c3b2b60a5e0162475d84801d633
|
7
|
+
data.tar.gz: 7becbfd04f2cb502cdd0d1400a09b06e608594d482320b7c50bd5daf0e0aff224d784d8c2426f43147c2e76c2656bb0d502ffd5b0b007a839c2090d170418f2f
|
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Indro De (http://indrode.com)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
**Note: This gem is still under construction!**
|
2
|
-
|
3
1
|
# feature_setting
|
4
2
|
|
5
|
-
[![Code Climate](https://codeclimate.com/github/indrode/feature_setting/badges/gpa.svg)](https://codeclimate.com/github/indrode/feature_setting) [![Test Coverage](https://codeclimate.com/github/indrode/feature_setting/badges/coverage.svg)](https://codeclimate.com/github/indrode/feature_setting/coverage)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/feature_setting.svg)](http://badge.fury.io/rb/feature_setting) [![Code Climate](https://codeclimate.com/github/indrode/feature_setting/badges/gpa.svg)](https://codeclimate.com/github/indrode/feature_setting) [![Test Coverage](https://codeclimate.com/github/indrode/feature_setting/badges/coverage.svg)](https://codeclimate.com/github/indrode/feature_setting/coverage)
|
6
4
|
|
7
5
|
This gem introduces the concept of "features" and "settings" to your Rails app. It provides an easy way to define such features and settings with default values right in your code and will persist them in the database.
|
8
6
|
|
@@ -29,7 +27,7 @@ end
|
|
29
27
|
if Setting.allowed_users.include?(current_user)
|
30
28
|
# to that
|
31
29
|
end
|
32
|
-
|
30
|
+
```
|
33
31
|
|
34
32
|
## Installation
|
35
33
|
|
@@ -106,11 +104,12 @@ end
|
|
106
104
|
You can now do the following:
|
107
105
|
|
108
106
|
```ruby
|
109
|
-
Settings.newsetting # =>
|
110
|
-
Settings.
|
107
|
+
Settings.newsetting # => 500
|
108
|
+
Settings.newsetting = 2000
|
111
109
|
Settings.newsetting # => 1000
|
112
110
|
|
113
|
-
# other ways to set setting values
|
111
|
+
# other ways to set setting values:
|
112
|
+
Settings.set!(newsetting: 1000)
|
114
113
|
Settings.set!(:newsetting, 1000)
|
115
114
|
Settings.set!('newsetting', 1000)
|
116
115
|
```
|
data/feature_setting.gemspec
CHANGED
@@ -6,24 +6,15 @@ require 'feature_setting/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'feature_setting'
|
8
8
|
spec.version = FeatureSetting::VERSION
|
9
|
+
spec.licenses = ['MIT']
|
9
10
|
spec.authors = ['Indro De']
|
10
11
|
spec.email = ['indro.de@gmail.com']
|
11
12
|
|
12
13
|
spec.summary = 'A lightweight feature/setting DSL for Rails applications.'
|
13
|
-
spec.description =
|
14
|
+
spec.description = 'This gem introduces the concept of "features" and "settings" to your Rails app. It provides an easy way to define such features and settings with default values right in your code and will persist them in the database.'
|
14
15
|
spec.homepage = 'https://github.com/indrode/feature_setting'
|
15
16
|
|
16
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
-
# delete this section to allow pushing this gem to any host.
|
18
|
-
# if spec.respond_to?(:metadata)
|
19
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
# else
|
21
|
-
# raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
-
# end
|
23
|
-
|
24
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
# spec.bindir = "exe"
|
26
|
-
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
18
|
spec.require_paths = ['lib']
|
28
19
|
|
29
20
|
spec.add_runtime_dependency 'activesupport', '~> 4.0'
|
@@ -31,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
31
22
|
spec.add_development_dependency 'bundler', '~> 1.9'
|
32
23
|
spec.add_development_dependency 'rake', '~> 10.0'
|
33
24
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
-
spec.add_development_dependency 'sqlite3'
|
25
|
+
spec.add_development_dependency 'sqlite3'
|
35
26
|
spec.add_development_dependency 'byebug', '~> 0'
|
36
27
|
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0'
|
37
28
|
end
|
@@ -50,14 +50,14 @@ module FeatureSetting
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def enable!(key)
|
53
|
-
if features.
|
53
|
+
if features.key?(key.to_sym)
|
54
54
|
record = self.where(key: key, klass: klass).first
|
55
55
|
record.update_attributes(enabled: true)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
def disable!(key)
|
60
|
-
if features.
|
60
|
+
if features.key?(key.to_sym)
|
61
61
|
record = self.where(key: key, klass: klass).first
|
62
62
|
record.update_attributes(enabled: false)
|
63
63
|
end
|
@@ -30,6 +30,10 @@ module FeatureSetting
|
|
30
30
|
record = self.where(key: key, klass: klass).first
|
31
31
|
convert_to_type(record.value, record.value_type)
|
32
32
|
end
|
33
|
+
define_singleton_method("#{key}=") do |value|
|
34
|
+
record = self.where(key: key, klass: klass).first
|
35
|
+
set!(key, value)
|
36
|
+
end
|
33
37
|
end
|
34
38
|
remove_old_settings!
|
35
39
|
end
|
@@ -45,7 +49,7 @@ module FeatureSetting
|
|
45
49
|
|
46
50
|
def set!(key = nil, value = nil, **hash)
|
47
51
|
key = existing_key(key, hash)
|
48
|
-
|
52
|
+
fail 'ERROR: FsSetting key is missing or does not exist.' unless key
|
49
53
|
|
50
54
|
record = self.where(key: key, klass: klass).first
|
51
55
|
new_value = hash.values.first || value
|
@@ -56,12 +60,10 @@ module FeatureSetting
|
|
56
60
|
end
|
57
61
|
|
58
62
|
def existing_key(key = nil, hash = {})
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
nil
|
64
|
-
end
|
63
|
+
settings.key?(hash.keys.first) || settings.key?(key.to_sym)
|
64
|
+
hash.keys.first || key.to_sym
|
65
|
+
rescue
|
66
|
+
nil
|
65
67
|
end
|
66
68
|
|
67
69
|
def defined_settings
|
@@ -2,10 +2,8 @@ require 'rails/generators'
|
|
2
2
|
require 'rails/generators/migration'
|
3
3
|
require 'rails/generators/active_record'
|
4
4
|
|
5
|
-
|
6
5
|
module FeatureSetting
|
7
6
|
module Generators
|
8
|
-
|
9
7
|
class InstallGenerator < Rails::Generators::Base
|
10
8
|
include Rails::Generators::Migration
|
11
9
|
extend ActiveRecord::Generators::Migration
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_setting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Indro De
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -84,14 +84,14 @@ dependencies:
|
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
@@ -134,7 +134,9 @@ files:
|
|
134
134
|
- ".gitignore"
|
135
135
|
- ".rspec"
|
136
136
|
- ".travis.yml"
|
137
|
+
- CHANGELOG.md
|
137
138
|
- Gemfile
|
139
|
+
- LICENSE
|
138
140
|
- README.md
|
139
141
|
- Rakefile
|
140
142
|
- bin/console
|
@@ -147,7 +149,8 @@ files:
|
|
147
149
|
- lib/generators/feature_setting/install/install_generator.rb
|
148
150
|
- lib/generators/feature_setting/install/templates/migrations/create_fs_tables.rb
|
149
151
|
homepage: https://github.com/indrode/feature_setting
|
150
|
-
licenses:
|
152
|
+
licenses:
|
153
|
+
- MIT
|
151
154
|
metadata: {}
|
152
155
|
post_install_message:
|
153
156
|
rdoc_options: []
|