lib/ruote/context.rb in ruote-2.1.11 vs lib/ruote/context.rb in ruote-2.2.0
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -27,22 +27,22 @@
module Ruote
#
# A sort of internal registry, via a shared instance of this class, the worker
- # and the engine can access subservices like parser, treechecker,
+ # and the engine can access subservices like reader, treechecker,
# wfid_generator and so on.
#
class Context
SERVICE_PREFIX = /^s\_/
attr_reader :storage
attr_accessor :worker
attr_accessor :engine
- def initialize (storage, worker=nil)
+ def initialize(storage, worker=nil)
@storage = storage
@storage.context = self
@engine = nil
@@ -78,18 +78,18 @@
#
# if @context['ruby_eval_allowed']
# # ...
# end
#
- def [] (key)
+ def [](key)
SERVICE_PREFIX.match(key) ? @services[key] : get_conf[key]
end
# Mostly used by engine#configure
#
- def []= (key, value)
+ def []=(key, value)
raise(
ArgumentError.new('use context#add_service to register services')
) if SERVICE_PREFIX.match(key)
@@ -103,11 +103,11 @@
def keys
get_conf.keys
end
- def add_service (key, *args)
+ def add_service(key, *args)
path, klass, opts = args
key = "s_#{key}" unless SERVICE_PREFIX.match(key)
@@ -139,12 +139,12 @@
# Takes care of shutting down every service registered in this context.
#
def shutdown
- @storage.shutdown if @storage.respond_to?(:shutdown)
@worker.shutdown if @worker
+ @storage.shutdown if @storage.respond_to?(:shutdown)
@services.values.each { |s| s.shutdown if s.respond_to?(:shutdown) }
end
protected
@@ -166,12 +166,12 @@
def default_conf
{ 's_wfidgen' => [
'ruote/id/mnemo_wfid_generator', 'Ruote::MnemoWfidGenerator' ],
- 's_parser' => [
- 'ruote/parser', 'Ruote::Parser' ],
+ 's_reader' => [
+ 'ruote/reader', 'Ruote::Reader' ],
's_treechecker' => [
'ruote/svc/treechecker', 'Ruote::TreeChecker' ],
's_expmap' => [
'ruote/svc/expression_map', 'Ruote::ExpressionMap' ],
's_tracker' => [
@@ -183,10 +183,12 @@
's_dollar_sub' => [
'ruote/svc/dollar_sub', 'Ruote::DollarSubstitution' ],
's_error_handler' => [
'ruote/svc/error_handler', 'Ruote::ErrorHandler' ],
's_logger' => [
- 'ruote/log/wait_logger', 'Ruote::WaitLogger' ] }
+ 'ruote/log/wait_logger', 'Ruote::WaitLogger' ],
+ 's_history' => [
+ 'ruote/log/default_history', 'Ruote::DefaultHistory' ] }
end
end
end