inversion 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddedafd07e49192ced4ff5ad6cde6e4652665133
4
- data.tar.gz: 1e3f6a0aaec50744c52103d3f4fccdbd2d6ca0f0
3
+ metadata.gz: 4983f0e8917f4a40d760bc7f77214c2732d04bcb
4
+ data.tar.gz: 5fd44317d690978ea3ebca07c9a6fcd4b3623ee5
5
5
  SHA512:
6
- metadata.gz: 38b0a7a2abcffe7c3efdd9cd69d3c5e06f86fc58d26ecc4361fcea753881d392bf661bbc04d7d37d591e7cf0b970a8756892d59cad15a1f2b80a3ba73fc01474
7
- data.tar.gz: 9ba61dbd363fab4f4339378f1062d7341c39ce39f2ab7609c08ee4bb2399fc34008e1750b20ea4ca0f7b8754031d475e0d201518acb7b5c0f8e1d8385196a1ec
6
+ metadata.gz: a6d6826555de328206231211b8d193fffe41854375c39eb25cf3dfb342d3412634c1e6de4d8dd850038246bee93e1ebc6a35cdd1f92ca18093baf87b00109ef6
7
+ data.tar.gz: 22eb288a86e2852b67ef94c097d9ecfc3ce26e85fb1ee58eeb964d1af481659a360856ddcc5a87a2e98f7faa1157bab1efa62b9b95a686ccb06022fcb309b408
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == v0.15.0 [2014-11-24] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Add a mechanism to allow tags to extend the template.
4
+
5
+
1
6
  == v0.14.0 [2014-11-05] Michael Granger <ged@FaerieMUD.org>
2
7
 
3
8
  - Add the fragment tag and docs
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env rake
2
2
 
3
+ require 'rake/clean'
3
4
  require 'rdoc/task'
4
5
 
5
6
  begin
@@ -8,6 +9,8 @@ rescue LoadError
8
9
  abort "This Rakefile requires hoe (gem install hoe)"
9
10
  end
10
11
 
12
+ GEMSPEC = 'inversion.gemspec'
13
+
11
14
  Hoe.plugin :mercurial
12
15
  Hoe.plugin :signing
13
16
  Hoe.plugin :manualgen
@@ -62,12 +65,29 @@ task :coverage do
62
65
  end
63
66
 
64
67
 
65
- Rake::Task[ 'docs' ].clear
66
- RDoc::Task.new( 'docs' ) do |rdoc|
68
+ # Use the fivefish formatter for docs generated from development checkout
69
+ if File.directory?( '.hg' )
70
+ require 'rdoc/task'
71
+
72
+ Rake::Task[ 'docs' ].clear
73
+ RDoc::Task.new( 'docs' ) do |rdoc|
67
74
  rdoc.main = "README.rdoc"
68
75
  rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
69
76
  rdoc.generator = :fivefish
70
77
  rdoc.rdoc_dir = 'doc'
78
+ end
71
79
  end
72
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}.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
73
91
 
92
+ CLOBBER.include( GEMSPEC.to_s )
93
+ task :default => :gemspec
data/Tags.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Built-In Tags
2
2
 
3
- Inversion's tags support the Pluggability[http://rubygems.org/gems/pluggability] API, allowing for the easy addition of {custom tags}[@Custom+Tags], but it comes with a number of built-in ones too.
3
+ Inversion's tags support the Pluggability[http://rubygems.org/gems/pluggability] API, allowing for the easy addition of {custom tags}[#label-Custom+Tags], but it comes with a number of built-in ones too.
4
4
 
5
5
 
6
6
  == Tag Syntax
@@ -27,7 +27,7 @@ These tags work as you'd expect from their ruby counterparts.
27
27
  The +begin+ section of the template to be rendered only if no exceptions are raised while it's
28
28
  being rendered. If an exception is raised, it is checked against any +rescue+ sections, and the
29
29
  first with a matching exception is rendered instead. If no +rescue+ block is found, the exception
30
- is handled by the configured exception behavior for the template (see options[Templates@Template+Options]).
30
+ is handled by the configured exception behavior for the template (see Inversion::Template@Template+Options).
31
31
 
32
32
  <?begin ?><?call employees.length ?><?end?>
33
33
 
@@ -559,3 +559,26 @@ The output is escaped according to the current setting of the {:escape_format}[r
559
559
  ctime=2011-08-12 08:43:15 -0700 (1313163795)&gt;</div>
560
560
  </div>
561
561
 
562
+
563
+ == Custom Tags
564
+
565
+ We have a lot of documentation work to do for this still, but the basics are:
566
+
567
+ * Create a file with the path <code>lib/inversion/template/«yourtagnametag».rb/code>
568
+
569
+ * Name your class Inversion::Template::«yourtagname.capitalize»Tag
570
+
571
+ * Subclass one of the abstract template tag types:
572
+
573
+ * If your tag body will contain code, subclass Inversion::Template::CodeTag
574
+
575
+ * Otherwise, subclass Inversion::Template::Tag
576
+
577
+ * If your tag is a container, include Inversion::Template::ContainerTag
578
+
579
+ * Read the documentation for the tag type you're subclassing for the methods you're
580
+ required to implement.
581
+
582
+ Unfortunately, the tag superclasses aren't currently documented very well, so
583
+ the best way to accomplish what you want is to find an existing tag that does
584
+ something similar and look at how it does it.
@@ -66,7 +66,7 @@ class Inversion::Template::Tag < Inversion::Template::Node
66
66
  tags = {}
67
67
 
68
68
  Gem.find_files( TAG_PLUGIN_PATTERN ).each do |tagfile|
69
- tagname = tagfile[ %r{/(\w+)tag\.rb$}, 1 ].untaint
69
+ tagname = tagfile[ %r{/(\w+?)_?tag\.rb$}, 1 ].untaint
70
70
  next unless tagname
71
71
 
72
72
  self.load( tagfile )
@@ -202,6 +202,56 @@ class Inversion::Template
202
202
  end
203
203
 
204
204
 
205
+ ### Add one or more extension +modules+ to Inversion::Template. This allows tags to decorate
206
+ ### the template class with new functionality.
207
+ ###
208
+ ### Each one of the given +modules+ will be included as a mixin, and if it also
209
+ ### contains a constant called ClassMethods and/or PrependedMethods, it will
210
+ ### also be extended/prepended (respectively) with it.
211
+ ###
212
+ ### == Example
213
+ ###
214
+ ### Add a layout attribute to templates from a 'layout' tag:
215
+ ###
216
+ ### class Inversion::Template::LayoutTag < Inversion::Tag
217
+ ###
218
+ ### module TemplateExtension
219
+ ###
220
+ ### def layout
221
+ ### return @layout || 'default.tmpl'
222
+ ### end
223
+ ###
224
+ ### module PrependedMethods
225
+ ### def initialize( * )
226
+ ### super
227
+ ### @layout = nil
228
+ ### end
229
+ ### end
230
+ ###
231
+ ### Inversion::Template.add_extensions( TemplateExtension )
232
+ ###
233
+ ### # ... more tag stuff
234
+ ###
235
+ ### end
236
+ ###
237
+ def self::add_extensions( *modules )
238
+ self.log.info "Adding extensions to %p: %p" % [ self, modules ]
239
+
240
+ modules.each do |mod|
241
+ include( mod )
242
+ if mod.const_defined?( :ClassMethods )
243
+ submod = mod.const_get( :ClassMethods )
244
+ extend( submod )
245
+ end
246
+ if mod.const_defined?( :PrependedMethods )
247
+ submod = mod.const_get( :PrependedMethods )
248
+ prepend( submod )
249
+ end
250
+ end
251
+
252
+ end
253
+
254
+
205
255
  ### Create a new Inversion:Template with the given +source+.
206
256
  def initialize( source, parsestate=nil, opts={} )
207
257
  if parsestate.is_a?( Hash )
data/lib/inversion.rb CHANGED
@@ -26,10 +26,10 @@ module Inversion
26
26
  warn ">>> Inversion requires Ruby 1.9.2 or later. <<<" if RUBY_VERSION < '1.9.2'
27
27
 
28
28
  # Library version constant
29
- VERSION = '0.14.0'
29
+ VERSION = '0.15.0'
30
30
 
31
31
  # Version-control revision constant
32
- REVISION = %q$Revision: 9bb165feaf57 $
32
+ REVISION = %q$Revision: 7db3ff80c8e1 $
33
33
 
34
34
 
35
35
  ### Get the Inversion version.
@@ -120,6 +120,47 @@ describe Inversion::Template do
120
120
  end
121
121
 
122
122
 
123
+ it "can be extended at runtime via an extension module" do
124
+ extension_mod = Module.new do
125
+ def some_extension_stuff
126
+ return :extension_stuff
127
+ end
128
+ end
129
+
130
+ described_class.add_extensions( extension_mod )
131
+
132
+ expect( described_class.new('a template').some_extension_stuff ).to eq( :extension_stuff )
133
+ end
134
+
135
+
136
+ it "can be extended at runtime with class methods via a ClassMethods submodule" do
137
+ extension_mod = Module.new do
138
+ module ClassMethods
139
+ def some_class_extension_stuff; :class_extension_stuff; end
140
+ end
141
+ end
142
+
143
+ described_class.add_extensions( extension_mod )
144
+
145
+ expect( described_class.some_class_extension_stuff ).to eq( :class_extension_stuff )
146
+ end
147
+
148
+
149
+ it "can override methods at runtime with a PrependedMethods submodule" do
150
+ extension_mod = Module.new do
151
+ def a_method; :original_a_method; end
152
+
153
+ module PrependedMethods
154
+ def a_method; :extension_a_method; end
155
+ end
156
+ end
157
+
158
+ described_class.add_extensions( extension_mod )
159
+
160
+ expect( described_class.new('a template').a_method ).to eq( :extension_a_method )
161
+ end
162
+
163
+
123
164
  context "loaded from a file" do
124
165
 
125
166
  before( :each ) do
data.tar.gz.sig CHANGED
Binary file
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.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -31,230 +31,230 @@ cert_chain:
31
31
  c7ZKPJcWBv0sm81+FCZXNACn2f9jfF8OQinxVs0O052KbGuEQaaiGIYeuuwQE2q6
32
32
  ggcrPfcYeTwWlfZPu2LrBg==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-11-05 00:00:00.000000000 Z
34
+ date: 2014-11-24 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: loggability
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ~>
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0.11'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0.11'
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: hoe-mercurial
52
52
  requirement: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '1.4'
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '1.4'
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: hoe-manualgen
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
70
  version: 0.3.0
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ~>
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
77
  version: 0.3.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: hoe-deveiate
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ~>
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0.6'
85
85
  type: :development
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ~>
89
+ - - "~>"
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0.6'
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: hoe-highline
94
94
  requirement: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - ~>
96
+ - - "~>"
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0.2'
99
99
  type: :development
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0.2'
106
106
  - !ruby/object:Gem::Dependency
107
107
  name: rdoc
108
108
  requirement: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ~>
110
+ - - "~>"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '4.0'
113
113
  type: :development
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ~>
117
+ - - "~>"
118
118
  - !ruby/object:Gem::Version
119
119
  version: '4.0'
120
120
  - !ruby/object:Gem::Dependency
121
121
  name: highline
122
122
  requirement: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ~>
124
+ - - "~>"
125
125
  - !ruby/object:Gem::Version
126
126
  version: '1.6'
127
127
  type: :development
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ~>
131
+ - - "~>"
132
132
  - !ruby/object:Gem::Version
133
133
  version: '1.6'
134
134
  - !ruby/object:Gem::Dependency
135
135
  name: hoe-bundler
136
136
  requirement: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ~>
138
+ - - "~>"
139
139
  - !ruby/object:Gem::Version
140
140
  version: '1.2'
141
141
  type: :development
142
142
  prerelease: false
143
143
  version_requirements: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ~>
145
+ - - "~>"
146
146
  - !ruby/object:Gem::Version
147
147
  version: '1.2'
148
148
  - !ruby/object:Gem::Dependency
149
149
  name: rack-test
150
150
  requirement: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ~>
152
+ - - "~>"
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0.6'
155
155
  type: :development
156
156
  prerelease: false
157
157
  version_requirements: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ~>
159
+ - - "~>"
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0.6'
162
162
  - !ruby/object:Gem::Dependency
163
163
  name: simplecov
164
164
  requirement: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ~>
166
+ - - "~>"
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0.8'
169
169
  type: :development
170
170
  prerelease: false
171
171
  version_requirements: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - ~>
173
+ - - "~>"
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0.8'
176
176
  - !ruby/object:Gem::Dependency
177
177
  name: sinatra
178
178
  requirement: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ~>
180
+ - - "~>"
181
181
  - !ruby/object:Gem::Version
182
182
  version: '1.4'
183
183
  type: :development
184
184
  prerelease: false
185
185
  version_requirements: !ruby/object:Gem::Requirement
186
186
  requirements:
187
- - - ~>
187
+ - - "~>"
188
188
  - !ruby/object:Gem::Version
189
189
  version: '1.4'
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: tilt
192
192
  requirement: !ruby/object:Gem::Requirement
193
193
  requirements:
194
- - - ~>
194
+ - - "~>"
195
195
  - !ruby/object:Gem::Version
196
196
  version: '2.0'
197
197
  type: :development
198
198
  prerelease: false
199
199
  version_requirements: !ruby/object:Gem::Requirement
200
200
  requirements:
201
- - - ~>
201
+ - - "~>"
202
202
  - !ruby/object:Gem::Version
203
203
  version: '2.0'
204
204
  - !ruby/object:Gem::Dependency
205
205
  name: sysexits
206
206
  requirement: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - ~>
208
+ - - "~>"
209
209
  - !ruby/object:Gem::Version
210
210
  version: '1.0'
211
211
  type: :development
212
212
  prerelease: false
213
213
  version_requirements: !ruby/object:Gem::Requirement
214
214
  requirements:
215
- - - ~>
215
+ - - "~>"
216
216
  - !ruby/object:Gem::Version
217
217
  version: '1.0'
218
218
  - !ruby/object:Gem::Dependency
219
219
  name: trollop
220
220
  requirement: !ruby/object:Gem::Requirement
221
221
  requirements:
222
- - - ~>
222
+ - - "~>"
223
223
  - !ruby/object:Gem::Version
224
224
  version: '2.0'
225
225
  type: :development
226
226
  prerelease: false
227
227
  version_requirements: !ruby/object:Gem::Requirement
228
228
  requirements:
229
- - - ~>
229
+ - - "~>"
230
230
  - !ruby/object:Gem::Version
231
231
  version: '2.0'
232
232
  - !ruby/object:Gem::Dependency
233
233
  name: rdoc-generator-fivefish
234
234
  requirement: !ruby/object:Gem::Requirement
235
235
  requirements:
236
- - - ~>
236
+ - - "~>"
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  type: :development
240
240
  prerelease: false
241
241
  version_requirements: !ruby/object:Gem::Requirement
242
242
  requirements:
243
- - - ~>
243
+ - - "~>"
244
244
  - !ruby/object:Gem::Version
245
245
  version: '0'
246
246
  - !ruby/object:Gem::Dependency
247
247
  name: hoe
248
248
  requirement: !ruby/object:Gem::Requirement
249
249
  requirements:
250
- - - ~>
250
+ - - "~>"
251
251
  - !ruby/object:Gem::Version
252
252
  version: '3.13'
253
253
  type: :development
254
254
  prerelease: false
255
255
  version_requirements: !ruby/object:Gem::Requirement
256
256
  requirements:
257
- - - ~>
257
+ - - "~>"
258
258
  - !ruby/object:Gem::Version
259
259
  version: '3.13'
260
260
  description: |-
@@ -277,7 +277,7 @@ extra_rdoc_files:
277
277
  - README.rdoc
278
278
  - Tags.rdoc
279
279
  files:
280
- - .gemtest
280
+ - ".gemtest"
281
281
  - ChangeLog
282
282
  - Examples.rdoc
283
283
  - GettingStarted.rdoc
@@ -370,23 +370,23 @@ licenses:
370
370
  metadata: {}
371
371
  post_install_message:
372
372
  rdoc_options:
373
- - --main
373
+ - "--main"
374
374
  - README.rdoc
375
375
  require_paths:
376
376
  - lib
377
377
  required_ruby_version: !ruby/object:Gem::Requirement
378
378
  requirements:
379
- - - '>='
379
+ - - ">="
380
380
  - !ruby/object:Gem::Version
381
381
  version: 1.9.2
382
382
  required_rubygems_version: !ruby/object:Gem::Requirement
383
383
  requirements:
384
- - - '>='
384
+ - - ">="
385
385
  - !ruby/object:Gem::Version
386
386
  version: '0'
387
387
  requirements: []
388
388
  rubyforge_project:
389
- rubygems_version: 2.4.2
389
+ rubygems_version: 2.4.4
390
390
  signing_key:
391
391
  specification_version: 4
392
392
  summary: Inversion is a templating system for Ruby
metadata.gz.sig CHANGED
Binary file