feature_setting 1.7.0 → 1.7.1

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
  SHA256:
3
- metadata.gz: d88b8c501d738b622e547956bbbc2e44164e375d72fe949a02749a5dbba93207
4
- data.tar.gz: 5ae3b3db98a22c65a7595b4b14015fae8b3b3de9f3c08d506186bb27a2c03657
3
+ metadata.gz: bc9ce0a91fa49c7c49d2e0abf9d15e636220934e0edb0ec6bec6de2e9ca8c9f3
4
+ data.tar.gz: 236b4539436772ff6d041e7b0e4b485debb59ffc7e2a2a0b96aee43a2d56c37a
5
5
  SHA512:
6
- metadata.gz: e97a3af42489cc34a2b4c716b6c36d241eb834156aa0936358cc57b0fb7d387fcfdea6f11d7b01f4e8c7551174d4b37a69800831f5927ae82f0c4f9d58809442
7
- data.tar.gz: 6954b1cb38e3314b9cf0f63181c0e6e100ad0e7ed647fa969e6cd71b67b15326ad60092a9de4159035b5e22068b444559d4b2b21831cfff5a9e54e4cfb9996ea
6
+ metadata.gz: 8a1b7325cfd5dbb39e3ec03d3de42e31733759282e9b952bc0aa2298584bfaeb0243623fd520424756073fde22f5da850ade263777672d95c2824120113dc513
7
+ data.tar.gz: bdbe4980d868e7e0727748c34ddb255b54ba417e02b102b92c0af974be3f96297127509c2e1e77fe720d53e39b623fa9b17085f03d77240cb1fd977ae4767866
data/.rubocop.yml CHANGED
@@ -4,6 +4,8 @@ require:
4
4
 
5
5
  AllCops:
6
6
  TargetRubyVersion: 2.6
7
+ NewCops: enable
8
+
7
9
  Style/FrozenStringLiteralComment:
8
10
  Enabled: false
9
11
  Metrics/BlockLength:
@@ -24,77 +26,3 @@ Metrics/MethodLength:
24
26
  Max: 12
25
27
  Exclude:
26
28
  - 'lib/generators/**/**'
27
- RSpec/FilePath:
28
- Enabled: false
29
- Gemspec/DateAssignment: # (new in 1.10)
30
- Enabled: true
31
- Layout/SpaceBeforeBrackets: # (new in 1.7)
32
- Enabled: true
33
- Lint/AmbiguousAssignment: # (new in 1.7)
34
- Enabled: true
35
- Lint/DeprecatedConstants: # (new in 1.8)
36
- Enabled: true
37
- Lint/DuplicateBranch: # (new in 1.3)
38
- Enabled: true
39
- Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
40
- Enabled: true
41
- Lint/EmptyBlock: # (new in 1.1)
42
- Enabled: true
43
- Lint/EmptyClass: # (new in 1.3)
44
- Enabled: true
45
- Lint/EmptyInPattern: # (new in 1.16)
46
- Enabled: true
47
- Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
48
- Enabled: true
49
- Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
50
- Enabled: true
51
- Lint/NumberedParameterAssignment: # (new in 1.9)
52
- Enabled: true
53
- Lint/OrAssignmentToConstant: # (new in 1.9)
54
- Enabled: true
55
- Lint/RedundantDirGlobSort: # (new in 1.8)
56
- Enabled: true
57
- Lint/SymbolConversion: # (new in 1.9)
58
- Enabled: true
59
- Lint/ToEnumArguments: # (new in 1.1)
60
- Enabled: true
61
- Lint/TripleQuotes: # (new in 1.9)
62
- Enabled: true
63
- Lint/UnexpectedBlockArity: # (new in 1.5)
64
- Enabled: true
65
- Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
66
- Enabled: true
67
- Style/ArgumentsForwarding: # (new in 1.1)
68
- Enabled: true
69
- Style/CollectionCompact: # (new in 1.2)
70
- Enabled: true
71
- Style/DocumentDynamicEvalDefinition: # (new in 1.1)
72
- Enabled: true
73
- Style/EndlessMethod: # (new in 1.8)
74
- Enabled: true
75
- Style/HashConversion: # (new in 1.10)
76
- Enabled: true
77
- Style/HashExcept: # (new in 1.7)
78
- Enabled: true
79
- Style/IfWithBooleanLiteralBranches: # (new in 1.9)
80
- Enabled: true
81
- Style/InPatternThen: # (new in 1.16)
82
- Enabled: true
83
- Style/MultilineInPatternThen: # (new in 1.16)
84
- Enabled: true
85
- Style/NegatedIfElseCondition: # (new in 1.2)
86
- Enabled: true
87
- Style/NilLambda: # (new in 1.3)
88
- Enabled: true
89
- Style/QuotedSymbols: # (new in 1.16)
90
- Enabled: true
91
- Style/RedundantArgument: # (new in 1.4)
92
- Enabled: true
93
- Style/StringChars: # (new in 1.12)
94
- Enabled: true
95
- Style/SwapValues: # (new in 1.1)
96
- Enabled: true
97
- RSpec/IdenticalEqualityAssertion: # (new in 2.4)
98
- Enabled: true
99
- RSpec/Rails/AvoidSetupHook: # (new in 2.4)
100
- Enabled: true
data/README.md CHANGED
@@ -6,7 +6,7 @@ Version](https://badge.fury.io/rb/feature_setting.svg)](https://badge.fury.io/rb
6
6
  Climate](https://codeclimate.com/github/indrode/feature_setting/badges/gpa.svg)](https://codeclimate.com/github/indrode/feature_setting)
7
7
  [![Test
8
8
  Coverage](https://codeclimate.com/github/indrode/feature_setting/badges/coverage.svg)](https://codeclimate.com/github/indrode/feature_setting/coverage)
9
- [![security](https://hakiri.io/github/indrode/feature_setting/master.svg)](https://hakiri.io/github/indrode/feature_setting/master) [![Build Status](https://travis-ci.org/indrode/feature_setting.svg?branch=master)](https://travis-ci.org/indrode/feature_setting)
9
+ [![security](https://hakiri.io/github/indrode/feature_setting/master.svg)](https://hakiri.io/github/indrode/feature_setting/master)
10
10
 
11
11
  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.
12
12
 
@@ -53,7 +53,6 @@ This generates a migration file. To run this migration:
53
53
 
54
54
  The next step is to define your Feature and/or Setting classes.
55
55
 
56
-
57
56
  ## Usage
58
57
 
59
58
  ### Features
@@ -90,7 +89,6 @@ Features.disable_newfeature!
90
89
 
91
90
  Default values for features are defined in your class and current values are persisted in the database.
92
91
 
93
-
94
92
  ### Settings
95
93
 
96
94
  To create a new Setting class, inherit a class from `FeatureSetting::Setting` (if using a gem version prior to `1.2.0` use `FeatureSetting::FsSetting`). Then define your settings in a hash called `SETTINGS` and call `init_settings!`. The following example shows the setup and some possible definitions.
@@ -102,7 +100,7 @@ class Settings < FeatureSetting::Setting
102
100
  setting_two: 'some string',
103
101
  setting_three: %w(one two three),
104
102
  setting_four: ENV['SETTING_FOUR'],
105
- setting_five: { key1: 'value1', key2: 'value2' }
103
+ setting_five: { key1: 'value1', key2: 'value2' },
106
104
  setting_six: true
107
105
  }
108
106
 
@@ -187,7 +185,6 @@ Notes:
187
185
  - Contributions without tests won't be accepted.
188
186
  - Please don't update the gem version.
189
187
 
190
-
191
188
  ## License
192
189
 
193
190
  The MIT License (MIT)
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_runtime_dependency 'activerecord', '>= 4.0'
25
- spec.add_runtime_dependency 'activesupport', '>= 4.0'
24
+ spec.add_runtime_dependency 'activerecord', '>= 5.2.4.5'
25
+ spec.add_runtime_dependency 'activesupport', '>= 5.2.4.3'
26
26
  spec.add_runtime_dependency 'hashie', '>= 3.4.3'
27
27
  spec.add_development_dependency 'bundler', '>= 1.9'
28
28
  spec.add_development_dependency 'byebug'
@@ -54,8 +54,7 @@ module FeatureSetting
54
54
  def define_checker_method(key, &block)
55
55
  unless block_given?
56
56
  block = proc do
57
- record = find_by key: key, klass: klass
58
- record ? record.enabled : false
57
+ find_by(key: key, klass: klass)&.enabled ? true : false
59
58
  end
60
59
  end
61
60
  define_singleton_method("#{key}_enabled?") { block.call }
@@ -90,14 +89,14 @@ module FeatureSetting
90
89
  def enable!(key)
91
90
  return unless features.key?(key.to_sym)
92
91
 
93
- record = find_by key: key, klass: klass
92
+ record = find_by(key: key, klass: klass)
94
93
  record.update(enabled: true)
95
94
  end
96
95
 
97
96
  def disable!(key)
98
97
  return unless features.key?(key.to_sym)
99
98
 
100
- record = find_by key: key, klass: klass
99
+ record = find_by(key: key, klass: klass)
101
100
  record.update(enabled: false)
102
101
  end
103
102
 
@@ -49,7 +49,7 @@ module FeatureSetting
49
49
  def cache_settings!
50
50
  settings.each do |key, value|
51
51
  create_setting(key, value)
52
- record = find_by key: key, klass: klass
52
+ record = find_by(key: key, klass: klass)
53
53
  value = ConvertValue.convert_to_type(record.value, record.value_type)
54
54
  define_getter_method(key) { value }
55
55
  end
@@ -58,7 +58,7 @@ module FeatureSetting
58
58
  def define_getter_method(key, &block)
59
59
  unless block_given?
60
60
  block = proc do
61
- record = find_by key: key, klass: klass
61
+ record = find_by(key: key, klass: klass)
62
62
  ConvertValue.convert_to_type(record.value, record.value_type)
63
63
  end
64
64
  end
@@ -84,7 +84,7 @@ module FeatureSetting
84
84
  def set!(key = nil, value = nil)
85
85
  raise SettingNotExistsError unless defined_keys.include?(key.to_s)
86
86
 
87
- record = find_by key: key.to_s, klass: klass
87
+ record = find_by(key: key.to_s, klass: klass)
88
88
  old_value = ConvertValue.convert_to_type(record.value, record.value_type)
89
89
 
90
90
  if record.value_type == 'Hash'
@@ -1,3 +1,3 @@
1
1
  module FeatureSetting
2
- VERSION = '1.7.0'.freeze
2
+ VERSION = '1.7.1'.freeze
3
3
  end
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.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indro De
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: 5.2.4.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: 5.2.4.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: 5.2.4.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: 5.2.4.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hashie
43
43
  requirement: !ruby/object:Gem::Requirement