bcms_settings 0.0.3 → 0.0.4
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 → README.markdown} +9 -12
- data/lib/bcms_settings/cms/settings.rb +14 -14
- metadata +6 -6
data/{README → README.markdown}
RENAMED
@@ -101,13 +101,13 @@ To delete values, call the delete method on the settings object:
|
|
101
101
|
=> #<Cms::Settings: bcms_s3 => {"account_id"=>"NEW_ID"}
|
102
102
|
|
103
103
|
Keys can have almost any name, except for these:
|
104
|
-
|
104
|
+
inspect, __send__, delete, instance_eval, __metaclass__, method_missing
|
105
105
|
|
106
106
|
|
107
107
|
### Registering and deleting modules
|
108
108
|
|
109
|
-
It is also possible to register and delete modules manually in addition
|
110
|
-
as an alternative to
|
109
|
+
It is also possible to register and delete modules manually in addition or
|
110
|
+
as an alternative to calling Settings.synchronize.
|
111
111
|
|
112
112
|
To register modules:
|
113
113
|
|
@@ -119,21 +119,18 @@ then you can store, retrieve and delete arbitrary values:
|
|
119
119
|
config.client = "Widgets INC"
|
120
120
|
config.url = "http://example.com"
|
121
121
|
config.sections = %w[A B C]
|
122
|
-
|
123
122
|
config.url
|
124
123
|
=> "http://example.com
|
125
|
-
|
126
124
|
config.delete("url")
|
127
|
-
|
128
125
|
config.url
|
129
126
|
=> nil
|
130
127
|
|
131
|
-
In
|
132
|
-
to store values, so you can request
|
128
|
+
In the background, what 'registering a module' does is create an object where
|
129
|
+
to store values, so you can request storage to the Settings module for
|
133
130
|
whatever porpose you like, povinding that:
|
134
131
|
|
135
|
-
|
136
|
-
|
132
|
+
1. The name you are trying to register is a valid BrowserCMS module
|
133
|
+
name and a valid Ruby method identifier, so this is valid:
|
137
134
|
|
138
135
|
Cms::Settings.register("bcms_my_config")
|
139
136
|
|
@@ -141,8 +138,8 @@ whatever porpose you like, povinding that:
|
|
141
138
|
|
142
139
|
Cms::Settings.register("My Config")
|
143
140
|
|
144
|
-
|
145
|
-
|
141
|
+
2. The name you are trying to register has not been previously registered.
|
142
|
+
Names passed to the register method must be unique.
|
146
143
|
|
147
144
|
|
148
145
|
To delete modules:
|
@@ -39,8 +39,10 @@ module Cms
|
|
39
39
|
# get a configuration object whether they need it or not.
|
40
40
|
|
41
41
|
def synchronize
|
42
|
-
|
43
|
-
|
42
|
+
if CmsModule.table_exists?
|
43
|
+
register_modules(installed_modules - registered_modules)
|
44
|
+
remove_modules(managed_modules - installed_modules)
|
45
|
+
end
|
44
46
|
end
|
45
47
|
|
46
48
|
# Retruns an array of module names the Cms::Settings module knows
|
@@ -176,18 +178,16 @@ module Cms
|
|
176
178
|
end
|
177
179
|
|
178
180
|
def register_modules(module_names, managed = true)
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
"The module #{name} is already registered."
|
190
|
-
end
|
181
|
+
module_names.each do |name|
|
182
|
+
verify_module_name(name)
|
183
|
+
begin
|
184
|
+
CmsModule.create!(:name => name.to_s,
|
185
|
+
:settings => {},
|
186
|
+
:cms_managed => managed)
|
187
|
+
|
188
|
+
rescue ActiveRecord::RecordInvalid
|
189
|
+
raise ModuleConfigurationExists,
|
190
|
+
"The module #{name} is already registered."
|
191
191
|
end
|
192
192
|
end
|
193
193
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- BrowserMedia
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-30 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,7 +42,7 @@ extensions: []
|
|
42
42
|
|
43
43
|
extra_rdoc_files:
|
44
44
|
- LICENSE.txt
|
45
|
-
- README
|
45
|
+
- README.markdown
|
46
46
|
files:
|
47
47
|
- app/controllers/application_controller.rb
|
48
48
|
- app/helpers/application_helper.rb
|
@@ -54,7 +54,7 @@ files:
|
|
54
54
|
- lib/bcms_settings/routes.rb
|
55
55
|
- rails/init.rb
|
56
56
|
- LICENSE.txt
|
57
|
-
- README
|
57
|
+
- README.markdown
|
58
58
|
- test/performance/browsing_test.rb
|
59
59
|
- test/test_helper.rb
|
60
60
|
- test/unit/cms_module_test.rb
|