inversion 1.0.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/History.rdoc +46 -0
  5. data/Manifest.txt +0 -1
  6. data/README.rdoc +10 -4
  7. data/Rakefile +4 -90
  8. data/bin/inversion +3 -1
  9. data/lib/inversion.rb +4 -4
  10. data/lib/inversion/command.rb +2 -1
  11. data/lib/inversion/exceptions.rb +4 -1
  12. data/lib/inversion/mixins.rb +30 -4
  13. data/lib/inversion/monkeypatches.rb +3 -2
  14. data/lib/inversion/parser.rb +2 -2
  15. data/lib/inversion/renderstate.rb +2 -1
  16. data/lib/inversion/sinatra.rb +4 -1
  17. data/lib/inversion/template.rb +3 -3
  18. data/lib/inversion/template/attrtag.rb +8 -6
  19. data/lib/inversion/template/begintag.rb +3 -1
  20. data/lib/inversion/template/calltag.rb +3 -1
  21. data/lib/inversion/template/codetag.rb +13 -2
  22. data/lib/inversion/template/commenttag.rb +3 -1
  23. data/lib/inversion/template/configtag.rb +10 -2
  24. data/lib/inversion/template/containertag.rb +2 -2
  25. data/lib/inversion/template/defaulttag.rb +4 -2
  26. data/lib/inversion/template/elsetag.rb +3 -1
  27. data/lib/inversion/template/elsiftag.rb +36 -7
  28. data/lib/inversion/template/endtag.rb +3 -3
  29. data/lib/inversion/template/escapetag.rb +3 -1
  30. data/lib/inversion/template/fortag.rb +14 -8
  31. data/lib/inversion/template/fragmenttag.rb +3 -1
  32. data/lib/inversion/template/iftag.rb +37 -8
  33. data/lib/inversion/template/importtag.rb +4 -2
  34. data/lib/inversion/template/includetag.rb +3 -1
  35. data/lib/inversion/template/node.rb +2 -1
  36. data/lib/inversion/template/pptag.rb +4 -2
  37. data/lib/inversion/template/publishtag.rb +3 -1
  38. data/lib/inversion/template/rescuetag.rb +3 -1
  39. data/lib/inversion/template/subscribetag.rb +3 -1
  40. data/lib/inversion/template/tag.rb +4 -4
  41. data/lib/inversion/template/textnode.rb +3 -1
  42. data/lib/inversion/template/timedeltatag.rb +16 -3
  43. data/lib/inversion/template/unlesstag.rb +31 -3
  44. data/lib/inversion/template/uriencodetag.rb +5 -5
  45. data/lib/inversion/template/yieldtag.rb +3 -1
  46. data/lib/inversion/tilt.rb +3 -1
  47. data/spec/helpers.rb +3 -0
  48. data/spec/inversion/mixins_spec.rb +14 -14
  49. data/spec/inversion/renderstate_spec.rb +0 -9
  50. data/spec/inversion/template/codetag_spec.rb +41 -1
  51. data/spec/inversion/template/elsiftag_spec.rb +25 -0
  52. data/spec/inversion/template/fortag_spec.rb +34 -2
  53. data/spec/inversion/template/iftag_spec.rb +11 -0
  54. data/spec/inversion/template/pptag_spec.rb +2 -0
  55. data/spec/inversion/template/timedeltatag_spec.rb +7 -0
  56. data/spec/inversion/template/unlesstag_spec.rb +11 -0
  57. data/spec/inversion/template_spec.rb +2 -6
  58. metadata +84 -121
  59. metadata.gz.sig +0 -0
  60. data/ChangeLog +0 -2078
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f4b8da84f00dd67a57f9f261339c2f8fd0dad397
4
- data.tar.gz: 21dbe5879f682b3b5b4a8c955bc48619cd6636ab
2
+ SHA256:
3
+ metadata.gz: de95b723b4e1d977b915f72d99659c4b73f6ca222afe91b4536c5e3e2c12bd73
4
+ data.tar.gz: 62b09f236668d37f6e33757d7cc7db174374ae5663ad42c6bd20aa9b55c40835
5
5
  SHA512:
6
- metadata.gz: 586cf26085d8dc43c9034c686428009ba5d55d12c9c8bdeb2ad9a888aa8a8b5b5eefb305a0be3485b74d1d3e7a08d14ec9ac9e0a668ddc412f547883be426ca4
7
- data.tar.gz: 7c5995c50244a22c035242a5363901fb110ac84fc541e6feea4ca172a954598e570ca0b75b11a452fe8d448f6330496cd009fcabe42189398720d979b2fd8b9d
6
+ metadata.gz: 1ad4969a736b028863e67d56e5b85b0ad887dcbba2313d9fe90f65f4a982216285c0dc988ba7852f23b157281395ad3dc43c78864fab233f82510d77a49bf284
7
+ data.tar.gz: 5c50d1f6636a0de6c65616a4996806d20bf50ba26d4da7295edf6d7d7e4eb6fdeb1bbff6b8148bd408137ceaf4a8ed465d87ba6e2fc4ba80f2df37d7d2224ef5
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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.
@@ -1,4 +1,3 @@
1
- ChangeLog
2
1
  Examples.rdoc
3
2
  GettingStarted.rdoc
4
3
  Guide.rdoc
@@ -1,8 +1,9 @@
1
1
  = inversion
2
2
 
3
- home :: http://deveiate.org/projects/Inversion
4
- code :: http://repo.deveiate.org/Inversion
5
- github :: http://github.com/ged/inversion.git
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-2015, Michael Granger and Mahlon E. Smith
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
- #!/usr/bin/env rake
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
 
3
- require 'rake/clean'
4
- require 'rdoc/task'
4
+ require 'rake/deveiate'
5
5
 
6
- begin
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
@@ -1,4 +1,6 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+ # vim: set noet nosta sw=4 ts=4 :
2
4
 
3
5
  require 'inversion'
4
6
  require 'inversion/command'
@@ -1,5 +1,5 @@
1
1
  # -*- ruby -*-
2
- #encoding: utf-8
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.2.0 or later. <<<" if RUBY_VERSION < '2.2.0'
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.0.0'
29
+ VERSION = '1.3.1'
30
30
 
31
31
  # Version-control revision constant
32
- REVISION = %q$Revision: a4b621e66915 $
32
+ REVISION = %q$Revision$
33
33
 
34
34
 
35
35
  ### Get the Inversion version.
@@ -1,5 +1,6 @@
1
1
  # -*- ruby -*-
2
- #encoding: utf-8
2
+ # frozen_string_literal: true
3
+ # vim: set noet nosta sw=4 ts=4 :
3
4
 
4
5
  require 'logger'
5
6
  require 'trollop'
@@ -1,6 +1,9 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
  # vim: set noet nosta sw=4 ts=4 :
3
4
 
5
+ require 'inversion' unless defined?( Inversion )
6
+
4
7
  #--
5
8
  module Inversion
6
9
 
@@ -1,5 +1,6 @@
1
- #!/usr/bin/env ruby
2
- # vim: set nosta noet ts=4 sw=4:
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
- ### untainted and transformed into symbols from whatever they were before.
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.dup.untaint.to_sym
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( />/, '&gt;' )
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
 
@@ -1,5 +1,6 @@
1
- #!/usr/bin/env ruby
2
- # vim: set nosta noet ts=4 sw=4:
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+ # vim: set noet nosta sw=4 ts=4 :
3
4
 
4
5
  require 'inversion' unless defined?( Inversion )
5
6
  require 'ripper'
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
3
  # vim: set noet nosta sw=4 ts=4 :
4
4
 
5
5
  require 'loggability'
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
2
3
  # vim: set noet nosta sw=4 ts=4 :
3
4
 
4
5
  require 'loggability'
@@ -1,4 +1,7 @@
1
- #!/usr/bin/env ruby
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+ # vim: set noet nosta sw=4 ts=4 :
4
+
2
5
 
3
6
  begin
4
7
  require 'inversion/tilt'
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
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/2 ]
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
- #!/usr/bin/env ruby
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 ).untaint.to_sym
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 ).untaint.to_sym
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 ).untaint.to_sym
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 ).untaint.to_sym
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.untaint.to_sym
63
+ self.identifiers << self.name.to_sym
62
64
  end
63
65
 
64
66
 
@@ -1,6 +1,8 @@
1
- #!/usr/bin/env ruby
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'
@@ -1,6 +1,8 @@
1
- #!/usr/bin/env ruby
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/attrtag'
5
7
 
6
8
  # Inversion call tag.