harukizaemon-system_settings 2.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.
@@ -0,0 +1,46 @@
1
+ == 2.0.1 released 2009-02-08
2
+
3
+ * Bump version number to try and get it to build on GitHub.
4
+
5
+ == 2.0.0 released 2009-01-14
6
+
7
+ * Updated to Rails 2.2.2.
8
+ * Removed all dependencies.
9
+
10
+ == 2007-10-01
11
+
12
+ * (#14286) Calls to SystemSetting[:environment] return nil.
13
+
14
+ == 2006-10-13
15
+
16
+ * install.rb informs user of missing dependencies.
17
+
18
+ == 2006-09-09
19
+
20
+ * Removed dependency on RedHill on Rails Core.
21
+ * Removed dependency on defunct Schema Defining.
22
+
23
+ == 2006-09-04
24
+
25
+ * Migration script generated with a column limit for name to satisfy most databases. If you're using a database such as PostgreSQL--that supports unbounded text fields with no performance penalties--and wish to have the previous behaviour, you can still edit the generated file and change it manually.
26
+
27
+ == 2006-09-03
28
+
29
+ * Migration script generator determines pluralisation at generation time.
30
+
31
+ == 2006-09-02
32
+
33
+ * The default generated migration script name is now create_system_settings.rb
34
+ * Correctly handle pluralisation of the table name via Inflector.
35
+
36
+ == 2006-08-02
37
+
38
+ * Removed validates_uniqueness_of :name. Install the schema_validations plugin instead.
39
+
40
+ == 2006-07-17
41
+
42
+ * Removed validates_presence_of :value. Install the schema_validations plugin instead.
43
+
44
+ == 2006-07-03
45
+
46
+ * Initial version.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Simon Harris
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ = System Settings
2
+
3
+ System Settings is a plugin that provides a convenient way to store and retrieve system configuration settings in the
4
+ database. The plugin provides a single model SystemSetting with two properties name+, and value+ Names must be unique
5
+ whereas values have no such restriction.
6
+
7
+ To create and retrieve system settings, the usual active record operations can be used:
8
+
9
+ SystemSetting.create(:name => "environment", :value => "production")
10
+ SystemSetting.find_by_name("environment") # => "production"
11
+ SystemSetting[:environment] # => "production"
12
+
13
+ Note that you can lookup a system setting using either a string or a symbol.
14
+
15
+ == Installation
16
+
17
+ You have two choices for installation. The first uses a gem (recommended):
18
+
19
+ config.gem "harukizaemon-system_settings", :lib => "system_settings", :source => "http://gems.github.com"
20
+
21
+ Or you can use the Rails plugin
22
+
23
+ $ ruby script/plugin install git://github.com/harukizaemon/system_settings.git
24
+
25
+ Once installed, System Settings requires the creation of a single table. You may choose to perform this step manually,
26
+ or use the generator provided. To use the generator, run:
27
+
28
+ ./script/generate system_settings_migration
29
+
30
+ This will generate an appropriately numbered migration script named <code>NNN_create_system_settings.rb</code> in the
31
+ <code>db/migrate</code> directory. The next time you run rake migrate, the table will automatically be created for you.
32
+
33
+ If you would prefer a different name for the script, simply pass the name as an argument. For example:
34
+
35
+ ./script/generate system_settings_migration create_the_system_settings_table
36
+
37
+ The plugin fully supports and understands the following active-record configuration properties:
38
+
39
+ * config.active_record.pluralize_table_names
40
+ * config.active_record.table_name_prefix
41
+ * config.active_record.table_name_suffix
42
+
43
+ === License
44
+
45
+ This plugin is copyright 2009 by Simon Harris and is released under the MIT license.
@@ -0,0 +1,12 @@
1
+ class SystemSettingsMigrationGenerator < Rails::Generator::NamedBase
2
+ def initialize(runtime_args, runtime_options = {})
3
+ runtime_args << 'create_system_settings' if runtime_args.empty?
4
+ super
5
+ end
6
+
7
+ def manifest
8
+ record do |m|
9
+ m.migration_template 'migration.rb', 'db/migrate'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ <%
2
+ table_name = "system_setting"
3
+ table_name = table_name.pluralize if ActiveRecord::Base.pluralize_table_names
4
+ -%>
5
+ class <%= class_name %> < ActiveRecord::Migration
6
+ def self.up
7
+ create_table :<%= table_name %> do |t|
8
+ t.column :name, :string, :null => false, :limit => 255
9
+ t.column :value, :text, :null => false
10
+ end
11
+
12
+ add_index :<%= table_name %>, [:name], :unique => true
13
+ end
14
+
15
+ def self.down
16
+ drop_table :<%= table_name %>
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ class SystemSetting < ActiveRecord::Base
2
+ unless defined?(RedHillConsulting::SchemaValidations)
3
+ validates_presence_of :name
4
+ validates_uniqueness_of :name
5
+ validates_length_of :name, :maximum => 255
6
+ end
7
+
8
+ def self.find_by_name(name)
9
+ first(:conditions => ["name = ?", name.to_s]) unless name.nil?
10
+ end
11
+
12
+ def self.[](name)
13
+ find_by_name(name)
14
+ end
15
+
16
+ def to_f
17
+ value.to_f
18
+ end
19
+
20
+ def to_i
21
+ value.to_i
22
+ end
23
+
24
+ def to_s
25
+ value
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "system_settings"
3
+ s.version = "2.0.1"
4
+ s.date = "2009-01-14"
5
+ s.summary = "Store and retrieve Ruby on Rails application configuration settings in the database."
6
+ s.email = "haruki.zaemon@gmail.com"
7
+ s.homepage = "http://github.com/harukizaemon/system_settings"
8
+ s.description = "Store and retrieve Ruby on Rails application configuration settings in the database."
9
+ s.has_rdoc = true
10
+ s.authors = ["Simon Harris"]
11
+ s.files = ["CHANGELOG.rdoc",
12
+ "MIT-LICENSE",
13
+ "README.rdoc",
14
+ "system_settings.gemspec",
15
+ "generators/system_settings_migration",
16
+ "generators/system_settings_migration/system_settings_migration_generator.rb",
17
+ "generators/system_settings_migration/templates",
18
+ "generators/system_settings_migration/templates/migration.rb",
19
+ "lib/system_setting.rb"]
20
+ s.rdoc_options = ["--main", "README.rdoc"]
21
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
22
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: harukizaemon-system_settings
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Simon Harris
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-14 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Store and retrieve Ruby on Rails application configuration settings in the database.
17
+ email: haruki.zaemon@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - CHANGELOG.rdoc
24
+ - README.rdoc
25
+ files:
26
+ - CHANGELOG.rdoc
27
+ - MIT-LICENSE
28
+ - README.rdoc
29
+ - system_settings.gemspec
30
+ - generators/system_settings_migration
31
+ - generators/system_settings_migration/system_settings_migration_generator.rb
32
+ - generators/system_settings_migration/templates
33
+ - generators/system_settings_migration/templates/migration.rb
34
+ - lib/system_setting.rb
35
+ has_rdoc: true
36
+ homepage: http://github.com/harukizaemon/system_settings
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --main
40
+ - README.rdoc
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.2.0
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Store and retrieve Ruby on Rails application configuration settings in the database.
62
+ test_files: []
63
+