Skip to content
Browse files

Added Loggability and Configurability support.

  • Loading branch information...
1 parent 279f0a9 commit f22ecaadb1272c98325c13f72bacee2ea41d87bc @ged committed May 11, 2012
Showing with 37 additions and 5 deletions.
  1. +3 −1 .rvm.gems
  2. +34 −4 lib/strelka/app/fancyerrors.rb
View
4 .rvm.gems
@@ -1,3 +1,5 @@
# .gems generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator
-inversion -v0.9.0
+inversion -v0.10.0
#strelka -v0.0.1
+loggability -v0.2.1
+
View
38 lib/strelka/app/fancyerrors.rb
@@ -2,6 +2,8 @@
# vim: set nosta noet ts=4 sw=4:
# encoding: utf-8
+require 'loggability'
+require 'configurability'
require 'inversion'
require 'strelka' unless defined?( Strelka )
@@ -11,10 +13,16 @@
# Fancy/useful error output for Strelka appliation development. This plugin
# uses the Strelka default :errors and :templating plugins.
module Strelka::App::FancyErrors
- extend Configurability,
+ extend Loggability,
+ Configurability,
+ Strelka::MethodUtilities,
Strelka::Plugin
+ # Loggability API -- log to Strelka's logger
+ log_to :strelka
+
+
# Library version constant
VERSION = '0.0.1'
@@ -42,17 +50,39 @@ module Strelka::App::FancyErrors
end
+ # Configurability configuration defaults
+ CONFIG_DEFAULTS = {
+ templates_dir: DEFAULT_DATADIR + 'templates',
+ }
+
+
+ ##
+ # The path to the error templates
+ singleton_attr_accessor :templates_dir
+ self.templates_dir = CONFIG_DEFAULTS[:templates_dir]
+
+
+ ### Configurability API -- Configure the plugin
+ def self::configure( config=nil )
+ if config
+ self.log.debug "Configuring fancy error templates: %p" % [ config ]
+ self.templates_dir = Pathname( config[:templates_dir] ) if config[:templates_dir]
+ end
+ end
+
+
# Class-level functionality
module ClassMethods
+ extend Loggability
+ log_to :strelka
### Extension callback -- overridden to also install dependencies.
def self::extended( obj )
super
- Strelka.log.debug "Setting up fancy error responses."
+ self.log.debug "Setting up fancy error responses."
# Add the plugin's template directory to Inversion's template path
- templatedir = DEFAULT_DATADIR + 'templates'
- Inversion::Template.template_paths.push( templatedir )
+ Inversion::Template.template_paths.push( Strelka::App::FancyErrors.templates_dir )
# Load the plugins this one depends on if they aren't already
obj.plugins :errors, :templating

0 comments on commit f22ecaa

Please sign in to comment.
Something went wrong with that request. Please try again.