active_settings 0.0.1
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 +15 -0
- data/lib/active_settings.rb +10 -0
- data/lib/active_settings/config.rb +287 -0
- data/lib/active_settings/config/definition.rb +150 -0
- data/lib/active_settings/engine.rb +5 -0
- data/lib/active_settings/version.rb +3 -0
- data/lib/generators/active_settings/install/install_generator.rb +23 -0
- data/lib/generators/active_settings/install/templates/active_settings.rb +17 -0
- data/lib/generators/active_settings/install/templates/migration.rb +16 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWQ0NTJiMmViYWU4ZWFmNDRkMDJhYWQzZjQ1YTNmZTNmZDhjMjI3NA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjhiZTMzYTQ4NzIwYmNlYjJiNzYzOGI0YzJhODM3OWVhM2U5M2FkZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Njc3YTE3OTZhNmQ4NjRlN2I5ZTk0MjU3MThjYWQ3OGU4YzcyYzU0MjE3YjZk
|
10
|
+
OWY1NjhkMDcxMDg0YTM0ZjVhZTY0YmQwOGYzYTY2MzNiZjRmOTFkYTBhNGU5
|
11
|
+
Mjg4ZGU0YjEwOWVhYWJmZjVkZGExNGE4MjcxYTJlOGFiYjliNGQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
N2U2MTM2OWQ4NTlhNzM1NTQwMjU0NjQzZWYzNzlmMWYzNWQxYTVmMzY5Mjkx
|
14
|
+
MmM4Y2UyZDkyMTc1MzNkZjFhOWRjYzgxMjkwMDk3ODllODRjODc2NmE4MmRk
|
15
|
+
NWExYjAxMTNjZWU4Mzg3OWYwYzRlNDM3OGVhODdlNWVhMzViZjc=
|
@@ -0,0 +1,287 @@
|
|
1
|
+
module ActiveSettings
|
2
|
+
|
3
|
+
class << self
|
4
|
+
def config_definitions
|
5
|
+
@config_definitions ||= {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def config_definitions=(definitions)
|
9
|
+
@config_definitions = definitions
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Config < ActiveRecord::Base
|
14
|
+
#
|
15
|
+
# The ActiveSettings.detail model class is stored in the database but emulates a hash
|
16
|
+
# with simple bracket methods that allow you to get and set values like so:
|
17
|
+
#
|
18
|
+
# ActiveSettings.detail['setting.name'] = 'value'
|
19
|
+
# ActiveSettings.detail['setting.name'] #=> "value"
|
20
|
+
#
|
21
|
+
# Config entries can be used freely as general-purpose global variables unless a definition
|
22
|
+
# has been given for that key, in which case restrictions and defaults may apply. The restrictions
|
23
|
+
# can take the form of validations, requirements, permissions or permitted options. They are
|
24
|
+
# declared by calling ActiveSettings::Config#define:
|
25
|
+
#
|
26
|
+
# # setting must be either 'foo', 'bar' or 'blank'
|
27
|
+
# define('admin.name', :select_from => ['foo', 'bar'])
|
28
|
+
#
|
29
|
+
# # setting is (and must be) chosen from the names of currently available layouts
|
30
|
+
# define('shop.layout', :select_from => lambda { Layout.all.map{|l| [l.name,l.id]} }, :allow_blank => false)
|
31
|
+
#
|
32
|
+
# # setting cannot be changed at runtime
|
33
|
+
# define('setting.important', :default => "something", :allow_change => false)
|
34
|
+
#
|
35
|
+
# Which almost always happens in a block like this:
|
36
|
+
#
|
37
|
+
# ActiveSettings.detail.configure do |config|
|
38
|
+
# config.namespace('user', :allow_change => true) do |user|
|
39
|
+
# user.define 'allow_password_reset?', :default => true
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# and usually in a config/active_settings.rb file in the application directory.
|
44
|
+
#
|
45
|
+
# admin.title :: the title of the admin system
|
46
|
+
# admin.subtitle :: the subtitle of the admin system
|
47
|
+
# defaults.page.parts :: a comma separated list of default page parts
|
48
|
+
# defaults.page.status :: a string representation of the default page status
|
49
|
+
# defaults.page.filter :: the default filter to use on new page parts
|
50
|
+
# defaults.page.fields :: a comma separated list of the default page fields
|
51
|
+
# defaults.snippet.filter :: the default filter to use on new snippets
|
52
|
+
# dev.host :: the hostname where draft pages are viewable
|
53
|
+
# local.timezone :: the timezone name (`rake -D time` for full list)
|
54
|
+
# used to correct displayed times
|
55
|
+
# page.edit.published_date? :: when true, shows the datetime selector
|
56
|
+
# for published date on the page edit screen
|
57
|
+
#
|
58
|
+
#
|
59
|
+
|
60
|
+
self.table_name = 'active_settings'
|
61
|
+
after_save :update_cache
|
62
|
+
attr_reader :definition
|
63
|
+
|
64
|
+
class ConfigError < RuntimeError; end
|
65
|
+
|
66
|
+
class << self
|
67
|
+
|
68
|
+
# Requesting a config item:
|
69
|
+
#
|
70
|
+
# key = ActiveSettings.detail['key']
|
71
|
+
def [](key)
|
72
|
+
if table_exists?
|
73
|
+
unless ActiveSettings::Config.cache_exists?
|
74
|
+
ActiveSettings::Config.initialize_cache
|
75
|
+
end
|
76
|
+
Rails.cache.read('ActiveSettings::Config')[key]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# The usual way to use a config item:
|
81
|
+
#
|
82
|
+
# ActiveSettings.detail['key'] = value
|
83
|
+
#
|
84
|
+
def []=(key, value)
|
85
|
+
if table_exists?
|
86
|
+
setting = find_or_initialize_by_key(key)
|
87
|
+
setting.value = value
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_hash
|
92
|
+
Hash[ *find(:all).map { |pair| [pair.key, pair.value] }.flatten ]
|
93
|
+
end
|
94
|
+
|
95
|
+
def initialize_cache
|
96
|
+
Rails.cache.write('ActiveSettings::Config', ActiveSettings::Config.to_hash)
|
97
|
+
Rails.cache.silence!
|
98
|
+
end
|
99
|
+
|
100
|
+
def cache_clear!
|
101
|
+
initialize_cache
|
102
|
+
end
|
103
|
+
|
104
|
+
def cache_exists?
|
105
|
+
true if Rails.cache.read('ActiveSettings::Config')
|
106
|
+
end
|
107
|
+
|
108
|
+
def configure(&block)
|
109
|
+
yield self
|
110
|
+
end
|
111
|
+
|
112
|
+
# A convenient drying method for specifying a prefix and options common to several settings.
|
113
|
+
#
|
114
|
+
# ActiveSettings.detail.configure do |config|
|
115
|
+
# config.namespace('secret', :allow_display => false) do |secret|
|
116
|
+
# secret.define('identity', :default => 'batman') # defines 'secret.identity'
|
117
|
+
# secret.define('lair', :default => 'batcave') # defines 'secret.lair'
|
118
|
+
# secret.define('longing', :default => 'vindication') # defines 'secret.longing'
|
119
|
+
# end
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
def namespace(prefix, options = {}, &block)
|
123
|
+
prefix = [options[:prefix], prefix].join('.') if options[:prefix]
|
124
|
+
with_options(options.merge(:prefix => prefix), &block)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Declares a setting definition that will constrain and support the use of a particular config entry.
|
128
|
+
#
|
129
|
+
# define('setting.key', options)
|
130
|
+
#
|
131
|
+
# Can take several options:
|
132
|
+
# * :default is the value that will be placed in the database if none has been set already
|
133
|
+
# * :type can be :string, :boolean or :integer. Note that all settings whose key ends in ? are considered boolean.
|
134
|
+
# * :select_from should be a list or hash suitable for passing to options_for_select, or a block that will return such a list at runtime
|
135
|
+
# * :validate_with should be a block that will receive a value and return true or false. Validations are also implied by type or select_from.
|
136
|
+
# * :allow_blank should be false if the config item must not be blank or nil
|
137
|
+
# * :allow_change should be false if the config item can only be set, not changed. Add a default to specify an unchanging config entry.
|
138
|
+
# * :allow_display should be false if the config item should not be showable in radius tags
|
139
|
+
#
|
140
|
+
# From the main ActiveSettings config/initializers/active_settings.rb:
|
141
|
+
#
|
142
|
+
# ActiveSettings.detail.configure do |config|
|
143
|
+
# config.define 'defaults.locale', :select_from => lambda {Layout.all.map{|l| [l.name, l.d]}}, :allow_blank => true
|
144
|
+
# config.define 'defaults.page.parts', :default => "Body,Extended"
|
145
|
+
# ...
|
146
|
+
# end
|
147
|
+
#
|
148
|
+
# It's also possible to reuse a definition by passing it to define:
|
149
|
+
#
|
150
|
+
# choose_layout = ActiveSettings::Config::Definition.new(:select_from => lambda {Layout.all.map{|l| [l.name, l.d]}})
|
151
|
+
# define "my.layout", choose_layout
|
152
|
+
# define "your.layout", choose_layout
|
153
|
+
#
|
154
|
+
# but at the moment that's only done in testing.
|
155
|
+
#
|
156
|
+
def define(key, options={})
|
157
|
+
called_from = caller.grep(/\/initializers\//).first
|
158
|
+
if options.is_a? ActiveSettings::Config::Definition
|
159
|
+
definition = options
|
160
|
+
else
|
161
|
+
key = [options[:prefix], key].join('.') if options[:prefix]
|
162
|
+
end
|
163
|
+
|
164
|
+
raise LoadError, %{
|
165
|
+
Config definition error: '#{key}' is defined twice:
|
166
|
+
1. #{called_from}
|
167
|
+
2. #{definitions[key].definer}
|
168
|
+
} unless definitions[key].nil? || definitions[key].empty?
|
169
|
+
|
170
|
+
definition ||= ActiveSettings::Config::Definition.new(options.merge(:definer => called_from))
|
171
|
+
definitions[key] = definition
|
172
|
+
|
173
|
+
if self[key].nil? && !definition.default.nil?
|
174
|
+
begin
|
175
|
+
self[key] = definition.default
|
176
|
+
rescue ActiveRecord::RecordInvalid
|
177
|
+
raise LoadError, "Default configuration invalid: value '#{definition.default}' is not allowed for '#{key}'"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def definitions
|
183
|
+
ActiveSettings.config_definitions
|
184
|
+
end
|
185
|
+
|
186
|
+
def definition_for(key)
|
187
|
+
definitions[key] ||= ActiveSettings::Config::Definition.new(:empty => true)
|
188
|
+
end
|
189
|
+
|
190
|
+
def clear_definitions!
|
191
|
+
ActiveSettings.config_definitions = {}
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
# The usual way to use a config item:
|
197
|
+
#
|
198
|
+
# ActiveSettings.detail['key'] = value
|
199
|
+
#
|
200
|
+
# is equivalent to this:
|
201
|
+
#
|
202
|
+
# ActiveSettings::Config.find_or_create_by_key('key').value = value
|
203
|
+
#
|
204
|
+
# Calling value= also applies any validations and restrictions that are found in the associated definition.
|
205
|
+
# so this will raise a ConfigError if you try to change a protected config entry or a RecordInvalid if you
|
206
|
+
# set a value that is not among those permitted.
|
207
|
+
#
|
208
|
+
def value=(param)
|
209
|
+
newvalue = param.to_s
|
210
|
+
if newvalue != self[:value]
|
211
|
+
raise ConfigError, "#{self.key} cannot be changed" unless settable? || self[:value].blank?
|
212
|
+
if boolean?
|
213
|
+
self[:value] = (newvalue == '1' || newvalue == 'true') ? 'true' : 'false'
|
214
|
+
else
|
215
|
+
self[:value] = newvalue
|
216
|
+
end
|
217
|
+
self.save!
|
218
|
+
end
|
219
|
+
self[:value]
|
220
|
+
end
|
221
|
+
|
222
|
+
# Requesting a config item:
|
223
|
+
#
|
224
|
+
# key = ActiveSettings.detail['key']
|
225
|
+
#
|
226
|
+
# is equivalent to this:
|
227
|
+
#
|
228
|
+
# key = ActiveSettings::Config.find_or_create_by_key('key').value
|
229
|
+
#
|
230
|
+
# If the config item is boolean the response will be true or false. For items with :type => :integer it will be an integer,
|
231
|
+
# for everything else a string.
|
232
|
+
#
|
233
|
+
def value
|
234
|
+
if boolean?
|
235
|
+
checked?
|
236
|
+
else
|
237
|
+
self[:value]
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# Returns the definition associated with this config item. If none has been declared this will be an empty definition
|
242
|
+
# that does not restrict use.
|
243
|
+
#
|
244
|
+
def definition
|
245
|
+
@definition ||= self.class.definition_for(self.key)
|
246
|
+
end
|
247
|
+
|
248
|
+
# Returns true if the item key ends with '?' or the definition specifies :type => :boolean.
|
249
|
+
#
|
250
|
+
def boolean?
|
251
|
+
definition.boolean? || self.key.ends_with?('?')
|
252
|
+
end
|
253
|
+
|
254
|
+
# Returns true if the item is boolean and true.
|
255
|
+
#
|
256
|
+
def checked?
|
257
|
+
return nil if self[:value].nil?
|
258
|
+
boolean? && self[:value] == 'true'
|
259
|
+
end
|
260
|
+
|
261
|
+
# Returns true if the item defintion includes a :select_from parameter that limits the range of permissible options.
|
262
|
+
#
|
263
|
+
def selector?
|
264
|
+
definition.selector?
|
265
|
+
end
|
266
|
+
|
267
|
+
# Returns a name corresponding to the current setting value, if the setting definition includes a select_from parameter.
|
268
|
+
#
|
269
|
+
def selected_value
|
270
|
+
definition.selected(value)
|
271
|
+
end
|
272
|
+
|
273
|
+
def update_cache
|
274
|
+
ActiveSettings::Config.initialize_cache
|
275
|
+
end
|
276
|
+
|
277
|
+
delegate :default, :type, :allow_blank?, :hidden?, :visible?, :settable?, :selection, :label, :notes, :units, :to => :definition
|
278
|
+
|
279
|
+
def validate
|
280
|
+
definition.validate(self)
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
require 'active_settings/config/definition' unless defined?(ActiveSettings::Config::Definition)
|
@@ -0,0 +1,150 @@
|
|
1
|
+
module ActiveSettings
|
2
|
+
class Config
|
3
|
+
class Definition
|
4
|
+
|
5
|
+
attr_reader :empty, :default, :type, :label, :notes, :validate_with,
|
6
|
+
:select_from, :allow_blank, :allow_display,
|
7
|
+
:allow_change, :units, :definer
|
8
|
+
|
9
|
+
# Configuration 'definitions' are metadata held in memory that add restriction and description to individual config entries.
|
10
|
+
#
|
11
|
+
# By default ActiveSettings' configuration machinery is open and ad-hoc: config items are just globally-accessible variables.
|
12
|
+
# They're created when first mentioned and then available in all parts of the application. The definition mechanism is a way
|
13
|
+
# to place limits on that behavior. It allows you to protect a config entry, to specify the values it can take and to
|
14
|
+
# validate it when it changes. In the next update it will also allow you to declare that
|
15
|
+
# a config item is global or site-specific.
|
16
|
+
#
|
17
|
+
# The actual defining is done by ActiveSettings::Config#define and usually in a block like this:
|
18
|
+
#
|
19
|
+
# ActiveSettings::Config.configure do |config|
|
20
|
+
# config.namespace('users', :allow_change => true) do |users|
|
21
|
+
# users.define 'allow_password_reset?', :label => 'Allow password reset?'
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# See the method documentation in ActiveSettings::Config for options and conventions.
|
26
|
+
#
|
27
|
+
def initialize(options={})
|
28
|
+
[:empty, :default, :type, :label, :notes, :validate_with, :select_from, :allow_blank,
|
29
|
+
:allow_change, :allow_display, :units, :definer].each do |attribute|
|
30
|
+
instance_variable_set "@#{attribute}".to_sym, options[attribute]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns true if the definition included an :empty flag, which should only be the case for the blank, unrestricting
|
35
|
+
# definitions created when an undefined config item is set or got.
|
36
|
+
#
|
37
|
+
def empty?
|
38
|
+
!!empty
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns true if the definition included a :type => :boolean parameter. Config entries that end in '?' are automatically
|
42
|
+
# considered boolean, whether a type is declared or not. config.boolean? may therefore differ from config.definition.boolean?
|
43
|
+
#
|
44
|
+
def boolean?
|
45
|
+
type == :boolean
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns true if the definition included a :select_from parameter (either as list or proc).
|
49
|
+
#
|
50
|
+
def selector?
|
51
|
+
!select_from.blank?
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns true if the definition included a :type => :integer parameter
|
55
|
+
def integer?
|
56
|
+
type == :integer
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns true if the definition included a :type => :date parameter
|
60
|
+
def date?
|
61
|
+
type == :date
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns the list of possible values for this config entry in a form suitable for passing to options_for_select.
|
65
|
+
# if :select_from is a proc it is called first with no arguments and its return value passed through.
|
66
|
+
#
|
67
|
+
def selection
|
68
|
+
if selector?
|
69
|
+
choices = select_from
|
70
|
+
choices = choices.call if choices.respond_to? :call
|
71
|
+
choices = normalize_selection(choices)
|
72
|
+
choices.unshift ['","'] if allow_blank?
|
73
|
+
choices
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# in definitions we accept anything that options_for_select would normally take
|
78
|
+
# here we standardises on an options array-of-arrays so that it's easier to validate input
|
79
|
+
#
|
80
|
+
def normalize_selection(choices)
|
81
|
+
choices = choices.to_a if Hash === choices
|
82
|
+
choices = choices.collect{|c| (c.is_a? Array) ? c : [c,c]}
|
83
|
+
end
|
84
|
+
|
85
|
+
# If the config item is a selector and :select_from specifies [name, value] pairs (as hash or array),
|
86
|
+
# this will return the name corresponding to the currently selected value.
|
87
|
+
#
|
88
|
+
def selected(value)
|
89
|
+
if value && selector? && pair = selection.find{|s| s.last == value}
|
90
|
+
pair.first
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Checks the supplied value against the validation rules for this definition.
|
95
|
+
# There are several ways in which validations might be defined or implied:
|
96
|
+
# * if :validate_with specifies a block, the setting object is passed to the block
|
97
|
+
# * if :type is :integer, we test that the supplied string resolves to a valid integer
|
98
|
+
# * if the config item is a selector we test that its value is one of the permitted options
|
99
|
+
# * if :allow_blank has been set to false, we test that the value is not blank
|
100
|
+
#
|
101
|
+
def validate(setting)
|
102
|
+
if allow_blank?
|
103
|
+
return if setting.value.blank?
|
104
|
+
else
|
105
|
+
setting.errors.add :value, :blank if setting.value.blank?
|
106
|
+
end
|
107
|
+
if validate_with.is_a? Proc
|
108
|
+
validate_with.call(setting)
|
109
|
+
end
|
110
|
+
if selector?
|
111
|
+
setting.errors.add :value, :not_permitted unless selectable?(setting.value)
|
112
|
+
end
|
113
|
+
if integer?
|
114
|
+
Integer(setting.value) rescue setting.errors.add :value, :not_a_number
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Returns true if the value is one of the permitted selections. Not case-sensitive.
|
119
|
+
def selectable?(value)
|
120
|
+
return true unless selector?
|
121
|
+
selection.map(&:last).map(&:downcase).include?(value.downcase)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns true unless :allow_blank has been explicitly set to false. Defaults to true.
|
125
|
+
# A config item that does not allow_blank must be set or it will not be valid.
|
126
|
+
def allow_blank?
|
127
|
+
true unless allow_blank == false
|
128
|
+
end
|
129
|
+
|
130
|
+
# Returns true unless :allow_change has been explicitly set to false. Defaults to true.
|
131
|
+
# A config item that is not settable cannot be changed in the running application.
|
132
|
+
def settable?
|
133
|
+
true unless allow_change == false
|
134
|
+
end
|
135
|
+
|
136
|
+
# Returns true unless :allow_change has been explicitly set to false. Defaults to true.
|
137
|
+
# A config item that is not visible cannot be displayed in a view.
|
138
|
+
def visible?
|
139
|
+
true unless allow_display == false
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns true if :allow_display has been explicitly set to false. Defaults to true.
|
143
|
+
def hidden?
|
144
|
+
true if allow_display == false
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'rails/generators/active_record/migration'
|
4
|
+
|
5
|
+
module ActiveSettings
|
6
|
+
module Generators
|
7
|
+
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
extend ActiveRecord::Generators::Migration
|
10
|
+
|
11
|
+
source_root File.expand_path("../templates", __FILE__)
|
12
|
+
|
13
|
+
def copy_initializer
|
14
|
+
template "active_settings.rb", "config/initializers/active_settings.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_migration_file
|
18
|
+
migration_template 'migration.rb', 'db/migrate/create_active_settings.rb'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
ActiveSettings.detail do |config|
|
2
|
+
# config.define 'admin.title', :default => "Your App"
|
3
|
+
# config.define 'dev.host'
|
4
|
+
# config.define 'local.timezone', :allow_change => true, :select_from => lambda { ActiveSupport::TimeZone::MAPPING.keys.sort }
|
5
|
+
# config.define 'defaults.locale', :select_from => lambda { Locales.locales }, :allow_blank => true
|
6
|
+
# config.define 'defaults.page.parts', :default => "Body,Extended"
|
7
|
+
# config.define 'defaults.page.status', :select_from => lambda { Status.selectable_values }, :allow_blank => false, :default => "Draft"
|
8
|
+
# config.define 'defaults.page.filter', :select_from => lambda { TextFilter.descendants.map { |s| s.filter_name }.sort }, :allow_blank => true
|
9
|
+
# config.define 'defaults.page.fields'
|
10
|
+
# config.define 'defaults.snippet.filter', :select_from => lambda { Snippets.all.map { |s| s.filter_name }.sort }, :allow_blank => true
|
11
|
+
# config.define 'pagination.param_name', :default => 'page'
|
12
|
+
# config.define 'pagination.per_page_param_name', :default => 'per_page'
|
13
|
+
# config.define 'admin.pagination.per_page', :type => :integer, :default => 50
|
14
|
+
# config.define 'site.title', :default => "Your site title", :allow_blank => false
|
15
|
+
# config.define 'site.host', :default => "www.example.com", :allow_blank => false
|
16
|
+
# config.define 'user.allow_password_reset?', :default => true
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateActiveSettings < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
create_table :active_settings do |t|
|
4
|
+
t.string :key, limit: 80
|
5
|
+
t.string :value, limit: 120
|
6
|
+
end
|
7
|
+
|
8
|
+
change_table :active_settings do |t|
|
9
|
+
t.index :key, unique: true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
drop_table :active_settings
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_settings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott V. Rosenthal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: ActiveSettings provides an open and ad-hoc settings config for globally-accessible
|
70
|
+
variables via ActiveRecord in your rails 3.1+ app.
|
71
|
+
email:
|
72
|
+
- sr7575@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- lib/active_settings/config/definition.rb
|
78
|
+
- lib/active_settings/config.rb
|
79
|
+
- lib/active_settings/engine.rb
|
80
|
+
- lib/active_settings/version.rb
|
81
|
+
- lib/active_settings.rb
|
82
|
+
- lib/generators/active_settings/install/install_generator.rb
|
83
|
+
- lib/generators/active_settings/install/templates/active_settings.rb
|
84
|
+
- lib/generators/active_settings/install/templates/migration.rb
|
85
|
+
homepage: https://github.com/scottvrosenthal/active_settings
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.0.3
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: ActiveSettings provides an open and ad-hoc settings config & definitions
|
109
|
+
for Rails cached globally-accessible variables via ActiveRecord in your rails 3.1+
|
110
|
+
app.
|
111
|
+
test_files: []
|