inversion 1.0.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +46 -0
- data/Manifest.txt +0 -1
- data/README.rdoc +10 -4
- data/Rakefile +4 -90
- data/bin/inversion +3 -1
- data/lib/inversion.rb +4 -4
- data/lib/inversion/command.rb +2 -1
- data/lib/inversion/exceptions.rb +4 -1
- data/lib/inversion/mixins.rb +30 -4
- data/lib/inversion/monkeypatches.rb +3 -2
- data/lib/inversion/parser.rb +2 -2
- data/lib/inversion/renderstate.rb +2 -1
- data/lib/inversion/sinatra.rb +4 -1
- data/lib/inversion/template.rb +3 -3
- data/lib/inversion/template/attrtag.rb +8 -6
- data/lib/inversion/template/begintag.rb +3 -1
- data/lib/inversion/template/calltag.rb +3 -1
- data/lib/inversion/template/codetag.rb +13 -2
- data/lib/inversion/template/commenttag.rb +3 -1
- data/lib/inversion/template/configtag.rb +10 -2
- data/lib/inversion/template/containertag.rb +2 -2
- data/lib/inversion/template/defaulttag.rb +4 -2
- data/lib/inversion/template/elsetag.rb +3 -1
- data/lib/inversion/template/elsiftag.rb +36 -7
- data/lib/inversion/template/endtag.rb +3 -3
- data/lib/inversion/template/escapetag.rb +3 -1
- data/lib/inversion/template/fortag.rb +14 -8
- data/lib/inversion/template/fragmenttag.rb +3 -1
- data/lib/inversion/template/iftag.rb +37 -8
- data/lib/inversion/template/importtag.rb +4 -2
- data/lib/inversion/template/includetag.rb +3 -1
- data/lib/inversion/template/node.rb +2 -1
- data/lib/inversion/template/pptag.rb +4 -2
- data/lib/inversion/template/publishtag.rb +3 -1
- data/lib/inversion/template/rescuetag.rb +3 -1
- data/lib/inversion/template/subscribetag.rb +3 -1
- data/lib/inversion/template/tag.rb +4 -4
- data/lib/inversion/template/textnode.rb +3 -1
- data/lib/inversion/template/timedeltatag.rb +16 -3
- data/lib/inversion/template/unlesstag.rb +31 -3
- data/lib/inversion/template/uriencodetag.rb +5 -5
- data/lib/inversion/template/yieldtag.rb +3 -1
- data/lib/inversion/tilt.rb +3 -1
- data/spec/helpers.rb +3 -0
- data/spec/inversion/mixins_spec.rb +14 -14
- data/spec/inversion/renderstate_spec.rb +0 -9
- data/spec/inversion/template/codetag_spec.rb +41 -1
- data/spec/inversion/template/elsiftag_spec.rb +25 -0
- data/spec/inversion/template/fortag_spec.rb +34 -2
- data/spec/inversion/template/iftag_spec.rb +11 -0
- data/spec/inversion/template/pptag_spec.rb +2 -0
- data/spec/inversion/template/timedeltatag_spec.rb +7 -0
- data/spec/inversion/template/unlesstag_spec.rb +11 -0
- data/spec/inversion/template_spec.rb +2 -6
- metadata +84 -121
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -2078
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: de95b723b4e1d977b915f72d99659c4b73f6ca222afe91b4536c5e3e2c12bd73
|
4
|
+
data.tar.gz: 62b09f236668d37f6e33757d7cc7db174374ae5663ad42c6bd20aa9b55c40835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ad4969a736b028863e67d56e5b85b0ad887dcbba2313d9fe90f65f4a982216285c0dc988ba7852f23b157281395ad3dc43c78864fab233f82510d77a49bf284
|
7
|
+
data.tar.gz: 5c50d1f6636a0de6c65616a4996806d20bf50ba26d4da7295edf6d7d7e4eb6fdeb1bbff6b8148bd408137ceaf4a8ed465d87ba6e2fc4ba80f2df37d7d2224ef5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,49 @@
|
|
1
|
+
= Release History for inversion
|
2
|
+
|
3
|
+
---
|
4
|
+
|
5
|
+
== v1.3.1 [2020-09-29] Michael Granger <ged@faeriemud.org>
|
6
|
+
|
7
|
+
Improvements:
|
8
|
+
|
9
|
+
- Only use SafeYAML if it's already loaded
|
10
|
+
- Handle HTML encoding for uriencoding tag ourselves
|
11
|
+
|
12
|
+
|
13
|
+
== v1.3.0 [2020-04-08] Mahlon E. Smith <mahlon@martini.nu>
|
14
|
+
|
15
|
+
- Use safe_yaml when deserializing config tag contents.
|
16
|
+
- Un-hoeify.
|
17
|
+
- Updates for Ruby 2.7.
|
18
|
+
|
19
|
+
|
20
|
+
== v1.2.0 [2019-05-14] Michael Granger <ged@FaerieMUD.org>
|
21
|
+
|
22
|
+
Enhancements:
|
23
|
+
|
24
|
+
- Add frozen string literal support (Ruby 2.6+)
|
25
|
+
- Allow the timedelta tag to accept hash arguments and make
|
26
|
+
'decorators' optional.
|
27
|
+
|
28
|
+
|
29
|
+
== v1.1.1 [2017-11-13] Michael Granger <ged@FaerieMUD.org>
|
30
|
+
|
31
|
+
Bugfixes:
|
32
|
+
|
33
|
+
- Yield subarrays in `each` tags when there's only one block argument (#3).
|
34
|
+
|
35
|
+
|
36
|
+
== v1.1.0 [2017-08-17] Mahlon E. Smith <mahlon@martini.nu>
|
37
|
+
|
38
|
+
Enhancements:
|
39
|
+
|
40
|
+
- Allow the use of the '!' operator in conditional tags, logically
|
41
|
+
inverting the evaluated body.
|
42
|
+
|
43
|
+
- Provide a method for children tags to inherit and append to their
|
44
|
+
parents matcher patterns.
|
45
|
+
|
46
|
+
|
1
47
|
== v1.0.0 [2017-01-16] Michael Granger <ged@FaerieMUD.org>
|
2
48
|
|
3
49
|
Mark as stable, update dependencies.
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
= inversion
|
2
2
|
|
3
|
-
home
|
4
|
-
code
|
5
|
-
github
|
3
|
+
home:: https://hg.sr.ht/~ged/Inversion
|
4
|
+
code:: https://hg.sr.ht/~ged/Inversion/browse
|
5
|
+
github:: https://github.com/ged/inversion
|
6
|
+
docs:: http://deveiate.org/code/Inversion
|
6
7
|
|
7
8
|
|
8
9
|
== Description
|
@@ -116,10 +117,15 @@ After checking out the source, run:
|
|
116
117
|
This task will install any missing dependencies, run the tests/specs,
|
117
118
|
and generate the API documentation.
|
118
119
|
|
120
|
+
== Authors
|
121
|
+
|
122
|
+
* Michael Granger <ged@faeriemud.org>
|
123
|
+
* Mahlon E. Smith <mahlon@martini.nu>
|
124
|
+
|
119
125
|
|
120
126
|
== License
|
121
127
|
|
122
|
-
Copyright © 2011-
|
128
|
+
Copyright © 2011-2020, Michael Granger and Mahlon E. Smith
|
123
129
|
All rights reserved.
|
124
130
|
|
125
131
|
Redistribution and use in source and binary forms, with or without
|
data/Rakefile
CHANGED
@@ -1,93 +1,7 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require 'rake/
|
4
|
-
require 'rdoc/task'
|
4
|
+
require 'rake/deveiate'
|
5
5
|
|
6
|
-
|
7
|
-
require 'hoe'
|
8
|
-
rescue LoadError
|
9
|
-
abort "This Rakefile requires hoe (gem install hoe)"
|
10
|
-
end
|
6
|
+
Rake::DevEiate.setup( 'inversion' )
|
11
7
|
|
12
|
-
GEMSPEC = 'inversion.gemspec'
|
13
|
-
|
14
|
-
Hoe.plugin :mercurial
|
15
|
-
Hoe.plugin :publish
|
16
|
-
Hoe.plugin :signing
|
17
|
-
|
18
|
-
Hoe.plugins.delete :rubyforge
|
19
|
-
|
20
|
-
hoespec = Hoe.spec 'inversion' do
|
21
|
-
self.readme_file = 'README.rdoc'
|
22
|
-
self.history_file = 'History.rdoc'
|
23
|
-
self.extra_rdoc_files << 'README.rdoc' << 'History.rdoc'
|
24
|
-
self.license "BSD"
|
25
|
-
|
26
|
-
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
27
|
-
self.developer 'Mahlon E. Smith', 'mahlon@martini.nu'
|
28
|
-
|
29
|
-
self.dependency 'loggability', '~> 0.12'
|
30
|
-
|
31
|
-
self.dependency 'highline', '~> 1.6', :development
|
32
|
-
self.dependency 'hoe-deveiate', '~> 0.5', :development
|
33
|
-
self.dependency 'rack-test', '~> 0.6', :development
|
34
|
-
self.dependency 'simplecov', '~> 0.8', :development
|
35
|
-
self.dependency 'sinatra', '~> 1.4', :development
|
36
|
-
self.dependency 'tilt', '~> 1.4', :development
|
37
|
-
self.dependency 'sysexits', '~> 1.0', :development
|
38
|
-
self.dependency 'trollop', '~> 2.0', :development
|
39
|
-
self.dependency 'rdoc-generator-fivefish', '~> 0', :development
|
40
|
-
self.dependency 'configurability', '~> 3.1', :development
|
41
|
-
|
42
|
-
self.require_ruby_version( '>=2.2.0' )
|
43
|
-
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
44
|
-
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
45
|
-
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
46
|
-
end
|
47
|
-
|
48
|
-
ENV['VERSION'] ||= hoespec.spec.version.to_s
|
49
|
-
|
50
|
-
# Ensure the specs pass before checking in
|
51
|
-
task 'hg:precheckin' => [:check_history, :check_manifest, :gemspec, :spec]
|
52
|
-
|
53
|
-
if Rake::Task.task_defined?( '.gemtest' )
|
54
|
-
Rake::Task['.gemtest'].clear
|
55
|
-
task '.gemtest' do
|
56
|
-
$stderr.puts "Not including a .gemtest until I'm confident the test suite is idempotent."
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
desc "Build a coverage report"
|
61
|
-
task :coverage do
|
62
|
-
ENV["COVERAGE"] = 'yes'
|
63
|
-
Rake::Task[:spec].invoke
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
# Use the fivefish formatter for docs generated from development checkout
|
68
|
-
if File.directory?( '.hg' )
|
69
|
-
require 'rdoc/task'
|
70
|
-
|
71
|
-
Rake::Task[ 'docs' ].clear
|
72
|
-
RDoc::Task.new( 'docs' ) do |rdoc|
|
73
|
-
rdoc.main = "README.rdoc"
|
74
|
-
rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
|
75
|
-
rdoc.generator = :fivefish
|
76
|
-
rdoc.title = "Inversion Templating"
|
77
|
-
rdoc.rdoc_dir = 'doc'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
task :gemspec => GEMSPEC
|
82
|
-
file GEMSPEC => __FILE__
|
83
|
-
task GEMSPEC do |task|
|
84
|
-
spec = $hoespec.spec
|
85
|
-
spec.files.delete( '.gemtest' )
|
86
|
-
spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
|
87
|
-
File.open( task.name, 'w' ) do |fh|
|
88
|
-
fh.write( spec.to_ruby )
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
CLOBBER.include( GEMSPEC.to_s )
|
93
|
-
task :default => :gemspec
|
data/bin/inversion
CHANGED
data/lib/inversion.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#
|
2
|
+
# frozen_string_literal: true
|
3
3
|
# vim: set noet nosta sw=4 ts=4 :
|
4
4
|
|
5
5
|
require 'loggability'
|
@@ -23,13 +23,13 @@ module Inversion
|
|
23
23
|
log_as :inversion
|
24
24
|
|
25
25
|
|
26
|
-
warn ">>> Inversion requires Ruby 2.
|
26
|
+
warn ">>> Inversion requires Ruby 2.4.0 or later. <<<" if RUBY_VERSION < '2.4.0'
|
27
27
|
|
28
28
|
# Library version constant
|
29
|
-
VERSION = '1.
|
29
|
+
VERSION = '1.3.1'
|
30
30
|
|
31
31
|
# Version-control revision constant
|
32
|
-
REVISION = %q$Revision
|
32
|
+
REVISION = %q$Revision$
|
33
33
|
|
34
34
|
|
35
35
|
### Get the Inversion version.
|
data/lib/inversion/command.rb
CHANGED
data/lib/inversion/exceptions.rb
CHANGED
data/lib/inversion/mixins.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
# vim: set noet nosta sw=4 ts=4 :
|
3
4
|
|
4
5
|
require 'tempfile'
|
5
6
|
|
@@ -87,7 +88,7 @@ module Inversion
|
|
87
88
|
|
88
89
|
|
89
90
|
### Return a duplicate of the given +hash+ with its identifier-like keys
|
90
|
-
###
|
91
|
+
### transformed into symbols from whatever they were before.
|
91
92
|
###
|
92
93
|
### symbolhash = symbolify_keys( stringhash )
|
93
94
|
###
|
@@ -95,7 +96,7 @@ module Inversion
|
|
95
96
|
newhash = {}
|
96
97
|
|
97
98
|
hash.each do |key,val|
|
98
|
-
keysym = key.to_s.
|
99
|
+
keysym = key.to_s.to_sym
|
99
100
|
|
100
101
|
if val.is_a?( Hash )
|
101
102
|
newhash[ keysym ] = symbolify_keys( val )
|
@@ -129,6 +130,20 @@ module Inversion
|
|
129
130
|
# The fallback escape format
|
130
131
|
DEFAULT_ESCAPE_FORMAT = :none
|
131
132
|
|
133
|
+
# Unreserved characters from section 2.3 of RFC 3986
|
134
|
+
# ALPHA / DIGIT / "-" / "." / "_" / "~"
|
135
|
+
URI_ENCODED_CHARACTERS = /[^\w\-\.~]/
|
136
|
+
|
137
|
+
|
138
|
+
### Inclusion callback; add Loggability if it isn't already present
|
139
|
+
def self::included( mod )
|
140
|
+
super
|
141
|
+
unless mod < Loggability
|
142
|
+
mod.extend( Loggability )
|
143
|
+
mod.log_to( :inversion )
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
132
147
|
|
133
148
|
### Escape the +output+ using the format specified by the given +render_state+'s config.
|
134
149
|
def escape( output, render_state )
|
@@ -153,6 +168,17 @@ module Inversion
|
|
153
168
|
gsub( />/, '>' )
|
154
169
|
end
|
155
170
|
|
171
|
+
|
172
|
+
### Escape the given +output+ using the encoding specified in RFC3986 (URIs)
|
173
|
+
def escape_uri( output )
|
174
|
+
return output.to_s.gsub( URI_ENCODED_CHARACTERS ) do |m|
|
175
|
+
bytes = m[ 0 ].each_byte
|
176
|
+
bytes.inject( String.new ) do |buf, char|
|
177
|
+
buf + sprintf( '%%%0X', char )
|
178
|
+
end
|
179
|
+
end.force_encoding( Encoding::US_ASCII )
|
180
|
+
end
|
181
|
+
|
156
182
|
end # Escaping
|
157
183
|
|
158
184
|
|
data/lib/inversion/parser.rb
CHANGED
data/lib/inversion/sinatra.rb
CHANGED
data/lib/inversion/template.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
# vim: set noet nosta sw=4 ts=4 :
|
3
4
|
|
4
5
|
require 'loggability'
|
@@ -200,7 +201,6 @@ class Inversion::Template
|
|
200
201
|
else
|
201
202
|
tmpl.read
|
202
203
|
end
|
203
|
-
source.untaint
|
204
204
|
|
205
205
|
# Load the instance and set the path to the source
|
206
206
|
template = self.new( source, parsestate, opts )
|
@@ -344,7 +344,7 @@ class Inversion::Template
|
|
344
344
|
### Render the template, optionally passing a render state (if, for example, the
|
345
345
|
### template is being rendered inside another template).
|
346
346
|
def render( parentstate=nil, &block )
|
347
|
-
self.log.info "rendering template %#x" % [ self.object_id
|
347
|
+
self.log.info "rendering template %#x" % [ self.object_id * 2 ]
|
348
348
|
opts = self.options
|
349
349
|
opts.merge!( parentstate.options ) if parentstate
|
350
350
|
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
# vim: set noet nosta sw=4 ts=4 :
|
3
4
|
|
5
|
+
require 'inversion/template' unless defined?( Inversion::Template )
|
4
6
|
require 'inversion/template/codetag'
|
5
7
|
|
6
8
|
# Inversion attribute tag.
|
@@ -17,7 +19,7 @@ class Inversion::Template::AttrTag < Inversion::Template::CodeTag
|
|
17
19
|
# <?attr foo ?>
|
18
20
|
tag_pattern '$(ident)' do |tag, match|
|
19
21
|
tag.send( :log ).debug " Identifier is: %p" % [ match.string(1) ]
|
20
|
-
tag.name = match.string( 1 ).
|
22
|
+
tag.name = match.string( 1 ).to_sym
|
21
23
|
end
|
22
24
|
|
23
25
|
# <?attr "%s" % foo ?>
|
@@ -26,12 +28,12 @@ class Inversion::Template::AttrTag < Inversion::Template::CodeTag
|
|
26
28
|
raise Inversion::ParseError, "expected '%%', got %p instead" % [ op ] unless op == '%'
|
27
29
|
|
28
30
|
tag.format = match.string( 1 )
|
29
|
-
tag.name = match.string( 3 ).
|
31
|
+
tag.name = match.string( 3 ).to_sym
|
30
32
|
end
|
31
33
|
|
32
34
|
# <?attr foo.methodchain ?>
|
33
35
|
tag_pattern '$(ident) $( .+ )' do |tag, match|
|
34
|
-
tag.name = match.string( 1 ).
|
36
|
+
tag.name = match.string( 1 ).to_sym
|
35
37
|
tag.methodchain = match.string( 2 )
|
36
38
|
end
|
37
39
|
|
@@ -41,7 +43,7 @@ class Inversion::Template::AttrTag < Inversion::Template::CodeTag
|
|
41
43
|
raise Inversion::ParseError, "expected '%%', got %p instead" % [ op ] unless op == '%'
|
42
44
|
|
43
45
|
tag.format = match.string( 1 )
|
44
|
-
tag.name = match.string( 3 ).
|
46
|
+
tag.name = match.string( 3 ).to_sym
|
45
47
|
tag.methodchain = match.string( 4 )
|
46
48
|
end
|
47
49
|
|
@@ -58,7 +60,7 @@ class Inversion::Template::AttrTag < Inversion::Template::CodeTag
|
|
58
60
|
super
|
59
61
|
|
60
62
|
# Add an identifier for the tag name
|
61
|
-
self.identifiers << self.name.
|
63
|
+
self.identifiers << self.name.to_sym
|
62
64
|
end
|
63
65
|
|
64
66
|
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
# vim: set noet nosta sw=4 ts=4 :
|
3
4
|
|
5
|
+
require 'inversion/template' unless defined?( Inversion::Template )
|
4
6
|
require 'inversion/mixins'
|
5
7
|
require 'inversion/template/attrtag'
|
6
8
|
require 'inversion/template/containertag'
|