inversion 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.rdoc +6 -0
- data/Manifest.txt +2 -1
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/lib/inversion.rb +9 -63
- data/lib/inversion/{utils.rb → logging.rb} +60 -8
- data/lib/inversion/mixins.rb +46 -4
- data/lib/inversion/renderstate.rb +11 -14
- data/lib/inversion/template.rb +1 -1
- data/lib/inversion/template/fortag.rb +2 -2
- data/lib/inversion/template/tag.rb +10 -7
- data/spec/inversion/logging_spec.rb +74 -0
- data/spec/lib/helpers.rb +3 -3
- metadata +30 -29
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== v0.8.0 [2012-04-01] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
- Optimization fixes
|
4
|
+
- Fixed rendering flow control to not use a begin/rescue.
|
5
|
+
|
6
|
+
|
1
7
|
== v0.7.0 [2012-03-29] Michael Granger <ged@FaerieMUD.org>
|
2
8
|
|
3
9
|
- Switch to a much more flexible way to render tag bodies. This should
|
data/Manifest.txt
CHANGED
@@ -6,6 +6,7 @@ Rakefile
|
|
6
6
|
bin/inversion
|
7
7
|
lib/inversion.rb
|
8
8
|
lib/inversion/exceptions.rb
|
9
|
+
lib/inversion/logging.rb
|
9
10
|
lib/inversion/mixins.rb
|
10
11
|
lib/inversion/monkeypatches.rb
|
11
12
|
lib/inversion/parser.rb
|
@@ -40,8 +41,8 @@ lib/inversion/template/unlesstag.rb
|
|
40
41
|
lib/inversion/template/uriencodetag.rb
|
41
42
|
lib/inversion/template/yieldtag.rb
|
42
43
|
lib/inversion/tilt.rb
|
43
|
-
lib/inversion/utils.rb
|
44
44
|
spec/data/sinatra/hello.inversion
|
45
|
+
spec/inversion/logging_spec.rb
|
45
46
|
spec/inversion/mixins_spec.rb
|
46
47
|
spec/inversion/monkeypatches_spec.rb
|
47
48
|
spec/inversion/parser_spec.rb
|
data/README.rdoc
CHANGED
@@ -118,7 +118,7 @@ and generate the API documentation.
|
|
118
118
|
|
119
119
|
== License
|
120
120
|
|
121
|
-
Copyright © 2011, Michael Granger and Mahlon E. Smith
|
121
|
+
Copyright © 2011-2012, Michael Granger and Mahlon E. Smith
|
122
122
|
All rights reserved.
|
123
123
|
|
124
124
|
Redistribution and use in source and binary forms, with or without
|
data/Rakefile
CHANGED
@@ -45,7 +45,7 @@ end
|
|
45
45
|
ENV['VERSION'] ||= hoespec.spec.version.to_s
|
46
46
|
|
47
47
|
# Ensure the specs pass before checking in
|
48
|
-
task 'hg:precheckin' => [:check_history, :spec]
|
48
|
+
task 'hg:precheckin' => [:check_history, :check_manifest, :spec]
|
49
49
|
|
50
50
|
if Rake::Task.task_defined?( '.gemtest' )
|
51
51
|
Rake::Task['.gemtest'].clear
|
data/lib/inversion.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
require 'logger'
|
5
|
-
|
6
4
|
|
7
5
|
# The Inversion templating system. This module provides the namespace for all the other
|
8
|
-
# classes and modules, and contains the logging subsystem. A good place to start for
|
9
|
-
# documentation would be to check out the examples in the README, and then
|
6
|
+
# classes and modules, and contains the logging subsystem. A good place to start for
|
7
|
+
# documentation would be to check out the examples in the README, and then
|
10
8
|
# Inversion::Template for a list of tags, configuration options, etc.
|
11
9
|
#
|
12
10
|
# == Authors
|
@@ -20,69 +18,14 @@ module Inversion
|
|
20
18
|
|
21
19
|
warn ">>> Inversion requires Ruby 1.9.2 or later. <<<" if RUBY_VERSION < '1.9.2'
|
22
20
|
|
23
|
-
require 'inversion/exceptions'
|
24
|
-
require 'inversion/mixins'
|
25
|
-
require 'inversion/utils'
|
26
|
-
require 'inversion/monkeypatches'
|
27
|
-
|
28
21
|
# Library version constant
|
29
|
-
VERSION = '0.
|
22
|
+
VERSION = '0.8.0'
|
30
23
|
|
31
24
|
# Version-control revision constant
|
32
|
-
REVISION = %q$Revision:
|
33
|
-
|
34
|
-
#
|
35
|
-
# Logging
|
36
|
-
#
|
37
|
-
|
38
|
-
# Log levels
|
39
|
-
LOG_LEVELS = {
|
40
|
-
'debug' => Logger::DEBUG,
|
41
|
-
'info' => Logger::INFO,
|
42
|
-
'warn' => Logger::WARN,
|
43
|
-
'error' => Logger::ERROR,
|
44
|
-
'fatal' => Logger::FATAL,
|
45
|
-
}.freeze
|
46
|
-
|
47
|
-
# Log levels keyed by level
|
48
|
-
LOG_LEVEL_NAMES = LOG_LEVELS.invert.freeze
|
49
|
-
|
50
|
-
@default_logger = Logger.new( $stderr )
|
51
|
-
@default_logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
|
52
|
-
|
53
|
-
@default_log_formatter = Inversion::LogFormatter.new( @default_logger )
|
54
|
-
@default_logger.formatter = @default_log_formatter
|
55
|
-
|
56
|
-
@logger = @default_logger
|
57
|
-
|
25
|
+
REVISION = %q$Revision: 2b5542ae6bf6 $
|
58
26
|
|
59
|
-
|
60
|
-
|
61
|
-
attr_accessor :default_log_formatter
|
62
|
-
|
63
|
-
# the logger that will be used when the logging subsystem is reset
|
64
|
-
attr_accessor :default_logger
|
65
|
-
|
66
|
-
# the logger that's currently in effect
|
67
|
-
attr_accessor :logger
|
68
|
-
alias_method :log, :logger
|
69
|
-
alias_method :log=, :logger=
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
### Reset the global logger object to the default
|
74
|
-
def self::reset_logger
|
75
|
-
self.logger = self.default_logger
|
76
|
-
self.logger.level = Logger::WARN
|
77
|
-
self.logger.formatter = self.default_log_formatter
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
|
-
### Returns +true+ if the global logger has not been set to something other than
|
82
|
-
### the default one.
|
83
|
-
def self::using_default_logger?
|
84
|
-
return self.logger == self.default_logger
|
85
|
-
end
|
27
|
+
require 'inversion/logging'
|
28
|
+
extend Inversion::Logging
|
86
29
|
|
87
30
|
|
88
31
|
### Get the Inversion version.
|
@@ -92,6 +35,9 @@ module Inversion
|
|
92
35
|
return vstring
|
93
36
|
end
|
94
37
|
|
38
|
+
require 'inversion/exceptions'
|
39
|
+
require 'inversion/mixins'
|
40
|
+
require 'inversion/monkeypatches'
|
95
41
|
require 'inversion/template'
|
96
42
|
|
97
43
|
end # module Inversion
|
@@ -8,12 +8,64 @@ require 'inversion' unless defined?( Inversion )
|
|
8
8
|
require 'inversion/mixins'
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
# A mixin that provides a top-level logging subsystem based on Logger.
|
12
|
+
module Inversion::Logging
|
13
|
+
|
14
|
+
### Logging
|
15
|
+
# Log levels
|
16
|
+
LOG_LEVELS = {
|
17
|
+
'debug' => Logger::DEBUG,
|
18
|
+
'info' => Logger::INFO,
|
19
|
+
'warn' => Logger::WARN,
|
20
|
+
'error' => Logger::ERROR,
|
21
|
+
'fatal' => Logger::FATAL,
|
22
|
+
}.freeze
|
23
|
+
LOG_LEVEL_NAMES = LOG_LEVELS.invert.freeze
|
24
|
+
|
25
|
+
|
26
|
+
### Inclusion hook
|
27
|
+
def self::extended( mod )
|
28
|
+
super
|
29
|
+
|
30
|
+
class << mod
|
31
|
+
# the log formatter that will be used when the logging subsystem is reset
|
32
|
+
attr_accessor :default_log_formatter
|
33
|
+
|
34
|
+
# the logger that will be used when the logging subsystem is reset
|
35
|
+
attr_accessor :default_logger
|
36
|
+
|
37
|
+
# the logger that's currently in effect
|
38
|
+
attr_accessor :logger
|
39
|
+
alias_method :log, :logger
|
40
|
+
alias_method :log=, :logger=
|
41
|
+
end
|
42
|
+
|
43
|
+
mod.default_logger = mod.logger = Logger.new( $stderr )
|
44
|
+
mod.default_logger.level = case
|
45
|
+
when $DEBUG then Logger::DEBUG
|
46
|
+
when $VERBOSE then Logger::INFO
|
47
|
+
else Logger::WARN end
|
48
|
+
mod.default_log_formatter = Inversion::Logging::Formatter.new( mod.default_logger )
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
### Reset the global logger object to the default
|
53
|
+
def reset_logger
|
54
|
+
self.logger = self.default_logger
|
55
|
+
self.logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
|
56
|
+
self.logger.formatter = self.default_log_formatter
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
### Returns +true+ if the global logger has not been set to something other than
|
61
|
+
### the default one.
|
62
|
+
def using_default_logger?
|
63
|
+
return self.logger == self.default_logger
|
64
|
+
end
|
12
65
|
|
13
|
-
# :stopdoc:
|
14
66
|
|
15
67
|
# A alternate formatter for Logger instances.
|
16
|
-
class
|
68
|
+
class Formatter < Logger::Formatter
|
17
69
|
|
18
70
|
# The format to output unless debugging is turned on
|
19
71
|
DEFAULT_FORMAT = "[%1$s.%2$06d %3$d/%4$s] %5$5s -- %7$s\n"
|
@@ -64,11 +116,11 @@ module Inversion
|
|
64
116
|
return self.format % args
|
65
117
|
end
|
66
118
|
end
|
67
|
-
end # class
|
119
|
+
end # class Formatter
|
68
120
|
|
69
121
|
|
70
122
|
# A ANSI-colorized formatter for Logger instances.
|
71
|
-
class
|
123
|
+
class ColorFormatter < Logger::Formatter
|
72
124
|
|
73
125
|
# Set some ANSI escape code constants (Shamelessly stolen from Perl's
|
74
126
|
# Term::ANSIColor by Russ Allbery <rra@stanford.edu> and Zenin <zenin@best.com>
|
@@ -173,12 +225,12 @@ module Inversion
|
|
173
225
|
return self.settings[ severity.downcase.to_sym ] % args
|
174
226
|
end
|
175
227
|
|
176
|
-
end # class
|
228
|
+
end # class Formatter
|
177
229
|
|
178
230
|
|
179
231
|
# An alternate formatter for Logger instances that outputs +div+ HTML
|
180
232
|
# fragments.
|
181
|
-
class
|
233
|
+
class HtmlFormatter < Logger::Formatter
|
182
234
|
include ERB::Util # for html_escape()
|
183
235
|
|
184
236
|
# The default HTML fragment that'll be used as the template for each log message.
|
@@ -229,7 +281,7 @@ module Inversion
|
|
229
281
|
return self.format % args
|
230
282
|
end
|
231
283
|
|
232
|
-
end # class
|
284
|
+
end # class HtmlFormatter
|
233
285
|
|
234
286
|
end # module Inversion
|
235
287
|
|
data/lib/inversion/mixins.rb
CHANGED
@@ -6,12 +6,12 @@ require 'logger'
|
|
6
6
|
|
7
7
|
module Inversion
|
8
8
|
|
9
|
-
# Add logging to a Inversion class. Including classes get #log and
|
9
|
+
# Add logging to a Inversion class. Including classes get #log and
|
10
10
|
# #log_debug methods.
|
11
11
|
#
|
12
12
|
# class MyClass
|
13
13
|
# include Inversion::Loggable
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# def a_method
|
16
16
|
# self.log.debug "Doing a_method stuff..."
|
17
17
|
# end
|
@@ -189,10 +189,10 @@ module Inversion
|
|
189
189
|
|
190
190
|
|
191
191
|
# A mixin that adds configurable escaping to a tag class.
|
192
|
-
#
|
192
|
+
#
|
193
193
|
# class MyTag < Inversion::Template::Tag
|
194
194
|
# include Inversion::Escaping
|
195
|
-
#
|
195
|
+
#
|
196
196
|
# def render( renderstate )
|
197
197
|
# val = self.get_rendered_value
|
198
198
|
# return self.escape( val.to_s, renderstate )
|
@@ -232,5 +232,47 @@ module Inversion
|
|
232
232
|
|
233
233
|
end # Escaping
|
234
234
|
|
235
|
+
|
236
|
+
# A collection of methods for declaring other methods.
|
237
|
+
#
|
238
|
+
# class MyClass
|
239
|
+
# include Inversion::MethodUtilities
|
240
|
+
#
|
241
|
+
# singleton_attr_accessor :types
|
242
|
+
# end
|
243
|
+
#
|
244
|
+
# MyClass.types = [ :pheno, :proto, :stereo ]
|
245
|
+
#
|
246
|
+
module MethodUtilities
|
247
|
+
|
248
|
+
### Creates instance variables and corresponding methods that return their
|
249
|
+
### values for each of the specified +symbols+ in the singleton of the
|
250
|
+
### declaring object (e.g., class instance variables and methods if declared
|
251
|
+
### in a Class).
|
252
|
+
def singleton_attr_reader( *symbols )
|
253
|
+
symbols.each do |sym|
|
254
|
+
singleton_class.__send__( :attr_reader, sym )
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
### Creates methods that allow assignment to the attributes of the singleton
|
259
|
+
### of the declaring object that correspond to the specified +symbols+.
|
260
|
+
def singleton_attr_writer( *symbols )
|
261
|
+
symbols.each do |sym|
|
262
|
+
singleton_class.__send__( :attr_writer, sym )
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
### Creates readers and writers that allow assignment to the attributes of
|
267
|
+
### the singleton of the declaring object that correspond to the specified
|
268
|
+
### +symbols+.
|
269
|
+
def singleton_attr_accessor( *symbols )
|
270
|
+
symbols.each do |sym|
|
271
|
+
singleton_class.__send__( :attr_accessor, sym )
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
end # module MethodUtilities
|
276
|
+
|
235
277
|
end # module Inversion
|
236
278
|
|
@@ -37,11 +37,7 @@ class Inversion::RenderState
|
|
37
37
|
### which can be either another Scope or a Hash.
|
38
38
|
def +( values )
|
39
39
|
# Have to do it this kludgy way because Scopes don't have #respond_to?
|
40
|
-
|
41
|
-
return Scope.new( @locals.merge(values.__locals__) )
|
42
|
-
rescue ::NameError
|
43
|
-
return Scope.new( @locals.merge(values) )
|
44
|
-
end
|
40
|
+
return Scope.new( @locals.merge(values) )
|
45
41
|
end
|
46
42
|
|
47
43
|
|
@@ -49,6 +45,7 @@ class Inversion::RenderState
|
|
49
45
|
def __locals__
|
50
46
|
return @locals
|
51
47
|
end
|
48
|
+
alias_method :to_hash, :__locals__
|
52
49
|
|
53
50
|
|
54
51
|
#########
|
@@ -150,7 +147,7 @@ class Inversion::RenderState
|
|
150
147
|
### Evaluate the specified +code+ in the context of itself and
|
151
148
|
### return the result.
|
152
149
|
def eval( code )
|
153
|
-
self.log.debug "Evaling: %p" [ code ]
|
150
|
+
# self.log.debug "Evaling: %p" [ code ]
|
154
151
|
return self.scope.instance_eval( code )
|
155
152
|
end
|
156
153
|
|
@@ -165,7 +162,7 @@ class Inversion::RenderState
|
|
165
162
|
### restore the attributes to their original values.
|
166
163
|
def with_attributes( overrides )
|
167
164
|
raise LocalJumpError, "no block given" unless block_given?
|
168
|
-
self.log.debug "Overriding template attributes with: %p" % [ overrides ]
|
165
|
+
# self.log.debug "Overriding template attributes with: %p" % [ overrides ]
|
169
166
|
|
170
167
|
begin
|
171
168
|
newscope = self.scope + overrides
|
@@ -181,7 +178,7 @@ class Inversion::RenderState
|
|
181
178
|
### revert the tag state back to what it was prior to running the block.
|
182
179
|
def with_tag_data( newhash={} )
|
183
180
|
raise LocalJumpError, "no block given" unless block_given?
|
184
|
-
self.log.debug "Overriding tag state with: %p" % [ newhash ]
|
181
|
+
# self.log.debug "Overriding tag state with: %p" % [ newhash ]
|
185
182
|
|
186
183
|
begin
|
187
184
|
@tag_data.push( @tag_data.last.merge(newhash) )
|
@@ -196,13 +193,13 @@ class Inversion::RenderState
|
|
196
193
|
### destination when the block returns.
|
197
194
|
def with_destination( new_destination )
|
198
195
|
raise LocalJumpError, "no block given" unless block_given?
|
199
|
-
self.log.debug "Overriding render destination with: %p" % [ new_destination ]
|
196
|
+
# self.log.debug "Overriding render destination with: %p" % [ new_destination ]
|
200
197
|
|
201
198
|
begin
|
202
199
|
@destinations.push( new_destination )
|
203
200
|
yield
|
204
201
|
ensure
|
205
|
-
self.log.debug " removing overridden render destination: %p" % [ @destinations.last ]
|
202
|
+
# self.log.debug " removing overridden render destination: %p" % [ @destinations.last ]
|
206
203
|
@destinations.pop
|
207
204
|
end
|
208
205
|
|
@@ -296,12 +293,12 @@ class Inversion::RenderState
|
|
296
293
|
### Publish the given +nodes+ to all subscribers to the specified +key+.
|
297
294
|
def publish( key, *nodes )
|
298
295
|
key = key.to_sym
|
299
|
-
self.log.debug "[0x%016x] Publishing %p nodes: %p" % [ self.object_id * 2, key, nodes ]
|
296
|
+
# self.log.debug "[0x%016x] Publishing %p nodes: %p" % [ self.object_id * 2, key, nodes ]
|
300
297
|
|
301
298
|
self.containerstate.publish( key, *nodes ) if self.containerstate
|
302
299
|
self.subscriptions[ key ].each do |subscriber|
|
303
|
-
self.log.debug " sending %d nodes to subscriber: %p (a %p)" %
|
304
|
-
|
300
|
+
# self.log.debug " sending %d nodes to subscriber: %p (a %p)" %
|
301
|
+
# [ nodes.length, subscriber, subscriber.class ]
|
305
302
|
subscriber.publish( *nodes )
|
306
303
|
end
|
307
304
|
end
|
@@ -432,7 +429,7 @@ class Inversion::RenderState
|
|
432
429
|
### Handle attribute methods.
|
433
430
|
def method_missing( sym, *args, &block )
|
434
431
|
return super unless sym.to_s =~ /^\w+$/
|
435
|
-
self.log.debug "mapping missing method call to tag local: %p" % [ sym ]
|
432
|
+
# self.log.debug "mapping missing method call to tag local: %p" % [ sym ]
|
436
433
|
return self.scope[ sym ]
|
437
434
|
end
|
438
435
|
|
data/lib/inversion/template.rb
CHANGED
@@ -117,7 +117,7 @@ class Inversion::Template
|
|
117
117
|
### Create a new Inversion:Template with the given +source+.
|
118
118
|
def initialize( source, parsestate=nil, opts={} )
|
119
119
|
if parsestate.is_a?( Hash )
|
120
|
-
self.log.debug "Shifting template options: %p" % [ parsestate ]
|
120
|
+
# self.log.debug "Shifting template options: %p" % [ parsestate ]
|
121
121
|
opts = parsestate
|
122
122
|
parsestate = nil
|
123
123
|
else
|
@@ -85,12 +85,12 @@ class Inversion::Template::ForTag < Inversion::Template::CodeTag
|
|
85
85
|
lvalue = state.eval( self.enumerator ) or return nil
|
86
86
|
lvalue = lvalue.each unless lvalue.respond_to?( :next )
|
87
87
|
|
88
|
-
self.log.debug "Rendering %p via block args: %p" % [ lvalue, self.block_args ]
|
88
|
+
# self.log.debug "Rendering %p via block args: %p" % [ lvalue, self.block_args ]
|
89
89
|
|
90
90
|
# Loop will exit as soon as the Enumerator runs out of elements
|
91
91
|
loop do
|
92
92
|
args = Array( lvalue.next )
|
93
|
-
self.log.debug " iterated block args are: %p" % [ args ]
|
93
|
+
# self.log.debug " iterated block args are: %p" % [ args ]
|
94
94
|
|
95
95
|
# Turn the block arguments into an overrides hash by zipping up
|
96
96
|
# the arguments names and values
|
@@ -14,6 +14,7 @@ require 'inversion/mixins'
|
|
14
14
|
# in a gem of your own, put them into a directory named 'inversion/template' and
|
15
15
|
# name the files <tt><tagname>tag.rb</tt> and the classes <tagname.capitalize>Tag.
|
16
16
|
class Inversion::Template::Tag < Inversion::Template::Node
|
17
|
+
extend Inversion::MethodUtilities
|
17
18
|
include Inversion::Loggable,
|
18
19
|
Inversion::AbstractClass
|
19
20
|
|
@@ -26,21 +27,23 @@ class Inversion::Template::Tag < Inversion::Template::Node
|
|
26
27
|
### C L A S S M E T H O D S
|
27
28
|
########################################################################
|
28
29
|
|
29
|
-
|
30
|
+
@derivatives = []
|
30
31
|
@types = nil
|
31
32
|
|
32
|
-
# Derivatives of this class
|
33
|
-
@derivatives = []
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
##
|
35
|
+
# The hash of loaded tag types, keyed by the tag name as a Symbol
|
36
|
+
singleton_attr_reader :types
|
37
|
+
|
38
|
+
##
|
39
|
+
# The Array of subclasses of this class
|
40
|
+
singleton_attr_reader :derivatives
|
38
41
|
|
39
42
|
|
40
43
|
### Inheritance hook -- keep track of loaded derivatives.
|
41
44
|
def self::inherited( subclass )
|
42
45
|
# Inversion.log.debug "%p inherited from %p" % [ subclass, self ]
|
43
|
-
Inversion::Template::Tag.derivatives << subclass
|
46
|
+
Inversion::Template::Tag.derivatives << subclass
|
44
47
|
Inversion.log.debug "Loaded tag type %p" % [ subclass ]
|
45
48
|
super
|
46
49
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# vim: set nosta noet ts=4 sw=4:
|
3
|
+
# encoding: utf-8
|
4
|
+
|
5
|
+
BEGIN {
|
6
|
+
require 'pathname'
|
7
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
8
|
+
$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
|
9
|
+
}
|
10
|
+
|
11
|
+
require 'rspec'
|
12
|
+
require 'stringio'
|
13
|
+
|
14
|
+
require 'spec/lib/helpers'
|
15
|
+
|
16
|
+
require 'inversion'
|
17
|
+
require 'inversion/logging'
|
18
|
+
|
19
|
+
|
20
|
+
#####################################################################
|
21
|
+
### C O N T E X T S
|
22
|
+
#####################################################################
|
23
|
+
|
24
|
+
describe Inversion::Logging, "-extended module" do
|
25
|
+
|
26
|
+
before( :each ) do
|
27
|
+
@extended_module = Module.new do
|
28
|
+
extend Inversion::Logging
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have a default Logger" do
|
33
|
+
@extended_module.logger.should be_a( Logger )
|
34
|
+
@extended_module.default_logger.should equal( @extended_module.logger )
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should know if its default logger is replaced" do
|
38
|
+
@extended_module.should be_using_default_logger
|
39
|
+
@extended_module.logger = Logger.new( $stderr )
|
40
|
+
@extended_module.should_not be_using_default_logger
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has the default logger instance after being reset" do
|
44
|
+
@extended_module.reset_logger
|
45
|
+
@extended_module.logger.should equal( @extended_module.default_logger )
|
46
|
+
end
|
47
|
+
|
48
|
+
it "has the default log formatter instance after being reset" do
|
49
|
+
@extended_module.reset_logger
|
50
|
+
@extended_module.logger.formatter.should equal( @extended_module.default_log_formatter )
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
context "with new defaults" do
|
55
|
+
|
56
|
+
before( :each ) do
|
57
|
+
@sink = StringIO.new
|
58
|
+
@logger = Logger.new( @sink )
|
59
|
+
@formatter = Inversion::Logging::ColorFormatter.new( @logger )
|
60
|
+
|
61
|
+
@extended_module.default_logger = @logger
|
62
|
+
@extended_module.default_log_formatter = @formatter
|
63
|
+
end
|
64
|
+
|
65
|
+
it "uses the new defaults when the logging subsystem is reset" do
|
66
|
+
@extended_module.reset_logger
|
67
|
+
@extended_module.logger.should equal( @logger )
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
end
|
74
|
+
|
data/spec/lib/helpers.rb
CHANGED
@@ -117,8 +117,8 @@ module Inversion::SpecHelpers
|
|
117
117
|
def setup_logging( level=Logger::FATAL )
|
118
118
|
|
119
119
|
# Turn symbol-style level config into Logger's expected Fixnum level
|
120
|
-
if Inversion::LOG_LEVELS.key?( level.to_s )
|
121
|
-
level = Inversion::LOG_LEVELS[ level.to_s ]
|
120
|
+
if Inversion::Logging::LOG_LEVELS.key?( level.to_s )
|
121
|
+
level = Inversion::Logging::LOG_LEVELS[ level.to_s ]
|
122
122
|
end
|
123
123
|
|
124
124
|
logger = Logger.new( $stderr )
|
@@ -131,7 +131,7 @@ module Inversion::SpecHelpers
|
|
131
131
|
logdevice = ArrayLogger.new( Thread.current['logger-output'] )
|
132
132
|
Inversion.logger = Logger.new( logdevice )
|
133
133
|
# Inversion.logger.level = level
|
134
|
-
Inversion.logger.formatter = Inversion::
|
134
|
+
Inversion.logger.formatter = Inversion::Logging::HtmlFormatter.new( logger )
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -37,11 +37,11 @@ cert_chain:
|
|
37
37
|
YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
|
38
38
|
Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
|
39
39
|
cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
40
|
-
date: 2012-
|
40
|
+
date: 2012-04-01 00:00:00.000000000 Z
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: hoe-mercurial
|
44
|
-
requirement: &
|
44
|
+
requirement: &70337034178000 !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
@@ -49,10 +49,10 @@ dependencies:
|
|
49
49
|
version: 1.4.0
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
|
-
version_requirements: *
|
52
|
+
version_requirements: *70337034178000
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: hoe-manualgen
|
55
|
-
requirement: &
|
55
|
+
requirement: &70337034177180 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
58
|
- - ~>
|
@@ -60,10 +60,10 @@ dependencies:
|
|
60
60
|
version: 0.3.0
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
|
-
version_requirements: *
|
63
|
+
version_requirements: *70337034177180
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: hoe-highline
|
66
|
-
requirement: &
|
66
|
+
requirement: &70337034192680 !ruby/object:Gem::Requirement
|
67
67
|
none: false
|
68
68
|
requirements:
|
69
69
|
- - ~>
|
@@ -71,10 +71,10 @@ dependencies:
|
|
71
71
|
version: 0.0.1
|
72
72
|
type: :development
|
73
73
|
prerelease: false
|
74
|
-
version_requirements: *
|
74
|
+
version_requirements: *70337034192680
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: rdoc
|
77
|
-
requirement: &
|
77
|
+
requirement: &70337034191900 !ruby/object:Gem::Requirement
|
78
78
|
none: false
|
79
79
|
requirements:
|
80
80
|
- - ~>
|
@@ -82,10 +82,10 @@ dependencies:
|
|
82
82
|
version: '3.10'
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
|
-
version_requirements: *
|
85
|
+
version_requirements: *70337034191900
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: rspec
|
88
|
-
requirement: &
|
88
|
+
requirement: &70337034191120 !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
@@ -93,10 +93,10 @@ dependencies:
|
|
93
93
|
version: '2.8'
|
94
94
|
type: :development
|
95
95
|
prerelease: false
|
96
|
-
version_requirements: *
|
96
|
+
version_requirements: *70337034191120
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: tilt
|
99
|
-
requirement: &
|
99
|
+
requirement: &70337034190160 !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|
102
102
|
- - ~>
|
@@ -104,10 +104,10 @@ dependencies:
|
|
104
104
|
version: '1.3'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
|
-
version_requirements: *
|
107
|
+
version_requirements: *70337034190160
|
108
108
|
- !ruby/object:Gem::Dependency
|
109
109
|
name: sinatra
|
110
|
-
requirement: &
|
110
|
+
requirement: &70337034189500 !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|
113
113
|
- - ~>
|
@@ -115,10 +115,10 @@ dependencies:
|
|
115
115
|
version: '1.2'
|
116
116
|
type: :development
|
117
117
|
prerelease: false
|
118
|
-
version_requirements: *
|
118
|
+
version_requirements: *70337034189500
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
120
|
name: rack-test
|
121
|
-
requirement: &
|
121
|
+
requirement: &70337034188740 !ruby/object:Gem::Requirement
|
122
122
|
none: false
|
123
123
|
requirements:
|
124
124
|
- - ~>
|
@@ -126,10 +126,10 @@ dependencies:
|
|
126
126
|
version: '0.6'
|
127
127
|
type: :development
|
128
128
|
prerelease: false
|
129
|
-
version_requirements: *
|
129
|
+
version_requirements: *70337034188740
|
130
130
|
- !ruby/object:Gem::Dependency
|
131
131
|
name: simplecov
|
132
|
-
requirement: &
|
132
|
+
requirement: &70337034188120 !ruby/object:Gem::Requirement
|
133
133
|
none: false
|
134
134
|
requirements:
|
135
135
|
- - ~>
|
@@ -137,10 +137,10 @@ dependencies:
|
|
137
137
|
version: '0.4'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
|
-
version_requirements: *
|
140
|
+
version_requirements: *70337034188120
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: trollop
|
143
|
-
requirement: &
|
143
|
+
requirement: &70337034187480 !ruby/object:Gem::Requirement
|
144
144
|
none: false
|
145
145
|
requirements:
|
146
146
|
- - ~>
|
@@ -148,10 +148,10 @@ dependencies:
|
|
148
148
|
version: '1.16'
|
149
149
|
type: :development
|
150
150
|
prerelease: false
|
151
|
-
version_requirements: *
|
151
|
+
version_requirements: *70337034187480
|
152
152
|
- !ruby/object:Gem::Dependency
|
153
153
|
name: highline
|
154
|
-
requirement: &
|
154
|
+
requirement: &70337034186680 !ruby/object:Gem::Requirement
|
155
155
|
none: false
|
156
156
|
requirements:
|
157
157
|
- - ~>
|
@@ -159,10 +159,10 @@ dependencies:
|
|
159
159
|
version: '1.6'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
|
-
version_requirements: *
|
162
|
+
version_requirements: *70337034186680
|
163
163
|
- !ruby/object:Gem::Dependency
|
164
164
|
name: sysexits
|
165
|
-
requirement: &
|
165
|
+
requirement: &70337034186080 !ruby/object:Gem::Requirement
|
166
166
|
none: false
|
167
167
|
requirements:
|
168
168
|
- - ~>
|
@@ -170,10 +170,10 @@ dependencies:
|
|
170
170
|
version: '1.0'
|
171
171
|
type: :development
|
172
172
|
prerelease: false
|
173
|
-
version_requirements: *
|
173
|
+
version_requirements: *70337034186080
|
174
174
|
- !ruby/object:Gem::Dependency
|
175
175
|
name: hoe
|
176
|
-
requirement: &
|
176
|
+
requirement: &70337034185360 !ruby/object:Gem::Requirement
|
177
177
|
none: false
|
178
178
|
requirements:
|
179
179
|
- - ~>
|
@@ -181,7 +181,7 @@ dependencies:
|
|
181
181
|
version: '3.0'
|
182
182
|
type: :development
|
183
183
|
prerelease: false
|
184
|
-
version_requirements: *
|
184
|
+
version_requirements: *70337034185360
|
185
185
|
description: ! 'Inversion is a templating system for Ruby. It uses the "Inversion
|
186
186
|
of Control"
|
187
187
|
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- bin/inversion
|
210
210
|
- lib/inversion.rb
|
211
211
|
- lib/inversion/exceptions.rb
|
212
|
+
- lib/inversion/logging.rb
|
212
213
|
- lib/inversion/mixins.rb
|
213
214
|
- lib/inversion/monkeypatches.rb
|
214
215
|
- lib/inversion/parser.rb
|
@@ -243,8 +244,8 @@ files:
|
|
243
244
|
- lib/inversion/template/uriencodetag.rb
|
244
245
|
- lib/inversion/template/yieldtag.rb
|
245
246
|
- lib/inversion/tilt.rb
|
246
|
-
- lib/inversion/utils.rb
|
247
247
|
- spec/data/sinatra/hello.inversion
|
248
|
+
- spec/inversion/logging_spec.rb
|
248
249
|
- spec/inversion/mixins_spec.rb
|
249
250
|
- spec/inversion/monkeypatches_spec.rb
|
250
251
|
- spec/inversion/parser_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|