wunderbar 0.21.3 → 0.21.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8badf15d87c160ff80047cf11daa11c075f52cd1
4
+ data.tar.gz: 49055a8e408472bfa4b868ea45dfbf3133aa09d4
5
+ SHA512:
6
+ metadata.gz: b325a928ba13e21146b98ecaea45a1eb53e7cece7e37c076f07b278373d9674798420370e295c798be7b20739106a189bba9095373ad45d22d3b0a8e3655eaa2
7
+ data.tar.gz: 76b378725828ff67d819119459e7aa480b9bd33d0284bd8dae28e37728e7fdcbdeb98f62933ee9f08b23d5993ea1024da7346d792f1e92a7fa3e0d6d2d2a8fd4
data/README.md CHANGED
@@ -21,6 +21,8 @@ A [tutorial](https://github.com/rubys/wunderbar/blob/master/docs/Introduction1.m
21
21
  Additional functionality is provided by
22
22
  [extensions](https://github.com/rubys/wunderbar/blob/master/docs/Extensions.md).
23
23
 
24
+ [![Build Status](https://travis-ci.org/rubys/wunderbar.svg)](https://travis-ci.org/rubys/wunderbar)
25
+
24
26
  Overview
25
27
  ---
26
28
 
@@ -334,7 +336,7 @@ are sent individually and as they are produced.
334
336
  `_.recv` or `_.pop` can be used to receive arbitrary strings. More commonly,
335
337
  `_.subscribe` is used to register a block that is used as a callback.
336
338
 
337
- `_.system` will run an aritrary command. Lines of output are sent across the
339
+ `_.system` will run an arbitrary command. Lines of output are sent across the
338
340
  websocket as they are received as JSON encoded hashes with two values: `type`
339
341
  is one of `stdin`, `stdout` or `stderr`; and `line` which contains the line
340
342
  itself. If the command is an array, the elements of the array will be escaped
@@ -0,0 +1,11 @@
1
+ # Redefine backtic in HTML templates to do a Ruby => JS conversion. Useful
2
+ # when there is a substantial amount of embedded JavaScript, for example
3
+ # when using Angular.js
4
+
5
+ require 'ruby2js'
6
+
7
+ class Wunderbar::HtmlMarkup
8
+ def `(input)
9
+ Ruby2JS.convert(input)
10
+ end
11
+ end
@@ -27,6 +27,75 @@ module Wunderbar
27
27
  end
28
28
  Wunderbar.websocket(*args, &block)
29
29
  end
30
+
31
+ # execute a system command, echoing stdin, stdout, and stderr
32
+ def system(command, opts={})
33
+ if command.respond_to? :flatten
34
+ flat = command.flatten
35
+ secret = command - flat
36
+ begin
37
+ # if available, use escape as it does prettier quoting
38
+ require 'escape'
39
+ echo = Escape.shell_command(command.compact - secret)
40
+ rescue LoadError
41
+ # std-lib function that gets the job done
42
+ require 'shellwords'
43
+ echo = Shellwords.join(command.compact - secret)
44
+ end
45
+ command = flat.compact.map(&:dup).map(&:untaint)
46
+ else
47
+ echo = command
48
+ command = [command]
49
+ end
50
+
51
+ patterns = opts[:hilite] || []
52
+ patterns=[patterns] if String === patterns or Regexp === patterns
53
+ patterns.map! do |pattern|
54
+ String === pattern ? Regexp.new(Regexp.escape(pattern)) : pattern
55
+ end
56
+
57
+ yield :stdin, echo unless opts[:echo] == false
58
+
59
+ require 'open3'
60
+ require 'thread'
61
+ semaphore = Mutex.new
62
+ Open3.popen3(*command) do |pin, pout, perr, wait|
63
+ [
64
+ Thread.new do
65
+ until pout.eof?
66
+ out_line = pout.readline.chomp
67
+ semaphore.synchronize do
68
+ if patterns.any? {|pattern| out_line =~ pattern}
69
+ yield :hilight, out_line
70
+ else
71
+ yield :stdout, out_line
72
+ end
73
+ end
74
+ end
75
+ end,
76
+
77
+ Thread.new do
78
+ until perr.eof?
79
+ err_line = perr.readline.chomp
80
+ semaphore.synchronize do
81
+ yield :stderr, err_line
82
+ end
83
+ end
84
+ end,
85
+
86
+ Thread.new do
87
+ if opts[:stdin].respond_to? :read
88
+ require 'fileutils'
89
+ FileUtils.copy_stream opts[:stdin], pin
90
+ elsif opts[:stdin]
91
+ pin.write opts[:stdin].to_s
92
+ end
93
+ pin.close
94
+ end
95
+ ].each {|thread| thread.join}
96
+ wait and wait.value.exitstatus
97
+ end
98
+ end
30
99
  end
31
100
 
32
101
  class XmlMarkup < BuilderClass
@@ -167,77 +236,15 @@ module Wunderbar
167
236
 
168
237
  # execute a system command, echoing stdin, stdout, and stderr
169
238
  def system(command, opts={})
170
- if command.respond_to? :flatten
171
- flat = command.flatten
172
- secret = command - flat
173
- begin
174
- # if available, use escape as it does prettier quoting
175
- require 'escape'
176
- echo = Escape.shell_command(command.compact - secret)
177
- rescue LoadError
178
- # std-lib function that gets the job done
179
- require 'shellwords'
180
- echo = Shellwords.join(command.compact - secret)
181
- end
182
- command = flat.compact.map(&:dup).map(&:untaint)
183
- else
184
- echo = command
185
- command = [command]
186
- end
187
-
188
- patterns = opts[:hilite] || []
189
- patterns=[patterns] if String === patterns or Regexp === patterns
190
- patterns.map! do |pattern|
191
- String === pattern ? Regexp.new(Regexp.escape(pattern)) : pattern
192
- end
193
-
194
- require 'open3'
195
239
  tag = opts[:tag] || 'pre'
196
240
  output_class = opts[:class] || {}
197
- stdin = output_class[:stdin] || '_stdin'
198
- stdout = output_class[:stdout] || '_stdout'
199
- stderr = output_class[:stderr] || '_stderr'
200
- hilite = output_class[:hilite] || '_stdout _hilite'
201
-
202
- tag! tag, echo, :class=>stdin unless opts[:echo] == false
203
-
204
- require 'thread'
205
- semaphore = Mutex.new
206
- Open3.popen3(*command) do |pin, pout, perr, wait|
207
- [
208
- Thread.new do
209
- until pout.eof?
210
- out_line = pout.readline.chomp
211
- semaphore.synchronize do
212
- if patterns.any? {|pattern| out_line =~ pattern}
213
- tag! tag, out_line, :class=>hilite
214
- else
215
- tag! tag, out_line, :class=>stdout
216
- end
217
- end
218
- end
219
- end,
241
+ output_class[:stdin] ||= '_stdin'
242
+ output_class[:stdout] ||= '_stdout'
243
+ output_class[:stderr] ||= '_stderr'
244
+ output_class[:hilite] ||= '_stdout _hilite'
220
245
 
221
- Thread.new do
222
- until perr.eof?
223
- err_line = perr.readline.chomp
224
- semaphore.synchronize do
225
- tag! tag, err_line, :class=>stderr
226
- end
227
- end
228
- end,
229
-
230
- Thread.new do
231
- if opts[:stdin].respond_to? :read
232
- require 'fileutils'
233
- FileUtils.copy_stream opts[:stdin], pin
234
- elsif opts[:stdin]
235
- pin.write opts[:stdin].to_s
236
- end
237
- pin.close
238
- end
239
- ].each {|thread| thread.join}
240
- wait and wait.value.exitstatus
246
+ super do |kind, line|
247
+ tag! tag, line, class: output_class[kind]
241
248
  end
242
249
  end
243
250
 
@@ -399,6 +406,16 @@ module Wunderbar
399
406
  end
400
407
  end
401
408
 
409
+ # execute a system command, echoing stdin, stdout, and stderr
410
+ def system(command, opts={})
411
+ output_prefix = opts[:prefix] || {}
412
+ output_prefix[:stdin] ||= '$ '
413
+
414
+ super do |kind, line|
415
+ @_target.puts "#{output_prefix[kind]}#{line}"
416
+ end
417
+ end
418
+
402
419
  def target!
403
420
  @_target.string
404
421
  end
@@ -503,6 +520,18 @@ module Wunderbar
503
520
  end
504
521
  end
505
522
 
523
+ # execute a system command, echoing stdin, stdout, and stderr
524
+ def system(command, opts={})
525
+ transcript = opts[:transcript] || 'transcript'
526
+ output_prefix = opts[:prefix] || {}
527
+ output_prefix[:stdin] ||= '$ '
528
+ @_target[transcript] ||= []
529
+
530
+ super do |kind, line|
531
+ @_target[transcript] << "#{output_prefix[kind]}#{line}"
532
+ end
533
+ end
534
+
506
535
  def target!
507
536
  begin
508
537
  JSON.pretty_generate(@_target)+ "\n"
@@ -510,5 +539,13 @@ module Wunderbar
510
539
  @_target.to_json + "\n"
511
540
  end
512
541
  end
542
+
543
+ def target?(type=nil)
544
+ if Class === type
545
+ type === @_target
546
+ else
547
+ @_target
548
+ end
549
+ end
513
550
  end
514
551
  end
@@ -12,7 +12,7 @@ module Wunderbar
12
12
  headers['status'] = "404 Not Found" if output == {}
13
13
  rescue Exception => exception
14
14
  headers['status'] = "500 Internal Server Error"
15
- builder._! Hash.new
15
+ builder._! Hash.new unless builder.target? Hash
16
16
  builder._exception exception
17
17
  ensure
18
18
  out?(scope, headers) { builder.target! }
@@ -2,7 +2,7 @@ module Wunderbar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 21
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/wunderbar.gemspec CHANGED
@@ -2,22 +2,22 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "wunderbar"
5
- s.version = "0.21.3"
5
+ s.version = "0.21.4"
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 = "2014-05-13"
9
+ s.date = "2014-06-24"
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/script.rb", "lib/wunderbar/jquery.rb", "lib/wunderbar/underscore.rb", "lib/wunderbar/polymer.rb", "lib/wunderbar/jquery", "lib/wunderbar/jquery/filter.rb", "lib/wunderbar/jquery/stupidtable.rb", "lib/wunderbar/vendor", "lib/wunderbar/vendor/polymer-v0.0.20131003.min.js", "lib/wunderbar/vendor/stupidtable.min.js", "lib/wunderbar/vendor/bootstrap.min.js", "lib/wunderbar/vendor/Markdown.Converter.js", "lib/wunderbar/vendor/angular.min.js", "lib/wunderbar/vendor/bootstrap-theme.min.css", "lib/wunderbar/vendor/jquery-1.11.0.min.js", "lib/wunderbar/vendor/angular-resource.min.js", "lib/wunderbar/vendor/bootstrap.min.css", "lib/wunderbar/vendor/underscore-min.js", "lib/wunderbar/vendor/angular-route.min.js", "lib/wunderbar/websocket.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/pagedown.rb", "lib/wunderbar/version.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/server.rb", "lib/wunderbar/angularjs.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/asset.rb", "lib/wunderbar/opal", "lib/wunderbar/opal/browser.rb", "lib/wunderbar/opal/jquery.rb", "lib/wunderbar/coffeescript.rb", "lib/wunderbar/markdown.rb", "lib/wunderbar/opal.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/bootstrap.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/angularjs", "lib/wunderbar/angularjs/resource.rb", "lib/wunderbar/angularjs/route.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/coderay.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/bootstrap", "lib/wunderbar/bootstrap/theme.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/node.rb"]
12
+ s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar", "lib/wunderbar/angularjs", "lib/wunderbar/angularjs/resource.rb", "lib/wunderbar/angularjs/route.rb", "lib/wunderbar/angularjs.rb", "lib/wunderbar/asset.rb", "lib/wunderbar/backtick.rb", "lib/wunderbar/bootstrap", "lib/wunderbar/bootstrap/theme.rb", "lib/wunderbar/bootstrap.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/html-methods.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/jquery", "lib/wunderbar/jquery/filter.rb", "lib/wunderbar/jquery/stupidtable.rb", "lib/wunderbar/jquery.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/markdown.rb", "lib/wunderbar/node.rb", "lib/wunderbar/opal", "lib/wunderbar/opal/browser.rb", "lib/wunderbar/opal/jquery.rb", "lib/wunderbar/opal.rb", "lib/wunderbar/pagedown.rb", "lib/wunderbar/polymer.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/script.rb", "lib/wunderbar/server.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/underscore.rb", "lib/wunderbar/vendor", "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/jquery-1.11.0.min.js", "lib/wunderbar/vendor/Markdown.Converter.js", "lib/wunderbar/vendor/polymer-v0.0.20131003.min.js", "lib/wunderbar/vendor/stupidtable.min.js", "lib/wunderbar/vendor/underscore-min.js", "lib/wunderbar/version.rb", "lib/wunderbar/websocket.rb", "lib/wunderbar.rb"]
13
13
  s.homepage = "http://github.com/rubys/wunderbar"
14
14
  s.licenses = ["MIT"]
15
15
  s.require_paths = ["lib"]
16
- s.rubygems_version = "1.8.23"
16
+ s.rubygems_version = "2.0.14"
17
17
  s.summary = "HTML Generator and CGI application support"
18
18
 
19
19
  if s.respond_to? :specification_version then
20
- s.specification_version = 3
20
+ s.specification_version = 4
21
21
 
22
22
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
23
  s.add_runtime_dependency(%q<json>, [">= 0"])
metadata CHANGED
@@ -1,36 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.3
5
- prerelease:
4
+ version: 0.21.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sam Ruby
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-05-13 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
- description: ! " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML,
31
- Unicode\n (utf-8), consistently indented, readable applications. This includes\n
32
- \ output that conforms to the Polyglot specification and the emerging\n results
33
- from the XML Error Recovery Community Group.\n"
27
+ description: |2
28
+ Wunderbar makes it easy to produce valid HTML5, wellformed XHTML, Unicode
29
+ (utf-8), consistently indented, readable applications. This includes
30
+ output that conforms to the Polyglot specification and the emerging
31
+ results from the XML Error Recovery Community Group.
34
32
  email: rubys@intertwingly.net
35
33
  executables: []
36
34
  extensions: []
@@ -39,75 +37,75 @@ files:
39
37
  - wunderbar.gemspec
40
38
  - README.md
41
39
  - COPYING
42
- - lib/wunderbar.rb
43
- - lib/wunderbar/script.rb
44
- - lib/wunderbar/jquery.rb
45
- - lib/wunderbar/underscore.rb
46
- - lib/wunderbar/polymer.rb
47
- - lib/wunderbar/jquery/filter.rb
48
- - lib/wunderbar/jquery/stupidtable.rb
49
- - lib/wunderbar/vendor/polymer-v0.0.20131003.min.js
50
- - lib/wunderbar/vendor/stupidtable.min.js
51
- - lib/wunderbar/vendor/bootstrap.min.js
52
- - lib/wunderbar/vendor/Markdown.Converter.js
53
- - lib/wunderbar/vendor/angular.min.js
54
- - lib/wunderbar/vendor/bootstrap-theme.min.css
55
- - lib/wunderbar/vendor/jquery-1.11.0.min.js
56
- - lib/wunderbar/vendor/angular-resource.min.js
57
- - lib/wunderbar/vendor/bootstrap.min.css
58
- - lib/wunderbar/vendor/underscore-min.js
59
- - lib/wunderbar/vendor/angular-route.min.js
60
- - lib/wunderbar/websocket.rb
61
- - lib/wunderbar/environment.rb
62
- - lib/wunderbar/pagedown.rb
63
- - lib/wunderbar/version.rb
64
- - lib/wunderbar/cgi-methods.rb
65
- - lib/wunderbar/server.rb
40
+ - lib/wunderbar/angularjs/resource.rb
41
+ - lib/wunderbar/angularjs/route.rb
66
42
  - lib/wunderbar/angularjs.rb
67
- - lib/wunderbar/logger.rb
68
43
  - lib/wunderbar/asset.rb
69
- - lib/wunderbar/opal/browser.rb
70
- - lib/wunderbar/opal/jquery.rb
71
- - lib/wunderbar/coffeescript.rb
72
- - lib/wunderbar/markdown.rb
73
- - lib/wunderbar/opal.rb
74
- - lib/wunderbar/installation.rb
44
+ - lib/wunderbar/backtick.rb
45
+ - lib/wunderbar/bootstrap/theme.rb
75
46
  - lib/wunderbar/bootstrap.rb
76
- - lib/wunderbar/job-control.rb
77
- - lib/wunderbar/sinatra.rb
78
- - lib/wunderbar/rails.rb
79
- - lib/wunderbar/angularjs/resource.rb
80
- - lib/wunderbar/angularjs/route.rb
81
- - lib/wunderbar/rack.rb
82
- - lib/wunderbar/coderay.rb
83
47
  - lib/wunderbar/builder.rb
84
- - lib/wunderbar/bootstrap/theme.rb
48
+ - lib/wunderbar/cgi-methods.rb
49
+ - lib/wunderbar/coderay.rb
50
+ - lib/wunderbar/coffeescript.rb
85
51
  - lib/wunderbar/cssproxy.rb
52
+ - lib/wunderbar/environment.rb
86
53
  - lib/wunderbar/html-methods.rb
54
+ - lib/wunderbar/installation.rb
55
+ - lib/wunderbar/job-control.rb
56
+ - lib/wunderbar/jquery/filter.rb
57
+ - lib/wunderbar/jquery/stupidtable.rb
58
+ - lib/wunderbar/jquery.rb
59
+ - lib/wunderbar/logger.rb
60
+ - lib/wunderbar/markdown.rb
87
61
  - lib/wunderbar/node.rb
62
+ - lib/wunderbar/opal/browser.rb
63
+ - lib/wunderbar/opal/jquery.rb
64
+ - lib/wunderbar/opal.rb
65
+ - lib/wunderbar/pagedown.rb
66
+ - lib/wunderbar/polymer.rb
67
+ - lib/wunderbar/rack.rb
68
+ - lib/wunderbar/rails.rb
69
+ - lib/wunderbar/script.rb
70
+ - lib/wunderbar/server.rb
71
+ - lib/wunderbar/sinatra.rb
72
+ - lib/wunderbar/underscore.rb
73
+ - lib/wunderbar/vendor/angular-resource.min.js
74
+ - lib/wunderbar/vendor/angular-route.min.js
75
+ - lib/wunderbar/vendor/angular.min.js
76
+ - lib/wunderbar/vendor/bootstrap-theme.min.css
77
+ - lib/wunderbar/vendor/bootstrap.min.css
78
+ - lib/wunderbar/vendor/bootstrap.min.js
79
+ - lib/wunderbar/vendor/jquery-1.11.0.min.js
80
+ - lib/wunderbar/vendor/Markdown.Converter.js
81
+ - lib/wunderbar/vendor/polymer-v0.0.20131003.min.js
82
+ - lib/wunderbar/vendor/stupidtable.min.js
83
+ - lib/wunderbar/vendor/underscore-min.js
84
+ - lib/wunderbar/version.rb
85
+ - lib/wunderbar/websocket.rb
86
+ - lib/wunderbar.rb
88
87
  homepage: http://github.com/rubys/wunderbar
89
88
  licenses:
90
89
  - MIT
90
+ metadata: {}
91
91
  post_install_message:
92
92
  rdoc_options: []
93
93
  require_paths:
94
94
  - lib
95
95
  required_ruby_version: !ruby/object:Gem::Requirement
96
- none: false
97
96
  requirements:
98
- - - ! '>='
97
+ - - '>='
99
98
  - !ruby/object:Gem::Version
100
99
  version: '0'
101
100
  required_rubygems_version: !ruby/object:Gem::Requirement
102
- none: false
103
101
  requirements:
104
- - - ! '>='
102
+ - - '>='
105
103
  - !ruby/object:Gem::Version
106
104
  version: '0'
107
105
  requirements: []
108
106
  rubyforge_project:
109
- rubygems_version: 1.8.23
107
+ rubygems_version: 2.0.14
110
108
  signing_key:
111
- specification_version: 3
109
+ specification_version: 4
112
110
  summary: HTML Generator and CGI application support
113
111
  test_files: []