inversion 0.9.0 → 0.10.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/ChangeLog +21 -2
- data/History.rdoc +5 -0
- data/Manifest.txt +0 -2
- data/Rakefile +2 -1
- data/bin/inversion +5 -3
- data/lib/inversion.rb +8 -5
- data/lib/inversion/mixins.rb +0 -78
- data/lib/inversion/parser.rb +11 -2
- data/lib/inversion/renderstate.rb +5 -2
- data/lib/inversion/template.rb +5 -1
- data/lib/inversion/template/begintag.rb +1 -2
- data/lib/inversion/template/codetag.rb +1 -2
- data/lib/inversion/template/commenttag.rb +2 -2
- data/lib/inversion/template/configtag.rb +1 -2
- data/lib/inversion/template/elsetag.rb +0 -2
- data/lib/inversion/template/elsiftag.rb +0 -1
- data/lib/inversion/template/endtag.rb +0 -2
- data/lib/inversion/template/fortag.rb +1 -2
- data/lib/inversion/template/iftag.rb +1 -2
- data/lib/inversion/template/includetag.rb +0 -2
- data/lib/inversion/template/node.rb +6 -0
- data/lib/inversion/template/rescuetag.rb +3 -5
- data/lib/inversion/template/tag.rb +8 -3
- data/lib/inversion/template/textnode.rb +0 -1
- data/lib/inversion/template/unlesstag.rb +1 -2
- data/lib/inversion/template/yieldtag.rb +1 -3
- data/spec/inversion/mixins_spec.rb +0 -34
- data/spec/inversion_spec.rb +0 -51
- data/spec/lib/helpers.rb +13 -79
- metadata +110 -31
- metadata.gz.sig +0 -0
- data/lib/inversion/logging.rb +0 -287
- data/spec/inversion/logging_spec.rb +0 -74
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,8 +1,27 @@
|
|
1
|
+
2012-04-24 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* .hgtags:
|
4
|
+
Added tag v0.9.0 for changeset 27f082ef7985
|
5
|
+
[dd18f3255985] [tip]
|
6
|
+
|
7
|
+
* .hgsigs:
|
8
|
+
Added signature for changeset b208fa9154b1
|
9
|
+
[27f082ef7985] [v0.9.0]
|
10
|
+
|
11
|
+
* History.rdoc, lib/inversion.rb:
|
12
|
+
Bump the minor version, update history.
|
13
|
+
[b208fa9154b1]
|
14
|
+
|
15
|
+
* lib/inversion/template.rb, spec/inversion/template_spec.rb:
|
16
|
+
Split the template path out from the config into a class instance
|
17
|
+
variable.
|
18
|
+
[34e2c59df5c7]
|
19
|
+
|
1
20
|
2012-04-13 Mahlon E. Smith <mahlon@martini.nu>
|
2
21
|
|
3
22
|
* manual/src/tags.page:
|
4
23
|
Fix the include tag example in the manual.
|
5
|
-
[b5fcbae36ff2] [
|
24
|
+
[b5fcbae36ff2] [github/master]
|
6
25
|
|
7
26
|
2012-04-02 Michael Granger <ged@FaerieMUD.org>
|
8
27
|
|
@@ -18,7 +37,7 @@
|
|
18
37
|
|
19
38
|
* .hgtags:
|
20
39
|
Added tag v0.8.0 for changeset 5d07557a543c
|
21
|
-
[57381a550306]
|
40
|
+
[57381a550306]
|
22
41
|
|
23
42
|
* .hgsigs:
|
24
43
|
Added signature for changeset d461a2bf079d
|
data/History.rdoc
CHANGED
data/Manifest.txt
CHANGED
@@ -6,7 +6,6 @@ Rakefile
|
|
6
6
|
bin/inversion
|
7
7
|
lib/inversion.rb
|
8
8
|
lib/inversion/exceptions.rb
|
9
|
-
lib/inversion/logging.rb
|
10
9
|
lib/inversion/mixins.rb
|
11
10
|
lib/inversion/monkeypatches.rb
|
12
11
|
lib/inversion/parser.rb
|
@@ -42,7 +41,6 @@ lib/inversion/template/uriencodetag.rb
|
|
42
41
|
lib/inversion/template/yieldtag.rb
|
43
42
|
lib/inversion/tilt.rb
|
44
43
|
spec/data/sinatra/hello.inversion
|
45
|
-
spec/inversion/logging_spec.rb
|
46
44
|
spec/inversion/mixins_spec.rb
|
47
45
|
spec/inversion/monkeypatches_spec.rb
|
48
46
|
spec/inversion/parser_spec.rb
|
data/Rakefile
CHANGED
@@ -20,7 +20,8 @@ hoespec = Hoe.spec 'inversion' do
|
|
20
20
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
21
21
|
self.developer 'Mahlon E. Smith', 'mahlon@martini.nu'
|
22
22
|
|
23
|
-
self.dependency '
|
23
|
+
self.dependency 'loggability', '~> 0.0'
|
24
|
+
|
24
25
|
self.dependency 'rdoc', '~> 3.12', :development
|
25
26
|
self.dependency 'rspec', '~> 2.8', :development
|
26
27
|
self.dependency 'tilt', '~> 1.3', :development
|
data/bin/inversion
CHANGED
@@ -105,9 +105,11 @@ class Inversion::Command
|
|
105
105
|
@opts = opts
|
106
106
|
@prompt = self.class.prompt
|
107
107
|
|
108
|
-
# Configure
|
109
|
-
|
110
|
-
|
108
|
+
# Configure logging
|
109
|
+
Loggability.level = opts.debug ? :debug : :error
|
110
|
+
Loggability.format_with( :color ) if $stdin.tty?
|
111
|
+
|
112
|
+
# Configure Inversion's strictness
|
111
113
|
Inversion::Template.configure(
|
112
114
|
:ignore_unknown_tags => opts.ignore_unknown_tags,
|
113
115
|
:template_paths => opts.path,
|
data/lib/inversion.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
+
require 'loggability'
|
4
5
|
|
5
6
|
# The Inversion templating system. This module provides the namespace for all the other
|
6
7
|
# classes and modules, and contains the logging subsystem. A good place to start for
|
@@ -15,17 +16,19 @@
|
|
15
16
|
# :main: README.rdoc
|
16
17
|
#
|
17
18
|
module Inversion
|
19
|
+
extend Loggability
|
20
|
+
|
21
|
+
# Loggability API -- set up a log host for the Inversion library
|
22
|
+
log_as :inversion
|
23
|
+
|
18
24
|
|
19
25
|
warn ">>> Inversion requires Ruby 1.9.2 or later. <<<" if RUBY_VERSION < '1.9.2'
|
20
26
|
|
21
27
|
# Library version constant
|
22
|
-
VERSION = '0.
|
28
|
+
VERSION = '0.10.0'
|
23
29
|
|
24
30
|
# Version-control revision constant
|
25
|
-
REVISION = %q$Revision:
|
26
|
-
|
27
|
-
require 'inversion/logging'
|
28
|
-
extend Inversion::Logging
|
31
|
+
REVISION = %q$Revision: 9d9c49d532be $
|
29
32
|
|
30
33
|
|
31
34
|
### Get the Inversion version.
|
data/lib/inversion/mixins.rb
CHANGED
@@ -1,87 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
3
|
|
4
|
-
require 'logger'
|
5
|
-
|
6
4
|
|
7
5
|
module Inversion
|
8
6
|
|
9
|
-
# Add logging to a Inversion class. Including classes get #log and
|
10
|
-
# #log_debug methods.
|
11
|
-
#
|
12
|
-
# class MyClass
|
13
|
-
# include Inversion::Loggable
|
14
|
-
#
|
15
|
-
# def a_method
|
16
|
-
# self.log.debug "Doing a_method stuff..."
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
module Loggable
|
21
|
-
|
22
|
-
### A logging proxy class that wraps calls to the logger into calls that include
|
23
|
-
### the name of the calling class.
|
24
|
-
class ClassNameProxy # :nodoc:
|
25
|
-
|
26
|
-
### Create a new proxy for the given +klass+.
|
27
|
-
def initialize( klass, force_debug=false )
|
28
|
-
@classname = klass.name
|
29
|
-
@force_debug = force_debug
|
30
|
-
end
|
31
|
-
|
32
|
-
### Delegate debug messages to the global logger with the appropriate class name.
|
33
|
-
def debug( msg=nil, &block )
|
34
|
-
Inversion.logger.add( Logger::DEBUG, msg, @classname, &block )
|
35
|
-
end
|
36
|
-
|
37
|
-
### Delegate info messages to the global logger with the appropriate class name.
|
38
|
-
def info( msg=nil, &block )
|
39
|
-
return self.debug( msg, &block ) if @force_debug
|
40
|
-
Inversion.logger.add( Logger::INFO, msg, @classname, &block )
|
41
|
-
end
|
42
|
-
|
43
|
-
### Delegate warn messages to the global logger with the appropriate class name.
|
44
|
-
def warn( msg=nil, &block )
|
45
|
-
return self.debug( msg, &block ) if @force_debug
|
46
|
-
Inversion.logger.add( Logger::WARN, msg, @classname, &block )
|
47
|
-
end
|
48
|
-
|
49
|
-
### Delegate error messages to the global logger with the appropriate class name.
|
50
|
-
def error( msg=nil, &block )
|
51
|
-
return self.debug( msg, &block ) if @force_debug
|
52
|
-
Inversion.logger.add( Logger::ERROR, msg, @classname, &block )
|
53
|
-
end
|
54
|
-
|
55
|
-
### Delegate fatal messages to the global logger with the appropriate class name.
|
56
|
-
def fatal( msg=nil, &block )
|
57
|
-
Inversion.logger.add( Logger::FATAL, msg, @classname, &block )
|
58
|
-
end
|
59
|
-
|
60
|
-
end # ClassNameProxy
|
61
|
-
|
62
|
-
#########
|
63
|
-
protected
|
64
|
-
#########
|
65
|
-
|
66
|
-
### Copy constructor -- clear the original's log proxy.
|
67
|
-
def initialize_copy( original )
|
68
|
-
@log_proxy = @log_debug_proxy = nil
|
69
|
-
super
|
70
|
-
end
|
71
|
-
|
72
|
-
### Return the proxied logger.
|
73
|
-
def log
|
74
|
-
@log_proxy ||= ClassNameProxy.new( self.class )
|
75
|
-
end
|
76
|
-
|
77
|
-
### Return a proxied "debug" logger that ignores other level specification.
|
78
|
-
def log_debug
|
79
|
-
@log_debug_proxy ||= ClassNameProxy.new( self.class, true )
|
80
|
-
end
|
81
|
-
|
82
|
-
end # module Loggable
|
83
|
-
|
84
|
-
|
85
7
|
# Hides your class's ::new method and adds a +pure_virtual+ method generator for
|
86
8
|
# defining API methods. If subclasses of your class don't provide implementations of
|
87
9
|
# "pure_virtual" methods, NotImplementedErrors will be raised if they are called.
|
data/lib/inversion/parser.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
# encoding: utf-8
|
3
3
|
# vim: set noet nosta sw=4 ts=4 :
|
4
4
|
|
5
|
+
require 'loggability'
|
6
|
+
|
5
7
|
require 'inversion/template' unless defined?( Inversion::Template )
|
6
8
|
require 'inversion/mixins'
|
7
9
|
require 'inversion/template/textnode'
|
@@ -11,7 +13,11 @@ require 'inversion/template/endtag'
|
|
11
13
|
# This is the parser for Inversion templates. It takes template source and
|
12
14
|
# returns a tree of Inversion::Template::Node objects (if parsing is successful).
|
13
15
|
class Inversion::Parser
|
14
|
-
|
16
|
+
extend Loggability
|
17
|
+
|
18
|
+
# Loggability API -- set up logging through the Inversion module's logger
|
19
|
+
log_to :inversion
|
20
|
+
|
15
21
|
|
16
22
|
# The pattern for matching a tag opening
|
17
23
|
TAG_OPEN = /[\[<]\?/
|
@@ -157,7 +163,10 @@ class Inversion::Parser
|
|
157
163
|
# Parse state object class. State objects keep track of where in the parse tree
|
158
164
|
# new nodes should be appended, and manages inclusion.
|
159
165
|
class State
|
160
|
-
|
166
|
+
extend Loggability
|
167
|
+
|
168
|
+
#
|
169
|
+
log_to :inversion
|
161
170
|
|
162
171
|
### Create a new State object
|
163
172
|
def initialize( template, options={} )
|
@@ -1,13 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
+
require 'loggability'
|
4
5
|
require 'inversion' unless defined?( Inversion )
|
5
6
|
|
6
7
|
|
7
8
|
# An object that provides an encapsulation of the template's state while it is rendering.
|
8
9
|
class Inversion::RenderState
|
9
|
-
|
10
|
+
extend Loggability
|
10
11
|
|
12
|
+
# Loggability API -- set up logging through the Inversion module's logger
|
13
|
+
log_to :inversion
|
11
14
|
|
12
15
|
# An encapsulation of the scope in which the bodies of tags evaluate. It's
|
13
16
|
# used to provide a controlled, isolated namespace which remains the same from
|
@@ -439,7 +442,7 @@ class Inversion::RenderState
|
|
439
442
|
|
440
443
|
### Recursively copy the specified +obj+ and return the result.
|
441
444
|
def deep_copy( obj )
|
442
|
-
#
|
445
|
+
# self.log.debug "Deep copying: %p" % [ obj ]
|
443
446
|
|
444
447
|
# Handle mocks during testing
|
445
448
|
return obj if obj.class.name == 'RSpec::Mocks::Mock'
|
data/lib/inversion/template.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
+
require 'loggability'
|
4
5
|
require 'pathname'
|
5
6
|
require 'inversion' unless defined?( Inversion )
|
6
7
|
|
@@ -16,7 +17,10 @@ end
|
|
16
17
|
# source and combining the resulting node tree with a set of attributes that
|
17
18
|
# can be used to populate it when rendered.
|
18
19
|
class Inversion::Template
|
19
|
-
|
20
|
+
extend Loggability
|
21
|
+
|
22
|
+
# Loggability API -- set up logging through the Inversion module's logger
|
23
|
+
log_to :inversion
|
20
24
|
|
21
25
|
# Configurability support -- load template configuration from the 'templates' section
|
22
26
|
# of the config.
|
@@ -32,8 +32,7 @@ require 'inversion/template/rescuetag'
|
|
32
32
|
# <?end?>
|
33
33
|
#
|
34
34
|
class Inversion::Template::BeginTag < Inversion::Template::Tag
|
35
|
-
include Inversion::
|
36
|
-
Inversion::Template::ContainerTag
|
35
|
+
include Inversion::Template::ContainerTag
|
37
36
|
|
38
37
|
|
39
38
|
### Initialize a new BeginTag.
|
@@ -31,8 +31,7 @@ require 'inversion/template/tag'
|
|
31
31
|
# :TODO: Finish the tag_pattern docs: placeholders, regex limitations, etc.
|
32
32
|
#
|
33
33
|
class Inversion::Template::CodeTag < Inversion::Template::Tag
|
34
|
-
include Inversion::
|
35
|
-
Inversion::AbstractClass
|
34
|
+
include Inversion::AbstractClass
|
36
35
|
|
37
36
|
|
38
37
|
### A subclass of Ripper::TokenPattern that binds matches to the beginning and
|
@@ -17,8 +17,8 @@ require 'inversion/template/containertag'
|
|
17
17
|
# <?end comment ?>
|
18
18
|
#
|
19
19
|
class Inversion::Template::CommentTag < Inversion::Template::Tag
|
20
|
-
include Inversion::
|
21
|
-
|
20
|
+
include Inversion::Template::ContainerTag
|
21
|
+
|
22
22
|
|
23
23
|
######
|
24
24
|
public
|
@@ -26,8 +26,7 @@ require 'inversion/template/tag'
|
|
26
26
|
#
|
27
27
|
#
|
28
28
|
class Inversion::Template::ConfigTag < Inversion::Template::Tag
|
29
|
-
include Inversion::
|
30
|
-
Inversion::HashUtilities
|
29
|
+
include Inversion::HashUtilities
|
31
30
|
|
32
31
|
|
33
32
|
### Create a new ConfigTag with the specified +body+.
|
@@ -18,8 +18,6 @@ require 'inversion/template/tag'
|
|
18
18
|
# <?end?>
|
19
19
|
#
|
20
20
|
class Inversion::Template::ElseTag < Inversion::Template::Tag
|
21
|
-
include Inversion::Loggable
|
22
|
-
|
23
21
|
|
24
22
|
### Overridden to default body to nothing, and raise an error if it has one.
|
25
23
|
def initialize( body='', linenum=nil, colnum=nil ) # :notnew:
|
@@ -7,8 +7,6 @@ require 'inversion/template/tag' unless defined?( Inversion::Template::Tag )
|
|
7
7
|
|
8
8
|
# Closing tag class
|
9
9
|
class Inversion::Template::EndTag < Inversion::Template::Tag
|
10
|
-
include Inversion::Loggable
|
11
|
-
|
12
10
|
|
13
11
|
### Overridden to provide a default +body+.
|
14
12
|
def initialize( body='', linenum=nil, colnum=nil )
|
@@ -26,8 +26,7 @@ require 'inversion/template/containertag'
|
|
26
26
|
# <?end ?>
|
27
27
|
#
|
28
28
|
class Inversion::Template::ForTag < Inversion::Template::CodeTag
|
29
|
-
include Inversion::
|
30
|
-
Inversion::Template::ContainerTag
|
29
|
+
include Inversion::Template::ContainerTag
|
31
30
|
|
32
31
|
# <?for var in attribute ?>
|
33
32
|
# <?for var in attribute.methodchain ?>
|
@@ -16,8 +16,7 @@ require 'inversion/template/containertag'
|
|
16
16
|
# <?if obj.method ?>...<?end?>
|
17
17
|
#
|
18
18
|
class Inversion::Template::IfTag < Inversion::Template::AttrTag
|
19
|
-
include Inversion::
|
20
|
-
Inversion::Template::ContainerTag
|
19
|
+
include Inversion::Template::ContainerTag
|
21
20
|
|
22
21
|
# Inherits AttrTag's tag patterns
|
23
22
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
+
require 'loggability'
|
5
|
+
|
4
6
|
require 'inversion/mixins'
|
5
7
|
require 'inversion/template' unless defined?( Inversion::Template )
|
6
8
|
|
@@ -11,8 +13,12 @@ require 'inversion/template' unless defined?( Inversion::Template )
|
|
11
13
|
# This class is abstract; it just defines the API that other nodes
|
12
14
|
# are expected to implement.
|
13
15
|
class Inversion::Template::Node
|
16
|
+
extend Loggability
|
14
17
|
include Inversion::AbstractClass
|
15
18
|
|
19
|
+
# Loggability API -- set up logging through the Inversion module's logger
|
20
|
+
log_to :inversion
|
21
|
+
|
16
22
|
|
17
23
|
### Create a new TextNode with the specified +source+.
|
18
24
|
def initialize( body, linenum=nil, colnum=nil )
|
@@ -9,7 +9,7 @@ require 'inversion/template/tag'
|
|
9
9
|
# This tag adds a logical switch to a BeginTag. If rendering any of the BeginTag's nodes raises
|
10
10
|
# an exception of the type specified by the RescueTag, the nodes following the RescueTag are
|
11
11
|
# rendered instead.
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# == Syntax
|
14
14
|
#
|
15
15
|
# <?begin ?>
|
@@ -19,14 +19,12 @@ require 'inversion/template/tag'
|
|
19
19
|
# <?rescue DatabaseError => err ?>
|
20
20
|
# Oh no!! I can't talk to the database for some reason. The
|
21
21
|
# error was as follows:
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# <?attr err.message ?>
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# <?end?>
|
26
26
|
#
|
27
27
|
class Inversion::Template::RescueTag < Inversion::Template::Tag
|
28
|
-
include Inversion::Loggable
|
29
|
-
|
30
28
|
|
31
29
|
### Overridden to default body to nothing, and raise an error if it has one.
|
32
30
|
def initialize( body='', linenum=nil, colnum=nil ) # :notnew:
|