wunderbar 0.17.2 → 0.17.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGQ5M2Y3ZTQwNmY2NjdmYWJiZGFjYjMxODg3YWFiNWIzZWJkOTRmMQ==
4
+ NTg5MmNjNzk0MzIzN2RlNWE4ZDI4YThiOGY1OTdhYzBiNTdmOTkyYg==
5
5
  data.tar.gz: !binary |-
6
- ZTE4NzljMTM3ZTI4MzdlMTkyYjQ2Mjc2YTVmYTgwOWQyYjY5NTMyMw==
6
+ MmJmZTQ3ZDI4N2FmOTMzNGQ3MzkyNWEyMWVjNTUzMWY1MDNkOGI2ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Y2NhYzRhNGNjMjM3NTczZDA1MDVlNThhYTcwMTQ3NGI4N2QzZDNiNzQ1ODky
10
- YzkwMmExNjQzOTcwMjdkYTk4NTAzOTI5NTFiYzEyMjhlNGRkZmIyMTZiMjQy
11
- MzEyNTcyMWFhNGI0MGNkYzdiZjEzMDlhMTU1M2VhMjExM2FmMWI=
9
+ YmM2NTRlZDZlNTkwZGNiNzEzZTJmMTBiMjc4Y2Y1ZDNjYzMwNDgwNjE2NzRm
10
+ MDBjZmU1YTMxODhiZTFmMzAxZjJkZDJhMzZhMTgzMDkxNDY2YjdjNWIwNGU4
11
+ YWU0YWY3Nzc2YTNjNmQ4OTBhMDc1YmU5NzE4MWM3OTgxYjgyYzM=
12
12
  data.tar.gz: !binary |-
13
- ZDc4OTFkNGY5ODU4MzY0OWM5N2ExNDA2ODcwZDUwYzk3OGJhMDg2Mzg5MGI0
14
- ODhlMTg0NzBhZWQ4YjZmODg0NmU5ZTA1MGQzMmMyZTIwYWIwNzkxNmE4ZGYy
15
- ODE2ZDEyNzFhMDYwMWFhODljZWNiMmFmZWY2MmZkMzc1ZjU0MTU=
13
+ M2JhYTZhNGY0ODJjMmNkODgwOWRlMmU4MDQyNGUyMDJmN2U1ZDRhNzM2YzYx
14
+ MjRiNTI4MjY3YWFjNmFlMTIwNWYxODZmNGI5MTY5ZGIzMTgwZjkzYTlhMjEy
15
+ YzkwOTBmNThkYTk4ZWU3NjlmOGYxNmE4ODRlYjUwNzg1YzFhYTg=
@@ -121,17 +121,35 @@ module Wunderbar
121
121
  end
122
122
 
123
123
  def call(scope)
124
+ # asset support for Rack
125
+ request = (scope.respond_to? :request) ? scope.request : nil
126
+ if request and request.path =~ %r{/assets/\w[-.\w]+}
127
+ path = ('.' + scope.request.path).untaint
128
+ headers = {'type' => 'text/plain'}
129
+ headers['type'] = 'application/javascript' if path =~ /\.js$/
130
+ out?(scope, headers) { File.read path if File.exist? path }
131
+ return
132
+ end
133
+
124
134
  env = scope.env
125
135
  accept = env['HTTP_ACCEPT'].to_s
126
136
  path_info = env['PATH_INFO'].to_s
127
137
 
128
138
  # implied request types
129
- xhr_json = Wunderbar::Options::XHR_JSON || (accept =~ /json/)
139
+ xhr_json = Wunderbar::Options::XHR_JSON || (accept =~ /json/) ||
140
+ env['HTTP_X_REQUESTED_WITH'].to_s == 'XMLHttpRequest'
130
141
  text = Wunderbar::Options::TEXT ||
131
142
  (accept =~ /plain/ and accept !~ /html/)
132
143
  @xhtml = (accept =~ /xhtml/ or accept == '')
133
144
  @pdf = (accept =~ /pdf/)
134
145
 
146
+ # parse json arguments
147
+ if xhr_json and request and request.respond_to? :body
148
+ if env['CONTENT_TYPE'] =~ %r{^application/json(;.*)?$}
149
+ scope.params.merge! JSON.parse(scope.request.body.read)
150
+ end
151
+ end
152
+
135
153
  # overrides via the command line
136
154
  xhtml_override = ARGV.include?('--xhtml')
137
155
  html_override = ARGV.include?('--html')
@@ -28,7 +28,8 @@ if port and ARGV.delete(port)
28
28
  # start the server
29
29
  require 'rack'
30
30
  require 'wunderbar/rack'
31
- Rack::Server.start :app => Wunderbar::RackApp.new, :Port => port,
31
+ app = Rack::Lock.new(Wunderbar::RackApp.new)
32
+ Rack::Server.start :app => app, :Port => port,
32
33
  :environment => (ENV['RACK_ENV'] || 'development')
33
34
  end
34
35
 
@@ -84,7 +85,17 @@ else
84
85
  ARGV.push '' if ARGV.empty?
85
86
  ARGV.delete('--prompt') or ARGV.delete('--offline')
86
87
 
88
+ payload = nil
89
+ if env['CONTENT_TYPE'] =~ %r{^application/json(;.*)?$}
90
+ # read payload before CGI.new eats $stdin
91
+ payload = JSON.parse($stdin.read) rescue nil
92
+ end
93
+
87
94
  cgi = CGI.new
95
+
96
+ cgi.params.merge!(payload) if payload rescue nil
97
+ payload = nil
98
+
88
99
  cgi.instance_variable_set '@env', ENV
89
100
  class << cgi
90
101
  attr_accessor :env
@@ -2,7 +2,7 @@ module Wunderbar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 17
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/wunderbar.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "wunderbar"
5
- s.version = "0.17.2"
5
+ s.version = "0.17.3"
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 = "2013-09-19"
9
+ s.date = "2013-09-21"
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
12
  s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar.rb", "lib/wunderbar", "lib/wunderbar/logger.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/jquery-1.10.2.min.js", "lib/wunderbar/environment.rb", "lib/wunderbar/server.rb", "lib/wunderbar/version.rb", "lib/wunderbar/asset.rb", "lib/wunderbar/websocket.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/opal-jquery.rb", "lib/wunderbar/jquery.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/opal.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/opal-browser.rb"]
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: 0.17.2
4
+ version: 0.17.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-19 00:00:00.000000000 Z
11
+ date: 2013-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder