wunderbar 1.0.21 → 1.0.23

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: f2e1e449f96b62b3cc9251367f7d25efcb45e1c7
4
- data.tar.gz: 5f01bf5862c3956c07ca5a7247596a1495a70ef7
3
+ metadata.gz: d584cea1e10ef64f349221f0c7166b273e87065e
4
+ data.tar.gz: ceb134f97e82c9dd9298a83c30d5add9ffd0d4a7
5
5
  SHA512:
6
- metadata.gz: 32e20118eeaa68e3e374812d8b75fdab54b05f3bdcceeffbe67accc0dd035d0408737682abb786dbc2468f3d942771f5d4319b2a1f038c76b5de8b4409d884eb
7
- data.tar.gz: caac555ac66f5c5d688e10c7cc34d062babbd3cbc286183533fc9ad070b9e975f08c0c6313b6c48b9d7ac1592c8ce47d1abbce0458ce0a2dd7ef6d95114f30e0
6
+ metadata.gz: 0bc7bd9fa1c2ed6b6c555736bf534a1b00c9cfe0aac2156f05c7b99ece51f5253d95c0b6ed121f6dde9fdd5aa3fd655252e0cf83e012b0086a48534329aa0294
7
+ data.tar.gz: e69d846acbe52f2d4fe64b5433a1cde82a8a39c98bcc75e52364494707259d34e984893364585b676236725068093623f65413e60c9fb24e230d1d09575fc1dc
data/README.md CHANGED
@@ -228,6 +228,7 @@ convenience methods are defined:
228
228
  Access to all of the builder _defined_ methods (typically these end in an esclamation mark) and all of the Wunderbar module methods can be accessed in this way. Examples:
229
229
 
230
230
  * `_.tag! :foo`: insert elements where the name can be dynamic
231
+ * `_.comment! "text"`: add a comment
231
232
  * `_.error 'Log message'`: write a message to the server log
232
233
 
233
234
  Underscores in element and attribute names are converted to dashes. To
@@ -364,9 +365,10 @@ Secure by default
364
365
 
365
366
  Wunderbar will properly escape all HTML and JSON output, eliminating problems
366
367
  of HTML or JavaScript injection. This includes calls to `_` to insert text
367
- directly. Even calls to insert markup (`_{...}`) will escape the markup if
368
- the input is `tainted` and not explicitly marked as `html-safe?`
369
- (when using Rails).
368
+ directly. Unless `nokogiri` was previously required (see [optional
369
+ dependencies](#optional-dependencies) below), calls to insert markup
370
+ (`_{...}`) will escape the markup if the input is `tainted` and not explicitly
371
+ marked as `html-safe?` (when using Rails).
370
372
 
371
373
  For all environments other than Rails, unless you call `Wunderbar.unsafe!` at
372
374
  the top of your script, Wunderbar will also set
@@ -407,6 +409,7 @@ Logging:
407
409
  * `_.error`: error messages
408
410
  * `_.fatal`: fatal error messages
409
411
  * `_.log_level`=: set logging level (default: `:warn`)
412
+ * `_.default_log_level`=: set, but don't override, log level
410
413
  * `_.logger`: return [Logger](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html) instance
411
414
 
412
415
  Command line options
@@ -443,9 +446,9 @@ The following gems are required by extensions of the same name:
443
446
 
444
447
  The following gems, if installed, will produce cleaner and prettier output:
445
448
 
446
- * `nokogiri` cleans up HTML fragments inserted via `<<`
447
- * `nokogumbo` also cleans up HTML fragments inserted via `<<`. If this is
448
- available, it will be preferred over direct usage of `nokogiri`.
449
+ * `nokogiri` cleans up HTML fragments inserted via `<<` and `_{}`.
450
+ * `nokogumbo` also cleans up HTML fragments inserted via `<<` and `_{}`. If
451
+ this gem is available, it will be preferred over direct usage of `nokogiri`.
449
452
  * `escape` prettier quoting of `system` commands
450
453
  * `sanitize` will remove unsafe markup from tainted input
451
454
 
@@ -62,6 +62,7 @@ module Wunderbar
62
62
  env = Thread.current[:env] || ENV
63
63
 
64
64
  @path = '../' * env['PATH_INFO'].to_s.count('/') + 'assets'
65
+ @root ||= nil
65
66
  @root = File.dirname(env['SCRIPT_FILENAME']) if env['SCRIPT_FILENAME']
66
67
  @root = File.expand_path((@root || Dir.pwd) + "/assets").untaint
67
68
 
@@ -123,7 +124,8 @@ module Wunderbar
123
124
  nodes = []
124
125
  @@scripts.each do |script|
125
126
  if script.path
126
- nodes << Node.new(:script, src: "#{path}/#{script.path}")
127
+ nodes << Node.new(:script, src:
128
+ "#{path}/#{script.path}?#{script.mtime.to_i}")
127
129
  elsif script.contents
128
130
  nodes << ScriptNode.new(:script, script.contents)
129
131
  end
@@ -146,7 +148,7 @@ module Wunderbar
146
148
  @@stylesheets.each do |stylesheet|
147
149
  if stylesheet.path
148
150
  nodes << Node.new(:link, rel: "stylesheet", type: "text/css",
149
- href: "#{path}/#{stylesheet.path}")
151
+ href: "#{path}/#{stylesheet.path}?#{stylesheet.mtime.to_i}")
150
152
  elsif stylesheet.contents
151
153
  nodes << StyleNode.new(:style, stylesheet.contents)
152
154
  end
@@ -11,10 +11,11 @@ module Wunderbar
11
11
 
12
12
  class BuilderBase
13
13
  def set_variables_from_params(locals={})
14
- params = @_scope.params.map do |key, value|
14
+ params = []
15
+ @_scope.params.each_pair do |key, value|
15
16
  value = value.first if Array === value
16
17
  value.gsub! "\r\n", "\n" if String === value
17
- ["@#{key}", value]
18
+ params << ["@#{key}", value]
18
19
  end
19
20
 
20
21
  Hash[params].merge(locals).each do |key,value|
@@ -403,7 +404,7 @@ module Wunderbar
403
404
  end
404
405
 
405
406
  def _(*args)
406
- @_target.puts *args if args.length > 0
407
+ @_target.puts(*args) if args.length > 0
407
408
  self
408
409
  end
409
410
 
@@ -96,9 +96,9 @@ module Wunderbar
96
96
  if @pdf
97
97
  x._.pdf = true if @pdf
98
98
  headers = { 'type' => 'application/pdf' }
99
- output = html2pdf {x.html *args, &block}
99
+ output = html2pdf {x.html(*args, &block)}
100
100
  else
101
- output = x.html *args, &block
101
+ output = x.html(*args, &block)
102
102
  end
103
103
  rescue ::Exception => exception
104
104
  headers['status'] = Wunderbar::ServerError.text
@@ -159,9 +159,9 @@ module Wunderbar
159
159
 
160
160
  # disable conneg if only one handler is provided
161
161
  if Wunderbar.queue.length == 1
162
- type = Wunderbar.queue.first.first
163
- xhr_json = (type == :json)
164
- text = (type == :text)
162
+ htype = Wunderbar.queue.first.first
163
+ xhr_json = (htype == :json)
164
+ text = (htype == :text)
165
165
  end
166
166
 
167
167
  Wunderbar.queue.each do |type, args, block|
@@ -7,7 +7,7 @@ module CodeRay::PluginHost
7
7
  alias_method :old_plugin_path, :plugin_path
8
8
  def plugin_path *args
9
9
  args.first.untaint if args.first == CodeRay::CODERAY_PATH
10
- old_plugin_path *args
10
+ old_plugin_path(*args)
11
11
  end
12
12
  end
13
13
 
@@ -35,7 +35,7 @@ module Wunderbar
35
35
  hash = args.pop.to_hash
36
36
  if attrs[:class] and hash[:class]
37
37
  hash[:class] = "#{attrs[:class]} #{hash[:class]}"
38
- end
38
+ end
39
39
  attrs.merge! hash
40
40
  end
41
41
  args.push(attrs)
@@ -109,8 +109,14 @@ $SERVER = ENV['HTTP_HOST'] || Socket::gethostname
109
109
 
110
110
  # set encoding to UTF-8
111
111
  ENV['LANG'] ||= "en_US.UTF-8"
112
- Encoding.default_external = Encoding::UTF_8
113
- Encoding.default_internal = Encoding::UTF_8
112
+ begin
113
+ verbose = $VERBOSE
114
+ $VERBOSE = nil
115
+ Encoding.default_external = Encoding::UTF_8
116
+ Encoding.default_internal = Encoding::UTF_8
117
+ ensure
118
+ $VERBOSE = verbose
119
+ end
114
120
 
115
121
  # Add methods to the 'main' object
116
122
  if self.to_s == 'main'
@@ -216,14 +216,14 @@ module Wunderbar
216
216
  x.instance_variable_set ivar, instance_variable_get(ivar)
217
217
  end
218
218
  if Hash === args.last
219
- args.last.each do |name, value|
220
- x.instance_variable_set "@#{name}", value
219
+ args.last.each do |attrname, value|
220
+ x.instance_variable_set "@#{attrname}", value
221
221
  end
222
222
  end
223
223
  save_yield = Wunderbar.templates['yield']
224
224
  begin
225
225
  Wunderbar.templates['yield'] = block if block
226
- x.instance_eval &Wunderbar.templates[name]
226
+ x.instance_eval(&Wunderbar.templates[name])
227
227
  ensure
228
228
  Wunderbar.templates['yield'] = save_yield
229
229
  Wunderbar.templates.delete 'yield' unless save_yield
@@ -371,7 +371,7 @@ module Wunderbar
371
371
  return @_x
372
372
  end
373
373
 
374
- children = instance_eval &block
374
+ children = instance_eval(&block)
375
375
 
376
376
  if String === children
377
377
  safe = !children.tainted?
@@ -425,7 +425,7 @@ module Wunderbar
425
425
  @_x.indented_text! text
426
426
  elsif block
427
427
  @_x.spaced!
428
- _ &block
428
+ _(&block)
429
429
  else
430
430
  @_x.text! ""
431
431
  end
@@ -8,6 +8,11 @@ module Wunderbar
8
8
  module JQuery
9
9
  include Ruby2JS::Filter::SEXP
10
10
 
11
+ def initialize(*args)
12
+ @_jqchild = nil
13
+ super
14
+ end
15
+
11
16
  def on_send(node)
12
17
  return super if @react
13
18
 
@@ -94,7 +99,7 @@ module Wunderbar
94
99
  s(:str, node.children[1].to_s[0..-2].gsub('_','-')))
95
100
 
96
101
  # if a hash argument is already passed, merge in id value
97
- hash = children.find_index {|node| node.type == :hash}
102
+ hash = children.find_index {|cnode| cnode.type == :hash}
98
103
  if hash
99
104
  children[hash] = s(:hash, pair, *children[hash].children)
100
105
  else
@@ -2,6 +2,7 @@ require 'logger'
2
2
 
3
3
  module Wunderbar
4
4
  def self.logger
5
+ @logger ||= nil
5
6
  return @logger if @logger
6
7
  @logger = Logger.new($stderr)
7
8
  @logger.level = Logger::WARN
@@ -29,6 +30,10 @@ module Wunderbar
29
30
  end
30
31
  end
31
32
 
33
+ def self.default_log_level=(level)
34
+ self.log_level = level unless @logger
35
+ end
36
+
32
37
  def self.log_level
33
38
  return 'debug' if logger.level == Logger::DEBUG
34
39
  return 'info' if logger.level == Logger::INFO
@@ -39,23 +44,23 @@ module Wunderbar
39
44
 
40
45
  # convenience methods
41
46
  def self.debug(*args, &block)
42
- logger.debug *args, &block
47
+ logger.debug(*args, &block)
43
48
  end
44
49
 
45
50
  def self.info(*args, &block)
46
- logger.info *args, &block
51
+ logger.info(*args, &block)
47
52
  end
48
53
 
49
54
  def self.warn(*args, &block)
50
- logger.warn *args, &block
55
+ logger.warn(*args, &block)
51
56
  end
52
57
 
53
58
  def self.error(*args, &block)
54
- logger.error *args, &block
59
+ logger.error(*args, &block)
55
60
  end
56
61
 
57
62
  def self.fatal(*args, &block)
58
- logger.fatal *args, &block
63
+ logger.fatal(*args, &block)
59
64
  end
60
65
  end
61
66
 
@@ -95,7 +95,7 @@ module Wunderbar
95
95
  reflowed = IndentedTextNode.reflow(indent, line, width,
96
96
  options[:indent])
97
97
  line = reflowed.pop
98
- result.push *reflowed
98
+ result.push(*reflowed)
99
99
  end
100
100
  end
101
101
  elsif CompactNode === self and not CompactNode === parent
@@ -278,9 +278,8 @@ module Wunderbar
278
278
  unindent = data.sub(/s+\Z/,'').scan(/^ *\S/).map(&:length).min || 0
279
279
 
280
280
  before = ::Regexp.new('^'.ljust(unindent))
281
- node = @node
282
281
  data.gsub! before, indent
283
- data.gsub! /^#{indent}$/, '' if unindent == 0
282
+ data.gsub!(/^#{indent}$/, '') if unindent == 0
284
283
  data
285
284
  end
286
285
 
@@ -342,8 +341,8 @@ module Wunderbar
342
341
  text = @text
343
342
  end
344
343
 
345
- result.push *IndentedTextNode.reflow(indent,
346
- text.to_s.gsub(/[&<>\u00A0]/,ESCAPE), options[:width], '')
344
+ result.push(*IndentedTextNode.reflow(indent,
345
+ text.to_s.gsub(/[&<>\u00A0]/,ESCAPE), options[:width], ''))
347
346
  end
348
347
  end
349
348
 
@@ -27,7 +27,7 @@ if self.to_s == 'main'
27
27
 
28
28
  begin
29
29
  element = x._polymer_element *args do
30
- x.instance_eval &block
30
+ x.instance_eval(&block)
31
31
  end
32
32
  output = element.serialize.join("\n") + "\n"
33
33
  rescue ::Exception => exception
@@ -49,7 +49,7 @@ module Wunderbar
49
49
  module SinatraHelpers
50
50
  def _polymer_element(*args, &block)
51
51
  Wunderbar::Template::Html.evaluate('_polymer_element', self) do
52
- _polymer_element(*args) { instance_eval &block }
52
+ _polymer_element(*args) { instance_eval(&block) }
53
53
  end
54
54
  end
55
55
  end
@@ -5,7 +5,7 @@ module Wunderbar
5
5
  module Rails
6
6
  class HtmlHandler
7
7
  cattr_accessor :default_format
8
- self.default_format = Mime::HTML
8
+ self.default_format = Mime[:html]
9
9
 
10
10
  def self.call(template)
11
11
  %{
@@ -14,7 +14,7 @@ module Wunderbar
14
14
  instance_variables.each do |var|
15
15
  x.instance_variable_set var, instance_variable_get(var)
16
16
  end
17
- x.instance_eval &compiled
17
+ x.instance_eval(&compiled)
18
18
  x._.target!
19
19
  }.strip # take care to preserve line numbers in original source
20
20
  end
@@ -22,7 +22,7 @@ module Wunderbar
22
22
 
23
23
  class JsonHandler
24
24
  cattr_accessor :default_format
25
- self.default_format = Mime::JSON
25
+ self.default_format = Mime[:json]
26
26
 
27
27
  def self.call(template)
28
28
  %{
@@ -31,7 +31,7 @@ module Wunderbar
31
31
  instance_variables.each do |var|
32
32
  x.instance_variable_set var, instance_variable_get(var)
33
33
  end
34
- x.instance_eval &compiled
34
+ x.instance_eval(&compiled)
35
35
  x.target!
36
36
  }.strip # take care to preserve line numbers in original source
37
37
  end
@@ -9,6 +9,7 @@ module Wunderbar
9
9
  class ScriptNode
10
10
  attr_accessor :block, :binding
11
11
  def serialize(options, result, indent)
12
+ @block ||= nil
12
13
  if @block and @children.empty? and not @text
13
14
  width = options[:width]
14
15
  width -= indent.to_s.length if width
@@ -45,8 +46,8 @@ module Wunderbar
45
46
  end
46
47
 
47
48
  def self.ruby2js(*args, &block)
48
- callback = Proc.new do |scope, args, block|
49
- ruby2js(scope, *args, &block)
49
+ callback = Proc.new do |scope, callback_args, callback_block|
50
+ ruby2js(scope, *callback_args, &callback_block)
50
51
  end
51
52
  @queue << [callback, args, block]
52
53
  end
@@ -15,7 +15,7 @@ module Wunderbar
15
15
 
16
16
  if block
17
17
  Wunderbar::Template::Html.evaluate('html.rb', self) do
18
- _html(*args) { instance_eval &block }
18
+ _html(*args) { instance_eval(&block) }
19
19
  end
20
20
  else
21
21
  Wunderbar::Template::Html.evaluate('html.rb', self, *args)
@@ -31,7 +31,7 @@ module Wunderbar
31
31
 
32
32
  if block
33
33
  Wunderbar::Template::Xhtml.evaluate('xhtml.rb', self) do
34
- _xhtml(*args) { instance_eval &block }
34
+ _xhtml(*args) { instance_eval(&block) }
35
35
  end
36
36
  else
37
37
  Wunderbar::Template::Xhtml.evaluate('xhtml.rb', self, *args)
@@ -277,9 +277,9 @@ unless Wunderbar.queue.empty?
277
277
  pass unless task
278
278
 
279
279
  if xhr_json
280
- _json *task[1], &task[2]
280
+ _json(*task[1], &task[2])
281
281
  else
282
- _html *task[1], &task[2]
282
+ _html(*task[1], &task[2])
283
283
  end
284
284
  end
285
285
 
@@ -2,7 +2,7 @@ module Wunderbar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 21
5
+ TINY = 23
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -188,7 +188,7 @@ module Wunderbar
188
188
  sock1.send('x',0)
189
189
  sock1.close
190
190
  end
191
- channel.instance_eval &block
191
+ channel.instance_eval(&block)
192
192
  rescue Exception => exception
193
193
  channel._ :type=>:stderr, :line=>exception.inspect
194
194
  exception.backtrace.each do |frame|
@@ -209,7 +209,7 @@ module Wunderbar
209
209
  instance_eval &proc
210
210
  else
211
211
  sock1, sock2 = UNIXSocket.pair
212
- submit &proc
212
+ submit(&proc)
213
213
  sleep 0.3 while sock2.recv(1) != 'x'
214
214
  sock2.close
215
215
  end
data/wunderbar.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: wunderbar 1.0.21 ruby lib
2
+ # stub: wunderbar 1.0.23 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "wunderbar"
6
- s.version = "1.0.21"
6
+ s.version = "1.0.23"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Sam Ruby"]
11
- s.date = "2016-03-03"
11
+ s.date = "2016-07-30"
12
12
  s.description = " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML, Unicode\n (utf-8), consistently indented, readable applications.'\n"
13
13
  s.email = "rubys@intertwingly.net"
14
14
  s.files = ["COPYING", "README.md", "lib/wunderbar", "lib/wunderbar.rb", "lib/wunderbar/angularjs", "lib/wunderbar/angularjs.rb", "lib/wunderbar/angularjs/resource.rb", "lib/wunderbar/angularjs/route.rb", "lib/wunderbar/asset.rb", "lib/wunderbar/backtick.rb", "lib/wunderbar/bootstrap", "lib/wunderbar/bootstrap.rb", "lib/wunderbar/bootstrap/theme.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/coderay.rb", "lib/wunderbar/coffeescript.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/eventsource.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/jquery", "lib/wunderbar/jquery.rb", "lib/wunderbar/jquery/filter.rb", "lib/wunderbar/jquery/stupidtable.rb", "lib/wunderbar/listen.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/markdown.rb", "lib/wunderbar/marked.rb", "lib/wunderbar/node.rb", "lib/wunderbar/pagedown.rb", "lib/wunderbar/polymer.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/react.rb", "lib/wunderbar/script.rb", "lib/wunderbar/server.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/underscore.rb", "lib/wunderbar/vendor", "lib/wunderbar/vendor/Markdown.Converter.js", "lib/wunderbar/vendor/angular-resource.min.js", "lib/wunderbar/vendor/angular-route.min.js", "lib/wunderbar/vendor/angular.min.js", "lib/wunderbar/vendor/bootstrap-theme.min.css", "lib/wunderbar/vendor/bootstrap.min.css", "lib/wunderbar/vendor/bootstrap.min.js", "lib/wunderbar/vendor/eventsource.min.js", "lib/wunderbar/vendor/jquery-1.11.2.min.js", "lib/wunderbar/vendor/marked.min.js", "lib/wunderbar/vendor/polymer-v0.0.20131003.min.js", "lib/wunderbar/vendor/react-dom.min.js", "lib/wunderbar/vendor/react-with-addons.min.js", "lib/wunderbar/vendor/stupidtable.min.js", "lib/wunderbar/vendor/underscore-min.js", "lib/wunderbar/version.rb", "lib/wunderbar/websocket.rb", "wunderbar.gemspec"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.21
4
+ version: 1.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json