mournful_settings 0.0.5 → 0.0.6
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.
- data/README.rdoc +16 -2
- data/lib/mournful_settings/setting.rb +2 -2
- data/lib/mournful_settings/version.rb +5 -1
- data/test/dummy/db/test.sqlite3.db +0 -0
- data/test/dummy/test/setting_test.rb +6 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -48,6 +48,20 @@ To use a stored setting, use the 'for' class method:
|
|
48
48
|
|
49
49
|
Setting.for(:pi) --> 3.14159
|
50
50
|
|
51
|
+
In this example, Setting.for(:pi) will return nil if there is no Setting
|
52
|
+
with a name of 'pi' in the database.
|
53
|
+
|
54
|
+
=== Supplying a default
|
55
|
+
|
56
|
+
If you wish an alternative value to be returned if no matching setting has been
|
57
|
+
defined, you can add a default to the for declaration.
|
58
|
+
|
59
|
+
Setting.for(:pi, 3.14)
|
60
|
+
|
61
|
+
This will return 3.14 until a 'pi' setting has been created.
|
62
|
+
|
63
|
+
The
|
64
|
+
|
51
65
|
== Encryption
|
52
66
|
|
53
67
|
By default mournful settings are encrypted. You can choose not to encrypt a
|
@@ -118,7 +132,7 @@ So the process would be:
|
|
118
132
|
|
119
133
|
== Integration with ActiveAdmin
|
120
134
|
|
121
|
-
Mournful settings contains
|
135
|
+
Mournful settings contains an ActiveAdmin register file, that allows settings to
|
122
136
|
be managed from within the parent app's active_admin space. Of course
|
123
137
|
ActiveAdmin needs to be installed and working in the parent rails application,
|
124
138
|
for this to work.
|
@@ -128,6 +142,6 @@ active_admin initializer in your application.
|
|
128
142
|
|
129
143
|
config.load_paths << MournfulSettings.active_admin_load_path
|
130
144
|
|
131
|
-
Alternatively, copy lib/active_admin/admin/setting.rb to
|
145
|
+
Alternatively, copy lib/active_admin/admin/setting.rb to app/admin within
|
132
146
|
the host rails app, and modify it as you desire.
|
133
147
|
|
@@ -1,10 +1,14 @@
|
|
1
1
|
module MournfulSettings
|
2
|
-
VERSION = "0.0.
|
2
|
+
VERSION = "0.0.6"
|
3
3
|
end
|
4
4
|
|
5
5
|
# History
|
6
6
|
# =======
|
7
7
|
#
|
8
|
+
# 0.0.6: Adds default option
|
9
|
+
# --------------------------
|
10
|
+
# Allows alternative to be set, that will be used until setting defined
|
11
|
+
#
|
8
12
|
# 0.0.5: Corrects gem description
|
9
13
|
# -------------------------------
|
10
14
|
# No functional change.
|
Binary file
|
@@ -86,6 +86,11 @@ class SettingTest < Test::Unit::TestCase
|
|
86
86
|
assert_nil(Setting.for(:nothing), "Should return nil when setting doesn't exist")
|
87
87
|
end
|
88
88
|
|
89
|
+
def test_for_with_default_provided
|
90
|
+
default = 'Something else'
|
91
|
+
assert_equal(default, Setting.for(:nothing, default))
|
92
|
+
end
|
93
|
+
|
89
94
|
def test_setting_an_invalid_cipher_config
|
90
95
|
assert_raises RuntimeError do
|
91
96
|
Setting::Cipher.config = 'invalid'
|
@@ -122,7 +127,7 @@ class SettingTest < Test::Unit::TestCase
|
|
122
127
|
assert_equal(key, Setting::Cipher.key)
|
123
128
|
test_encrypted_value
|
124
129
|
end
|
125
|
-
|
130
|
+
|
126
131
|
private
|
127
132
|
def text_setting
|
128
133
|
@text_setting ||= Setting.create(:name => 'text_setting', :value => 'foo', :value_type => 'text', :encrypted => false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mournful_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|