wunderbar 0.14.4 → 0.14.5

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.
@@ -1,373 +1,380 @@
1
1
  # Wrapper class that understands HTML
2
- class HtmlMarkup < Wunderbar::BuilderBase
3
- VOID = %w(
4
- area base br col command embed hr img input keygen
5
- link meta param source track wbr
6
- )
7
-
8
- HTML5_BLOCK = %w(
9
- # https://developer.mozilla.org/en/HTML/Block-level_elements
10
- address article aside audio blockquote br canvas dd div dl fieldset
11
- figcaption figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr
12
- noscript ol output p pre section table tfoot ul video
13
- )
14
-
15
- def initialize(scope)
16
- @_scope = scope
17
- @x = Wunderbar::XmlMarkup.new :scope => scope, :indent => 2, :target => []
18
- @xthml = false
19
- end
20
-
21
- def xhtml(*args, &block)
22
- @xhtml = true
23
- html(*args, &block)
24
- end
25
-
26
- def html(*args, &block)
27
- # default namespace
28
- args << {} if args.empty?
29
- args.first[:xmlns] ||= 'http://www.w3.org/1999/xhtml' if Hash === args.first
30
- @_width = args.first.delete(:_width) if Hash === args.first
31
-
32
- @x.text! "\xEF\xBB\xBF"
33
- @x.declare! :DOCTYPE, :html
34
- @x.tag! :html, *args do
35
- set_variables_from_params
36
- instance_eval(&block)
2
+ module Wunderbar
3
+ class HtmlMarkup < BuilderBase
4
+ VOID = %w(
5
+ area base br col command embed hr img input keygen
6
+ link meta param source track wbr
7
+ )
8
+
9
+ HTML5_BLOCK = %w(
10
+ # https://developer.mozilla.org/en/HTML/Block-level_elements
11
+ address article aside audio blockquote br canvas dd div dl fieldset
12
+ figcaption figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup
13
+ hr noscript ol output p pre section table tfoot ul video
14
+ )
15
+
16
+ def initialize(scope)
17
+ @_scope = scope
18
+ @x = XmlMarkup.new :scope => scope, :indent => 2, :target => []
19
+ @xthml = false
37
20
  end
38
21
 
39
- if @_width
40
- self.class.reflow(@x.target!, @_width)
22
+ def xhtml(*args, &block)
23
+ @xhtml = true
24
+ html(*args, &block)
41
25
  end
42
26
 
43
- @x.target!.join
44
- end
27
+ def html(*args, &block)
28
+ # default namespace
29
+ args << {} if args.empty?
30
+ if Hash === args.first
31
+ args.first[:xmlns] ||= 'http://www.w3.org/1999/xhtml'
32
+ end
33
+ @_width = args.first.delete(:_width) if Hash === args.first
45
34
 
46
- def _html(*args, &block)
47
- html(*args, &block)
48
- end
35
+ @x.text! "\xEF\xBB\xBF"
36
+ @x.declare! :DOCTYPE, :html
37
+ @x.tag! :html, *args do
38
+ set_variables_from_params
39
+ instance_eval(&block)
40
+ end
49
41
 
50
- def _xhtml(*args, &block)
51
- @xhtml = true
52
- html(*args, &block)
53
- end
42
+ if @_width
43
+ self.class.reflow(@x.target!, @_width)
44
+ end
54
45
 
55
- def xhtml?
56
- @xhtml
57
- end
46
+ @x.target!.join
47
+ end
58
48
 
59
- def method_missing(name, *args, &block)
60
- if name.to_s =~ /^_(\w+)(!|\?|)$/
61
- name, flag = $1, $2
62
- elsif @_scope and @_scope.respond_to? name
63
- return @_scope.__send__ name, *args, &block
64
- else
65
- error = NameError.new "undefined local variable or method `#{name}'", name
66
- error.set_backtrace caller
67
- raise error
49
+ def _html(*args, &block)
50
+ html(*args, &block)
68
51
  end
69
52
 
70
- if name.sub!(/_$/,'')
71
- @x.margin!
72
- return __send__ "_#{name}", *args, &block if respond_to? "_#{name}"
53
+ def _xhtml(*args, &block)
54
+ @xhtml = true
55
+ html(*args, &block)
73
56
  end
74
57
 
75
- if flag != '!'
76
- if %w(script style).include?(name)
77
- if String === args.first and not block
78
- text = args.shift
79
- if !text.include? '&' and !text.include? '<'
80
- block = Proc.new do
81
- @x.indented_data!(text)
82
- end
83
- elsif name == 'style'
84
- block = Proc.new do
85
- @x.indented_data!(text, "/*<![CDATA[*/", "/*]]>*/")
58
+ def xhtml?
59
+ @xhtml
60
+ end
61
+
62
+ def method_missing(name, *args, &block)
63
+ if name.to_s =~ /^_(\w+)(!|\?|)$/
64
+ name, flag = $1, $2
65
+ elsif @_scope and @_scope.respond_to? name
66
+ return @_scope.__send__ name, *args, &block
67
+ else
68
+ err = NameError.new "undefined local variable or method `#{name}'", name
69
+ err.set_backtrace caller
70
+ raise err
71
+ end
72
+
73
+ if name.sub!(/_$/,'')
74
+ @x.margin!
75
+ return __send__ "_#{name}", *args, &block if respond_to? "_#{name}"
76
+ end
77
+
78
+ if flag != '!'
79
+ if %w(script style).include?(name)
80
+ if String === args.first and not block
81
+ text = args.shift
82
+ if !text.include? '&' and !text.include? '<'
83
+ block = Proc.new do
84
+ @x.indented_data!(text)
85
+ end
86
+ elsif name == 'style'
87
+ block = Proc.new do
88
+ @x.indented_data!(text, "/*<![CDATA[*/", "/*]]>*/")
89
+ end
90
+ else
91
+ block = Proc.new do
92
+ @x.indented_data!(text, "//<![CDATA[", "//]]>")
93
+ end
86
94
  end
87
- else
88
- block = Proc.new do
89
- @x.indented_data!(text, "//<![CDATA[", "//]]>")
95
+ end
96
+
97
+ args << {} if args.length == 0
98
+ if Hash === args.last
99
+ args.last[:lang] ||= 'text/javascript' if name == 'script'
100
+ args.last[:type] ||= 'text/css' if name == 'style'
101
+ end
102
+ end
103
+
104
+ # ensure that non-void elements are explicitly closed
105
+ if not block and not VOID.include?(name)
106
+ symbol = (args.shift if args.length > 0 and Symbol === args.first)
107
+ if args.length == 0 or (args.length == 1 and Hash === args.first)
108
+ args.unshift ''
109
+ end
110
+ args.unshift(symbol) if symbol
111
+ end
112
+
113
+ if String === args.first and args.first.respond_to? :html_safe?
114
+ if args.first.html_safe? and not block
115
+ if args.first.include? '>' or args.first.include? '&'
116
+ markup = args.shift
117
+ block = Proc.new {_ markup}
90
118
  end
91
119
  end
92
120
  end
93
121
 
94
- args << {} if args.length == 0
95
122
  if Hash === args.last
96
- args.last[:lang] ||= 'text/javascript' if name == 'script'
97
- args.last[:type] ||= 'text/css' if name == 'style'
98
- end
99
- end
123
+ # remove attributes with nil, false values
124
+ args.last.delete_if {|key, value| !value}
100
125
 
101
- # ensure that non-void elements are explicitly closed
102
- if not block and not VOID.include?(name)
103
- symbol = (args.shift if args.length > 0 and Symbol === args.first)
104
- if args.length == 0 or (args.length == 1 and Hash === args.first)
105
- args.unshift ''
126
+ # replace boolean 'true' attributes with the name of the attribute
127
+ args.last.each {|key, value| args.last[key]=key if value == true}
106
128
  end
107
- args.unshift(symbol) if symbol
108
129
  end
109
130
 
110
- if String === args.first and args.first.respond_to? :html_safe?
111
- if args.first.html_safe? and not block
112
- if args.first.include? '>' or args.first.include? '&'
113
- markup = args.shift
114
- block = Proc.new {_ markup}
131
+ if flag == '!'
132
+ @x.disable_indentation! do
133
+ @x.tag! name, *args, &block
134
+ end
135
+ elsif flag == '?'
136
+ # capture exceptions, produce filtered tracebacks
137
+ @x.tag!(name, *args) do
138
+ begin
139
+ block.call
140
+ rescue ::Exception => exception
141
+ options = (Hash === args.last)? args.last : {}
142
+ options[:log_level] = 'warn'
143
+ _exception exception, options
115
144
  end
116
145
  end
117
- end
118
-
119
- if Hash === args.last
120
- # remove attributes with nil, false values
121
- args.last.delete_if {|key, value| !value}
122
-
123
- # replace boolean 'true' attributes with the name of the attribute
124
- args.last.each {|key, value| args.last[key]=key if value == true}
146
+ else
147
+ target = @x.tag! name, *args, &block
148
+ if block and %w(script style).include?(name)
149
+ if %w{//]]> /*]]>*/}.include? target[-4]
150
+ target[-4], target[-3] = target[-3], target[-4]
151
+ end
152
+ end
153
+ target
125
154
  end
126
155
  end
127
156
 
128
- if flag == '!'
129
- @x.disable_indentation! do
130
- @x.tag! name, *args, &block
131
- end
132
- elsif flag == '?'
133
- # capture exceptions, produce filtered tracebacks
134
- @x.tag!(name, *args) do
135
- begin
136
- block.call
137
- rescue ::Exception => exception
138
- options = (Hash === args.last)? args.last : {}
139
- options[:log_level] = 'warn'
140
- _exception exception, options
157
+ def _exception(*args)
158
+ exception = args.first
159
+ if exception.respond_to? :backtrace
160
+ options = (Hash === args.last)? args.last : {}
161
+ traceback_class = options.delete(:traceback_class)
162
+ traceback_style = options.delete(:traceback_style)
163
+ traceback_style ||= 'background-color:#ff0; margin: 1em 0; ' +
164
+ 'padding: 1em; border: 4px solid red; border-radius: 1em'
165
+
166
+ text = exception.inspect
167
+ log_level = options.delete(:log_level) || :error
168
+ Wunderbar.send log_level, text
169
+ exception.backtrace.each do |frame|
170
+ next if Wunderbar::CALLERS_TO_IGNORE.any? {|re| frame =~ re}
171
+ Wunderbar.send log_level, " #{frame}"
172
+ text += "\n #{frame}"
141
173
  end
142
- end
143
- else
144
- target = @x.tag! name, *args, &block
145
- if block and %w(script style).include?(name)
146
- if %w{//]]> /*]]>*/}.include? target[-4]
147
- target[-4], target[-3] = target[-3], target[-4]
174
+
175
+ if traceback_class
176
+ @x.tag! :pre, text, :class=>traceback_class
177
+ else
178
+ @x.tag! :pre, text, :style=>traceback_style
148
179
  end
180
+ else
181
+ super
149
182
  end
150
- target
151
183
  end
152
- end
153
184
 
154
- def _exception(*args)
155
- exception = args.first
156
- if exception.respond_to? :backtrace
157
- options = (Hash === args.last)? args.last : {}
158
- traceback_class = options.delete(:traceback_class)
159
- traceback_style = options.delete(:traceback_style)
160
- traceback_style ||= 'background-color:#ff0; margin: 1em 0; ' +
161
- 'padding: 1em; border: 4px solid red; border-radius: 1em'
162
-
163
- text = exception.inspect
164
- log_level = options.delete(:log_level) || :error
165
- Wunderbar.send log_level, text
166
- exception.backtrace.each do |frame|
167
- next if Wunderbar::CALLERS_TO_IGNORE.any? {|re| frame =~ re}
168
- Wunderbar.send log_level, " #{frame}"
169
- text += "\n #{frame}"
170
- end
171
-
172
- if traceback_class
173
- @x.tag! :pre, text, :class=>traceback_class
174
- else
175
- @x.tag! :pre, text, :style=>traceback_style
185
+ def _head(*args, &block)
186
+ @x.tag!('head', *args) do
187
+ @x.tag! :meta, :charset => 'utf-8'
188
+ block.call if block
176
189
  end
177
- else
178
- super
179
190
  end
180
- end
181
191
 
182
- def _head(*args, &block)
183
- @x.tag!('head', *args) do
184
- @x.tag! :meta, :charset => 'utf-8'
185
- block.call if block
192
+ def _svg(*args, &block)
193
+ args << {} if args.empty?
194
+ args.first['xmlns'] = 'http://www.w3.org/2000/svg' if Hash === args.first
195
+ @x.tag! :svg, *args, &block
186
196
  end
187
- end
188
197
 
189
- def _svg(*args, &block)
190
- args << {} if args.empty?
191
- args.first['xmlns'] = 'http://www.w3.org/2000/svg' if Hash === args.first
192
- @x.tag! :svg, *args, &block
193
- end
198
+ def _math(*args, &block)
199
+ args << {} if args.empty?
200
+ if Hash === args.first
201
+ args.first['xmlns'] = 'http://www.w3.org/1998/Math/MathML'
202
+ end
203
+ @x.tag! :math, *args, &block
204
+ end
194
205
 
195
- def _math(*args, &block)
196
- args << {} if args.empty?
197
- if Hash === args.first
198
- args.first['xmlns'] = 'http://www.w3.org/1998/Math/MathML'
206
+ def _?(text)
207
+ @x.indented_text! text.to_s
199
208
  end
200
- @x.tag! :math, *args, &block
201
- end
202
209
 
203
- def _?(text)
204
- @x.indented_text! text.to_s
205
- end
210
+ def _!(text)
211
+ @x.text! text.to_s
212
+ end
206
213
 
207
- def _!(text)
208
- @x.text! text.to_s
209
- end
214
+ def _(children=nil)
215
+ return @x if children == nil
210
216
 
211
- def _(children=nil)
212
- return @x if children == nil
217
+ if String === children
218
+ safe = !children.tainted?
219
+ safe ||= children.html_safe? if children.respond_to? :html_safe?
213
220
 
214
- if String === children
215
- safe = !children.tainted?
216
- safe ||= children.html_safe? if children.respond_to? :html_safe?
221
+ if safe and (children.include? '<' or children.include? '&')
222
+ require 'nokogiri'
223
+ children = Nokogiri::HTML::fragment(children.to_s).children
224
+ else
225
+ return @x.indented_text! children
226
+ end
227
+ end
217
228
 
218
- if safe and (children.include? '<' or children.include? '&')
219
- require 'nokogiri'
220
- children = Nokogiri::HTML::fragment(children.to_s).children
221
- else
222
- return @x.indented_text! children
229
+ # remove leading and trailing space
230
+ if children.first.text? and children.first.text.strip.empty?
231
+ children.shift
223
232
  end
224
- end
225
233
 
226
- # remove leading and trailing space
227
- children.shift if children.first.text? and children.first.text.strip.empty?
228
- if not children.empty?
229
- children.pop if children.last.text? and children.last.text.strip.empty?
230
- end
234
+ if not children.empty?
235
+ children.pop if children.last.text? and children.last.text.strip.empty?
236
+ end
231
237
 
232
- children.each do |child|
233
- if child.text? or child.cdata?
234
- text = child.text
235
- if text.strip.empty?
236
- @x.text! "\n" if text.count("\n")>1
237
- elsif @x.indentation_state!.first == 0
238
- @x.indented_text! text.gsub(/\s+/, ' ')
239
- else
240
- @x.indented_text! text.strip
241
- end
242
- elsif child.comment?
243
- @x.comment! child.text.sub(/\A /,'').sub(/ \Z/, '')
244
- elsif self.class.flatten? child.children
245
- block_element = Proc.new do |node|
246
- node.element? and HTML5_BLOCK.include?(node.name)
247
- end
238
+ children.each do |child|
239
+ if child.text? or child.cdata?
240
+ text = child.text
241
+ if text.strip.empty?
242
+ @x.text! "\n" if text.count("\n")>1
243
+ elsif @x.indentation_state!.first == 0
244
+ @x.indented_text! text.gsub(/\s+/, ' ')
245
+ else
246
+ @x.indented_text! text.strip
247
+ end
248
+ elsif child.comment?
249
+ @x.comment! child.text.sub(/\A /,'').sub(/ \Z/, '')
250
+ elsif self.class.flatten? child.children
251
+ block_element = Proc.new do |node|
252
+ node.element? and HTML5_BLOCK.include?(node.name)
253
+ end
248
254
 
249
- if child.children.any?(&block_element)
250
- # indent children, but disable indentation on consecutive
251
- # sequences of non-block-elements. Put another way: break
252
- # out block elements to a new line.
253
- @x.tag!(child.name, child.attributes) do
254
- children = child.children.to_a
255
- while not children.empty?
256
- stop = children.index(&block_element)
257
- if stop == 0
258
- _ [children.shift]
259
- else
260
- @x.disable_indentation! do
261
- _ children.shift(stop || children.length)
255
+ if child.children.any?(&block_element)
256
+ # indent children, but disable indentation on consecutive
257
+ # sequences of non-block-elements. Put another way: break
258
+ # out block elements to a new line.
259
+ @x.tag!(child.name, child.attributes) do
260
+ children = child.children.to_a
261
+ while not children.empty?
262
+ stop = children.index(&block_element)
263
+ if stop == 0
264
+ _ [children.shift]
265
+ else
266
+ @x.disable_indentation! do
267
+ _ children.shift(stop || children.length)
268
+ end
262
269
  end
263
270
  end
264
271
  end
272
+ else
273
+ # disable indentation on the entire element
274
+ @x.disable_indentation! do
275
+ @x.tag!(child.name, child.attributes) {_ child.children}
276
+ end
265
277
  end
278
+ elsif child.children.empty? and VOID.include? child.name
279
+ @x.tag!(child.name, child.attributes)
280
+ elsif child.children.all? {|gchild| gchild.text?}
281
+ @x.tag!(child.name, child.text.strip, child.attributes)
282
+ elsif child.children.any? {|gchild| gchild.cdata?} and
283
+ (child.text.include? '<' or child.text.include? '&')
284
+ @x << child
266
285
  else
267
- # disable indentation on the entire element
268
- @x.disable_indentation! do
269
- @x.tag!(child.name, child.attributes) {_ child.children}
270
- end
286
+ @x.tag!(child.name, child.attributes) {_ child.children}
271
287
  end
272
- elsif child.children.empty? and VOID.include? child.name
273
- @x.tag!(child.name, child.attributes)
274
- elsif child.children.all? {|gchild| gchild.text?}
275
- @x.tag!(child.name, child.text.strip, child.attributes)
276
- elsif child.children.any? {|gchild| gchild.cdata?} and
277
- (child.text.include? '<' or child.text.include? '&')
278
- @x << child
279
- else
280
- @x.tag!(child.name, child.attributes) {_ child.children}
281
288
  end
282
289
  end
283
- end
284
290
 
285
- def _coffeescript(text)
286
- require 'coffee-script'
287
- _script CoffeeScript.compile(text)
288
- rescue LoadError
289
- _script text, :lang => 'text/coffeescript'
290
- end
291
+ def _coffeescript(text)
292
+ require 'coffee-script'
293
+ _script CoffeeScript.compile(text)
294
+ rescue LoadError
295
+ _script text, :lang => 'text/coffeescript'
296
+ end
291
297
 
292
- def clear!
293
- @x.target!.clear
294
- end
298
+ def clear!
299
+ @x.target!.clear
300
+ end
295
301
 
296
- def self.flatten?(children)
297
- # do any of the text nodes need special processing to preserve spacing?
298
- flatten = false
299
- space = true
300
- if children.any? {|child| child.text? and !child.text.strip.empty?}
301
- children.each do |child|
302
- if child.text? or child.element?
303
- unless child.text == ''
304
- flatten = true if not space and not child.text =~ /\A\s/
305
- space = (child.text =~ /\s\Z/)
302
+ def self.flatten?(children)
303
+ # do any of the text nodes need special processing to preserve spacing?
304
+ flatten = false
305
+ space = true
306
+ if children.any? {|child| child.text? and !child.text.strip.empty?}
307
+ children.each do |child|
308
+ if child.text? or child.element?
309
+ unless child.text == ''
310
+ flatten = true if not space and not child.text =~ /\A\s/
311
+ space = (child.text =~ /\s\Z/)
312
+ end
313
+ space = true if child.element? and HTML5_BLOCK.include? child.name
306
314
  end
307
- space = true if child.element? and HTML5_BLOCK.include? child.name
308
315
  end
309
316
  end
317
+ flatten
310
318
  end
311
- flatten
312
- end
313
319
 
314
- # reflow long lines
315
- def self.reflow(stream, width)
316
- source = stream.slice!(0..-1)
317
- indent = col = 0
318
- breakable = true
319
- pre = false
320
- while not source.empty?
321
- token = source.shift
322
- indent = token[/^ */].length if col == 0
323
-
324
- if token.start_with? '<'
325
- breakable = false
326
- pre = true if token == '<pre'
327
- end
320
+ # reflow long lines
321
+ def self.reflow(stream, width)
322
+ source = stream.slice!(0..-1)
323
+ indent = col = 0
324
+ breakable = true
325
+ pre = false
326
+ while not source.empty?
327
+ token = source.shift
328
+ indent = token[/^ */].length if col == 0
329
+
330
+ if token.start_with? '<'
331
+ breakable = false
332
+ pre = true if token == '<pre'
333
+ end
328
334
 
329
- # flow text
330
- while token.length + col > width and breakable and not pre
331
- break if token[0...-1].include? "\n"
332
- split = token.rindex(' ', [width-col,0].max) || token.index(' ')
333
- break unless split
334
- break if col+split < indent+width/2
335
- stream << token[0...split] << "\n" << (' '*indent)
336
- col = indent
337
- token = token[split+1..-1]
338
- end
335
+ # flow text
336
+ while token.length + col > width and breakable and not pre
337
+ break if token[0...-1].include? "\n"
338
+ split = token.rindex(' ', [width-col,0].max) || token.index(' ')
339
+ break unless split
340
+ break if col+split < indent+width/2
341
+ stream << token[0...split] << "\n" << (' '*indent)
342
+ col = indent
343
+ token = token[split+1..-1]
344
+ end
339
345
 
340
- # break around tags
341
- if token.end_with? '>'
342
- if col > indent + 4 and stream[-2..-1] == ['<br', '/']
343
- stream << token << "\n"
344
- col = 0
345
- token = ' '*indent
346
- source[0] = source.first.lstrip unless source.empty?
347
- elsif col > width and not pre
348
- # break on previous space within text
349
- pcol = col
350
- stream.reverse_each do |xtoken|
351
- break if xtoken.include? "\n"
352
- split = xtoken.rindex(' ')
353
- breakable = false if xtoken.end_with? '>'
354
- if breakable and split
355
- col = col - pcol + xtoken.length - split + indent
356
- xtoken[split] = "\n#{' '*indent}"
357
- break
346
+ # break around tags
347
+ if token.end_with? '>'
348
+ if col > indent + 4 and stream[-2..-1] == ['<br', '/']
349
+ stream << token << "\n"
350
+ col = 0
351
+ token = ' '*indent
352
+ source[0] = source.first.lstrip unless source.empty?
353
+ elsif col > width and not pre
354
+ # break on previous space within text
355
+ pcol = col
356
+ stream.reverse_each do |xtoken|
357
+ break if xtoken.include? "\n"
358
+ split = xtoken.rindex(' ')
359
+ breakable = false if xtoken.end_with? '>'
360
+ if breakable and split
361
+ col = col - pcol + xtoken.length - split + indent
362
+ xtoken[split] = "\n#{' '*indent}"
363
+ break
364
+ end
365
+ breakable = true if xtoken.start_with? '<'
366
+ pcol -= xtoken.length
367
+ break if pcol < (width + indent)/2
358
368
  end
359
- breakable = true if xtoken.start_with? '<'
360
- pcol -= xtoken.length
361
- break if pcol < (width + indent)/2
362
369
  end
370
+ breakable = true
371
+ pre = false if token == '</pre>'
363
372
  end
364
- breakable = true
365
- pre = false if token == '</pre>'
366
- end
367
373
 
368
- stream << token
369
- col += token.length
370
- col = 0 if token.end_with? "\n"
374
+ stream << token
375
+ col += token.length
376
+ col = 0 if token.end_with? "\n"
377
+ end
371
378
  end
372
379
  end
373
380
  end
@@ -9,7 +9,7 @@ module Wunderbar
9
9
  def self.call(template)
10
10
  %{
11
11
  compiled = Proc.new {#{template.source}}
12
- x = HtmlMarkup.new(self);
12
+ x = Wunderbar::HtmlMarkup.new(self);
13
13
  instance_variables.each do |var|
14
14
  x.instance_variable_set var, instance_variable_get(var)
15
15
  end
@@ -54,8 +54,11 @@ else
54
54
  ENV['USER'] ||= $USER
55
55
  end
56
56
 
57
- ENV['HOME'] ||= Dir.home($USER) rescue nil
58
- ENV['HOME'] = ENV['DOCUMENT_ROOT'] if not File.exist? ENV['HOME'].to_s
57
+ $HOME = ENV['HOME']
58
+ $HOME ||= Dir.home($USER) rescue nil
59
+ $HOME ||= File.expand_path("~#{$USER}") rescue nil
60
+ $HOME = ENV['DOCUMENT_ROOT'] if not $HOME or not File.exist? $HOME
61
+ ENV['HOME'] = $HOME
59
62
 
60
63
  at_exit do
61
64
  if Wunderbar.queue.length > 0
@@ -2,7 +2,7 @@ module Wunderbar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 14
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/wunderbar.gemspec CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "wunderbar"
5
- s.version = "0.14.4"
5
+ s.version = "0.14.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sam Ruby"]
9
- s.date = "2012-05-02"
9
+ s.date = "2012-05-03"
10
10
  s.description = " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML, Unicode\n (utf-8), consistently indented, readable applications. This includes\n output that conforms to the Polyglot specification and the emerging\n results from the XML Error Recovery Community Group.\n"
11
11
  s.email = "rubys@intertwingly.net"
12
- s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar.rb", "lib/wunderbar", "lib/wunderbar/installation.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/server.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/websocket.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/version.rb"]
12
+ s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar", "lib/wunderbar/logger.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/websocket.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/version.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/server.rb", "lib/wunderbar.rb"]
13
13
  s.homepage = "http://github.com/rubys/wunderbar"
14
14
  s.require_paths = ["lib"]
15
15
  s.rubygems_version = "1.8.21"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderbar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 14
9
- - 4
10
- version: 0.14.4
9
+ - 5
10
+ version: 0.14.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Ruby
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-02 00:00:00 Z
18
+ date: 2012-05-03 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: builder
@@ -58,21 +58,21 @@ files:
58
58
  - wunderbar.gemspec
59
59
  - README.md
60
60
  - COPYING
61
- - lib/wunderbar.rb
62
- - lib/wunderbar/installation.rb
63
- - lib/wunderbar/html-methods.rb
64
- - lib/wunderbar/job-control.rb
65
- - lib/wunderbar/server.rb
66
61
  - lib/wunderbar/logger.rb
67
62
  - lib/wunderbar/rack.rb
68
- - lib/wunderbar/builder.rb
69
- - lib/wunderbar/websocket.rb
70
63
  - lib/wunderbar/sinatra.rb
71
- - lib/wunderbar/environment.rb
72
- - lib/wunderbar/rails.rb
73
64
  - lib/wunderbar/cgi-methods.rb
74
65
  - lib/wunderbar/cssproxy.rb
66
+ - lib/wunderbar/builder.rb
67
+ - lib/wunderbar/websocket.rb
68
+ - lib/wunderbar/installation.rb
75
69
  - lib/wunderbar/version.rb
70
+ - lib/wunderbar/html-methods.rb
71
+ - lib/wunderbar/job-control.rb
72
+ - lib/wunderbar/rails.rb
73
+ - lib/wunderbar/environment.rb
74
+ - lib/wunderbar/server.rb
75
+ - lib/wunderbar.rb
76
76
  homepage: http://github.com/rubys/wunderbar
77
77
  licenses: []
78
78