-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated initial loading into the HushCMS module, added loading of …
…config/hush.yml and validation of required entries
- Loading branch information
1 parent
c77eb97
commit a8a8de4
Showing
2 changed files
with
40 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
require File.join(File.dirname(__FILE__), 'lib', 'hush_cms') | ||
|
||
HushCMS.load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
require 'extensions/string' | ||
require 'extensions/mapper' | ||
|
||
%w( models controllers helpers ).each do |dir| | ||
path = File.join(File.dirname(__FILE__), dir) | ||
$LOAD_PATH << path | ||
Dependencies.load_paths << path | ||
Dependencies.load_once_paths.delete(path) | ||
end | ||
|
||
ActionController::Base.append_view_path(File.join(File.dirname(__FILE__), 'views')) | ||
ActionView::Base.send :include, HushCMSViewHelpers | ||
|
||
module HushCMS | ||
class << self | ||
attr_reader :configuration | ||
|
||
def load | ||
%w( models controllers controllers/admin helpers ).each do |dir| | ||
path = File.join(File.dirname(__FILE__), dir) | ||
$LOAD_PATH << path | ||
Dependencies.load_paths << path | ||
Dependencies.load_once_paths.delete(path) | ||
end | ||
|
||
ActionController::Base.append_view_path(File.join(File.dirname(__FILE__), 'views')) | ||
ActionView::Base.send :include, HushCMSViewHelpers | ||
|
||
if File.exist?("#{RAILS_ROOT}/config/hush.yml") | ||
@configuration = YAML::load(File.open("#{RAILS_ROOT}/config/hush.yml")) | ||
else | ||
raise ConfigurationException.new("config/hush.yml doesn't exist") | ||
end | ||
|
||
validate_configuration | ||
end | ||
|
||
private | ||
def validate_configuration | ||
unless configuration | ||
raise ConfigurationException.new("config/hush.yml doesn't define anything") | ||
end | ||
|
||
unless configuration['administration'] && configuration['administration']['username'] && configuration['administration']['password'] | ||
raise ConfigurationException.new("config/hush.yml doesn't define username and password under administration") | ||
end | ||
end | ||
end | ||
|
||
class ConfigurationException < Exception | ||
end | ||
end | ||
|