setting_accessors 0.0.8 → 0.0.9
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/.codeclimate.yml +66 -0
- data/lib/setting_accessors/integration.rb +7 -2
- data/lib/setting_accessors/version.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/test/models/user_test.rb +19 -0
- 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: ff68f0a6d47ec46945e83aa4c4f625bec4e7c115
|
4
|
+
data.tar.gz: b3d12cf74aac005bf9d0e0f46e4b9b4402127701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 399a03eabae5d7b475b0ac0119cec650ad37f6c266d53d86c9d90cbb63431e8b32987f9c5fe8a1ec4b255f5b83df876603beeb6fb178c52bb5b1ae2d9130aea0
|
7
|
+
data.tar.gz: aca92f047b34247a2f9b6bcbc1478f36529e6b31e6837758749a99aa81088216a90883ff977c167681618eaf5079acdaf1fb2fcce96dcbcb23092c1600dbc940
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
---
|
2
|
+
engines:
|
3
|
+
rubocop:
|
4
|
+
enabled: true
|
5
|
+
eslint:
|
6
|
+
enabled: true
|
7
|
+
csslint:
|
8
|
+
enabled: true
|
9
|
+
ratings:
|
10
|
+
paths:
|
11
|
+
- "**.rb"
|
12
|
+
- "**.js"
|
13
|
+
- "**.jsx"
|
14
|
+
- "**.css"
|
15
|
+
exclude_paths:
|
16
|
+
- test/**/*
|
17
|
+
# This is a sample .codeclimate.yml configured for Engine analysis on Code
|
18
|
+
# Climate Platform. For an overview of the Code Climate Platform, see here:
|
19
|
+
# http://docs.codeclimate.com/article/300-the-codeclimate-platform
|
20
|
+
|
21
|
+
# Under the engines key, you can configure which engines will analyze your repo.
|
22
|
+
# Each key is an engine name. For each value, you need to specify enabled: true
|
23
|
+
# to enable the engine as well as any other engines-specific configuration.
|
24
|
+
|
25
|
+
# For more details, see here:
|
26
|
+
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
|
27
|
+
|
28
|
+
# For a list of all available engines, see here:
|
29
|
+
# http://docs.codeclimate.com/article/296-engines-available-engines
|
30
|
+
|
31
|
+
engines:
|
32
|
+
# to turn on an engine, add it here and set enabled to `true`
|
33
|
+
# to turn off an engine, set enabled to `false` or remove it
|
34
|
+
rubocop:
|
35
|
+
enabled: true
|
36
|
+
golint:
|
37
|
+
enabled: true
|
38
|
+
gofmt:
|
39
|
+
enabled: true
|
40
|
+
eslint:
|
41
|
+
enabled: true
|
42
|
+
csslint:
|
43
|
+
enabled: true
|
44
|
+
|
45
|
+
# Engines can analyze files and report issues on them, but you can separately
|
46
|
+
# decide which files will receive ratings based on those issues. This is
|
47
|
+
# specified by path patterns under the ratings key.
|
48
|
+
|
49
|
+
# For more details see here:
|
50
|
+
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
|
51
|
+
|
52
|
+
# Note: If the ratings key is not specified, this will result in a 0.0 GPA on your dashboard.
|
53
|
+
|
54
|
+
# ratings:
|
55
|
+
# paths:
|
56
|
+
# - app/**
|
57
|
+
# - lib/**
|
58
|
+
# - "**.rb"
|
59
|
+
# - "**.go"
|
60
|
+
|
61
|
+
# You can globally exclude files from being analyzed by any engine using the
|
62
|
+
# exclude_paths key.
|
63
|
+
|
64
|
+
#exclude_paths:
|
65
|
+
#- spec/**/*
|
66
|
+
#- vendor/**/*
|
@@ -43,20 +43,25 @@ module SettingAccessors::Integration
|
|
43
43
|
|
44
44
|
SettingAccessors::Internal.set_class_setting(self, setting_name, options)
|
45
45
|
|
46
|
+
setting_type = SettingAccessors::Internal.setting_value_type(setting_name, self.new).to_sym
|
47
|
+
|
46
48
|
#Create a virtual column in the models column hash.
|
47
49
|
#This is currently not absolutely necessary, but will become important once
|
48
50
|
#Time etc. are supported. Otherwise, Rails won't be able to e.g. automatically
|
49
51
|
#create multi-param fields in forms.
|
50
|
-
self.columns_hash[setting_name.to_s] = OpenStruct.new(type:
|
52
|
+
self.columns_hash[setting_name.to_s] = OpenStruct.new(type: setting_type)
|
51
53
|
|
52
54
|
#Add the setting's name to the list of setting_accessors for this class
|
53
55
|
SettingAccessors::Internal.add_setting_accessor_name(self, setting_name)
|
54
56
|
|
55
|
-
#Getter
|
57
|
+
# Getter
|
56
58
|
define_method(setting_name) do
|
57
59
|
settings.get_with_fallback(setting_name, fallback)
|
58
60
|
end
|
59
61
|
|
62
|
+
# Getter alias for boolean settings
|
63
|
+
alias_method "#{setting_name}?", setting_name if setting_type == :boolean
|
64
|
+
|
60
65
|
# Setter
|
61
66
|
define_method("#{setting_name}=") do |new_value|
|
62
67
|
settings[setting_name] = new_value
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -18,4 +18,23 @@ class UserTest < ActiveSupport::TestCase
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
context 'Boolean getter methods' do
|
23
|
+
setup do
|
24
|
+
@user = User.new(:a_string => 'test', :a_number => 42, :a_boolean => false)
|
25
|
+
end
|
26
|
+
|
27
|
+
should 'be created for boolean settings' do
|
28
|
+
assert @user.respond_to?(:a_boolean?), '?-getter is not defined for boolean settings'
|
29
|
+
end
|
30
|
+
|
31
|
+
should 'return the same value as the original getter' do
|
32
|
+
assert_equal @user.a_boolean, @user.a_boolean?
|
33
|
+
end
|
34
|
+
|
35
|
+
should 'not be created for non-boolean settings' do
|
36
|
+
assert !@user.respond_to?(:a_number?)
|
37
|
+
assert !@user.respond_to?(:a_string?)
|
38
|
+
end
|
39
|
+
end
|
21
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setting_accessors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Exner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,6 +117,7 @@ executables: []
|
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
|
+
- ".codeclimate.yml"
|
120
121
|
- ".gitignore"
|
121
122
|
- ".ruby-gemset"
|
122
123
|
- ".ruby-version"
|