Commits

Michael Granger committed fc2da6a

Added Loggability and Configurability support.

Comments (0)

Files changed (2)

 # .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
+

lib/strelka/app/fancyerrors.rb

 # vim: set nosta noet ts=4 sw=4:
 # encoding: utf-8
 
+require 'loggability'
+require 'configurability'
 require 'inversion'
 
 require 'strelka' unless defined?( Strelka )
 # 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'
 
 		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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.