refinerycms-settings-initializer 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.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2011 Kyle Wilkinson, InternMatch
2
+
3
+ The MIT License (MIT)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/changelog.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.9 [24 June 2011]
2
+ * add unscoped logic
3
+ * add settings.yml file and class to load them
4
+ * add generator
5
+ * Gemspec and Version
6
+
@@ -0,0 +1,20 @@
1
+ module Refinery
2
+ module Generators
3
+ class SettingsInitializerGenerator < Rails::Generators::Base
4
+ desc 'Creates a RefinerySetting initializer to load RefinerySettings from a configuration file.'
5
+
6
+ def self.source_root
7
+ @_refinerycms_settigs_initializer_source_root ||= File.expand_path("../templates", __FILE__)
8
+ end
9
+
10
+ def create_config_file
11
+ template 'settings.yml', File.join('config', 'refinery', 'settings.yml')
12
+ end
13
+
14
+ def create_initializer_file
15
+ template 'refinerycms_settings.rb', File.join('config', 'initializers', 'refinerycms_settings.rb')
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,8 @@
1
+ require 'refinerycms-settings-initializer'
2
+
3
+
4
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
5
+ # four configuration values can also be set straight in your models.
6
+ ::Refinery::SettingsInitializer::Loader.new(
7
+ YAML::load(File.open("#{Rails.root}/config/refinery/settings.yml"))
8
+ ).load
@@ -0,0 +1,20 @@
1
+ # RefinerySettings Configuration File. Loads these settings on app startup.
2
+ #
3
+ # File is formatted as:
4
+ #
5
+ # scoping:
6
+ # setting_name:
7
+ # value: foo
8
+ # destroyable: *optional*
9
+ # ...
10
+ # setting2_name:
11
+ # value: foo
12
+ # destroyable: *optional*
13
+ # ...
14
+ #
15
+ # For "unscoping-ed" settings, use this as the scoping:
16
+ # unscoped:
17
+ # unscoped_setting_name:
18
+ # ...
19
+ # unscoped_setting_name_2:
20
+ #
@@ -0,0 +1,33 @@
1
+ module Refinery
2
+ module SettingsInitializer
3
+ class Loader
4
+ attr_reader :settings
5
+
6
+ def initialize(settings)
7
+ @settings = settings
8
+ end
9
+
10
+ def load
11
+ @settings.map do |scope, settings|
12
+ settings.map do |name, value|
13
+ [name, transform_value(value, scope)]
14
+ end
15
+ end.flatten(1).each do |setting|
16
+ RefinerySetting.set(setting.first, setting.last)
17
+ end
18
+ end
19
+
20
+ private
21
+ def transform_value(value, scope)
22
+ value = symbolize_keys(value)
23
+ scope == 'unscoped' ? value : value.merge({:scoping => scope})
24
+ end
25
+
26
+ def symbolize_keys(value)
27
+ Hash[value.map{|k, v| [k.to_sym, v]}]
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,7 @@
1
+ module Refinery
2
+ module SettingsInitializer
3
+ VERSION = "0.9"
4
+ end
5
+ end
6
+
7
+
@@ -0,0 +1,7 @@
1
+ module Refinery
2
+ module SettingsInitializer
3
+ autoload :Version, File.expand_path('../refinery/settings_initializer/version', __FILE__)
4
+ autoload :Loader, File.expand_path('../refinery/settings_initializer/loader', __FILE__)
5
+ end
6
+ end
7
+
data/readme.md ADDED
File without changes
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-settings-initializer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ version: "0.9"
10
+ platform: ruby
11
+ authors:
12
+ - Kyle Wilkinson
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-06-24 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: refinerycms-settings
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 23
29
+ segments:
30
+ - 1
31
+ - 0
32
+ - 0
33
+ version: 1.0.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: Adds an initializer to a Rails project using RefineryCMS that reads in a YAML configuration file to initialize RefinerySettings.
37
+ email:
38
+ - kyle@internmatch.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - lib/rails/generators/refinery/settings_initializer_generator.rb
47
+ - lib/rails/generators/refinery/templates/refinerycms_settings.rb
48
+ - lib/rails/generators/refinery/templates/settings.yml
49
+ - lib/refinery/settings_initializer/loader.rb
50
+ - lib/refinery/settings_initializer/version.rb
51
+ - lib/refinerycms-settings-initializer.rb
52
+ - LICENSE
53
+ - readme.md
54
+ - changelog.md
55
+ has_rdoc: true
56
+ homepage: http://github.com/wikyd/refinerycms-settings-initializer
57
+ licenses: []
58
+
59
+ post_install_message:
60
+ rdoc_options: []
61
+
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 23
79
+ segments:
80
+ - 1
81
+ - 3
82
+ - 6
83
+ version: 1.3.6
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.6.2
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Configure RefineryCMS settings with a file, instead of by hand.
91
+ test_files: []
92
+