Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove trailing whitespaces

  • Loading branch information...
commit 498bad91059651ced6f26079c2b59d88de1a3505 1 parent 762967f
@etehtsea etehtsea authored
View
10 examples/chat.rb
@@ -25,11 +25,11 @@
@@ layout
<html>
- <head>
- <title>Super Simple Chat with Sinatra</title>
+ <head>
+ <title>Super Simple Chat with Sinatra</title>
<meta charset="utf-8" />
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
- </head>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
+ </head>
<body><%= yield %></body>
</html>
@@ -58,4 +58,4 @@
<form>
<input id='msg' placeholder='type message here...' />
-</form>
+</form>
View
2  lib/sinatra/base.rb
@@ -1348,7 +1348,7 @@ def encoded(char)
enc = "(?:#{enc}|#{encoded('+')})" if char == " "
enc
end
-
+
def escaped(char, enc = URI.escape(char))
[Regexp.escape(enc), URI.escape(char, /./)]
end
View
48 test/compile_test.rb
@@ -2,7 +2,7 @@
require File.expand_path('../helper', __FILE__)
class CompileTest < Test::Unit::TestCase
-
+
def self.converts pattern, expected_regexp
it "generates #{expected_regexp.source} from #{pattern}" do
compiled, _ = compiled pattern
@@ -14,7 +14,7 @@ def self.parses pattern, example, expected_params
compiled, keys = compiled pattern
match = compiled.match(example)
fail %Q{"#{example}" does not parse on pattern "#{pattern}".} unless match
-
+
# Aggregate e.g. multiple splat values into one array.
#
params = keys.zip(match.captures).reduce({}) do |hash, mapping|
@@ -26,7 +26,7 @@ def self.parses pattern, example, expected_params
end
hash
end
-
+
assert_equal(expected_params, params)
end
end
@@ -42,13 +42,13 @@ def compiled pattern
compiled, keys = app.send(:compile, pattern)
[compiled, keys]
end
-
+
converts "/", %r{\A/\z}
parses "/", "/", {}
-
+
converts "/foo", %r{\A/foo\z}
parses "/foo", "/foo", {}
-
+
converts "/:foo", %r{\A/([^/?#]+)\z}
parses "/:foo", "/foo", "foo" => "foo"
parses "/:foo", "/foo.bar", "foo" => "foo.bar"
@@ -57,33 +57,33 @@ def compiled pattern
fails "/:foo", "/foo/bar"
fails "/:foo", "/"
fails "/:foo", "/foo/"
-
+
converts "/föö", %r{\A/f%C3%B6%C3%B6\z}
parses "/föö", "/f%C3%B6%C3%B6", {}
-
+
converts "/:foo/:bar", %r{\A/([^/?#]+)/([^/?#]+)\z}
parses "/:foo/:bar", "/foo/bar", "foo" => "foo", "bar" => "bar"
-
+
converts "/hello/:person", %r{\A/hello/([^/?#]+)\z}
parses "/hello/:person", "/hello/Frank", "person" => "Frank"
-
+
converts "/?:foo?/?:bar?", %r{\A/?([^/?#]+)?/?([^/?#]+)?\z}
parses "/?:foo?/?:bar?", "/hello/world", "foo" => "hello", "bar" => "world"
parses "/?:foo?/?:bar?", "/hello", "foo" => "hello", "bar" => nil
parses "/?:foo?/?:bar?", "/", "foo" => nil, "bar" => nil
parses "/?:foo?/?:bar?", "", "foo" => nil, "bar" => nil
-
+
converts "/*", %r{\A/(.*?)\z}
parses "/*", "/", "splat" => ""
parses "/*", "/foo", "splat" => "foo"
parses "/*", "/foo/bar", "splat" => "foo/bar"
-
+
converts "/:foo/*", %r{\A/([^/?#]+)/(.*?)\z}
parses "/:foo/*", "/foo/bar/baz", "foo" => "foo", "splat" => "bar/baz"
-
+
converts "/:foo/:bar", %r{\A/([^/?#]+)/([^/?#]+)\z}
parses "/:foo/:bar", "/user@example.com/name", "foo" => "user@example.com", "bar" => "name"
-
+
converts "/test$/", %r{\A/test(?:\$|%24)/\z}
parses "/test$/", "/test$/", {}
@@ -91,45 +91,45 @@ def compiled pattern
parses "/te+st/", "/te+st/", {}
fails "/te+st/", "/test/"
fails "/te+st/", "/teeest/"
-
+
converts "/test(bar)/", %r{\A/test(?:\(|%28)bar(?:\)|%29)/\z}
parses "/test(bar)/", "/test(bar)/", {}
-
+
converts "/path with spaces", %r{\A/path(?:%20|(?:\+|%2B))with(?:%20|(?:\+|%2B))spaces\z}
parses "/path with spaces", "/path%20with%20spaces", {}
parses "/path with spaces", "/path%2Bwith%2Bspaces", {}
parses "/path with spaces", "/path+with+spaces", {}
-
+
converts "/foo&bar", %r{\A/foo(?:&|%26)bar\z}
parses "/foo&bar", "/foo&bar", {}
-
+
converts "/:foo/*", %r{\A/([^/?#]+)/(.*?)\z}
parses "/:foo/*", "/hello%20world/how%20are%20you", "foo" => "hello%20world", "splat" => "how%20are%20you"
-
+
converts "/*/foo/*/*", %r{\A/(.*?)/foo/(.*?)/(.*?)\z}
parses "/*/foo/*/*", "/bar/foo/bling/baz/boom", "splat" => ["bar", "bling", "baz/boom"]
fails "/*/foo/*/*", "/bar/foo/baz"
-
+
converts "/test.bar", %r{\A/test(?:\.|%2E)bar\z}
parses "/test.bar", "/test.bar", {}
fails "/test.bar", "/test0bar"
-
+
converts "/:file.:ext", %r{\A/([^\.%2E/?#]+)(?:\.|%2E)([^\.%2E/?#]+)\z}
parses "/:file.:ext", "/pony.jpg", "file" => "pony", "ext" => "jpg"
parses "/:file.:ext", "/pony%2Ejpg", "file" => "pony", "ext" => "jpg"
fails "/:file.:ext", "/.jpg"
-
+
converts "/:name.?:format?", %r{\A/([^\.%2E/?#]+)(?:\.|%2E)?([^\.%2E/?#]+)?\z}
parses "/:name.?:format?", "/foo", "name" => "foo", "format" => nil
parses "/:name.?:format?", "/foo.bar", "name" => "foo", "format" => "bar"
parses "/:name.?:format?", "/foo%2Ebar", "name" => "foo", "format" => "bar"
fails "/:name.?:format?", "/.bar"
-
+
converts "/:user@?:host?", %r{\A/([^@%40/?#]+)(?:@|%40)?([^@%40/?#]+)?\z}
parses "/:user@?:host?", "/foo@bar", "user" => "foo", "host" => "bar"
parses "/:user@?:host?", "/foo.foo@bar", "user" => "foo.foo", "host" => "bar"
parses "/:user@?:host?", "/foo@bar.bar", "user" => "foo", "host" => "bar.bar"
-
+
# From https://gist.github.com/2154980#gistcomment-169469.
#
# converts "/:name(.:format)?", %r{\A/([^\.%2E/?#]+)(?:\(|%28)(?:\.|%2E)([^\.%2E/?#]+)(?:\)|%29)?\z}
View
6 test/contest.rb
@@ -1,15 +1,15 @@
# Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
View
14 test/helpers_test.rb
@@ -586,21 +586,21 @@ def attachment_app(filename=nil)
end
end
end
-
+
it 'sets the Content-Type response header' do
attachment_app('test.xml')
get '/attachment'
assert_equal 'application/xml;charset=utf-8', response['Content-Type']
assert_equal '<sinatra></sinatra>', body
- end
-
+ end
+
it 'sets the Content-Type response header without extname' do
attachment_app('test')
get '/attachment'
assert_equal 'text/html;charset=utf-8', response['Content-Type']
- assert_equal '<sinatra></sinatra>', body
+ assert_equal '<sinatra></sinatra>', body
end
-
+
it 'sets the Content-Type response header with extname' do
mock_app do
get('/attachment') do
@@ -612,9 +612,9 @@ def attachment_app(filename=nil)
get '/attachment'
assert_equal 'application/atom+xml', response['Content-Type']
- assert_equal '<sinatra></sinatra>', body
+ assert_equal '<sinatra></sinatra>', body
end
-
+
end
describe 'send_file' do
View
2  test/liquid_test.rb
@@ -44,7 +44,7 @@ def liquid_app(&block)
mock_app { get('/') { liquid :no_such_template } }
assert_raise(Errno::ENOENT) { get('/') }
end
-
+
it "allows passing locals" do
liquid_app {
liquid '{{ value }}', :locals => { :value => 'foo' }
View
4 test/mapped_error_test.rb
@@ -211,7 +211,7 @@ def test_default
assert_equal 500, status
end
- it "allows a stack of exception_handlers" do
+ it "allows a stack of exception_handlers" do
mock_app do
set :raise_errors, false
error(FirstError) { 'First!' }
@@ -223,7 +223,7 @@ def test_default
assert_equal 'Second!', body
end
- it "allows an exception handler to pass control to the next exception handler" do
+ it "allows an exception handler to pass control to the next exception handler" do
mock_app do
set :raise_errors, false
error(500, FirstError) { 'First!' }
View
4 test/markaby_test.rb
@@ -55,7 +55,7 @@ def markaby_app(&block)
assert_equal "<h1>THIS. IS. <em>SPARTA</em></h1>", body
end
- it 'renders inline markaby blocks with file layouts' do
+ it 'renders inline markaby blocks with file layouts' do
markaby_app { markaby(:layout => :layout2) { text "Hello World" } }
assert ok?
assert_equal "<h1>Markaby Layout!</h1><p>Hello World</p>", body
@@ -65,7 +65,7 @@ def markaby_app(&block)
mock_app { get('/') { markaby :no_such_template } }
assert_raise(Errno::ENOENT) { get('/') }
end
-
+
it "allows passing locals" do
markaby_app {
markaby 'text value', :locals => { :value => 'foo' }
View
10 test/rabl_test.rb
@@ -34,7 +34,7 @@ def rabl_app(&block)
assert ok?
assert_equal '{"openstruct":{"bar":"baz"}}', body
end
-
+
it "renders with file layouts" do
rabl_app {
@foo = OpenStruct.new(:bar => 'baz')
@@ -43,14 +43,14 @@ def rabl_app(&block)
assert ok?
assert_equal '{"qux":{"openstruct":{"bar":"baz"}}}', body
end
-
+
it "raises error if template not found" do
mock_app {
get('/') { rabl :no_such_template }
}
assert_raise(Errno::ENOENT) { get('/') }
end
-
+
it "passes rabl options to the rabl engine" do
mock_app do
get('/') do
@@ -65,7 +65,7 @@ def rabl_app(&block)
assert ok?
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
end
-
+
it "passes default rabl options to the rabl engine" do
mock_app do
set :rabl, :format => 'xml'
@@ -81,7 +81,7 @@ def rabl_app(&block)
assert ok?
assert_body '<?xml version="1.0" encoding="UTF-8"?><openstruct><bar>baz</bar></openstruct>'
end
-
+
end
rescue LoadError
View
2  test/radius_test.rb
@@ -44,7 +44,7 @@ def radius_app(&block)
mock_app { get('/') { radius :no_such_template } }
assert_raise(Errno::ENOENT) { get('/') }
end
-
+
it "allows passing locals" do
radius_app {
radius '<r:value />', :locals => { :value => 'foo' }
View
4 test/route_added_hook_test.rb
@@ -47,13 +47,13 @@ class RouteAddedHookTest < Test::Unit::TestCase
assert_equal [["GET", "/"], ["HEAD", "/"]],
RouteAddedTest.routes
end
-
+
it "should pass route blocks as an argument" do
mock_app(Class.new(Sinatra::Base)) do
register RouteAddedTest
get('/') {}
end
- assert_kind_of Proc, RouteAddedTest.procs.first
+ assert_kind_of Proc, RouteAddedTest.procs.first
end
end
View
4 test/scss_test.rb
@@ -75,9 +75,9 @@ def scss_app(options = {}, &block)
mock_app do
set :scss, {:style => :compact} # default scss style is :nested
get('/') {
- scss("#scss {\n background-color: white;\n color: black;\n}")
+ scss("#scss {\n background-color: white;\n color: black;\n}")
}
- end
+ end
get '/'
assert ok?
assert_equal "#scss { background-color: white; color: black; }\n", body
View
2  test/sinatra_test.rb
@@ -5,7 +5,7 @@ class SinatraTest < Test::Unit::TestCase
app = Sinatra.new { get('/') { 'Hello World' } }
assert_same Sinatra::Base, app.superclass
end
-
+
it "responds to #template_cache" do
assert_kind_of Tilt::Cache, Sinatra::Base.new!.template_cache
end
View
16 test/slim_test.rb
@@ -17,13 +17,13 @@ def slim_app(&block)
assert ok?
assert_equal "<h1>Hiya</h1>", body
end
-
+
it 'renders .slim files in views path' do
slim_app { slim :hello }
assert ok?
assert_equal "<h1>Hello From Slim</h1>", body
end
-
+
it "renders with inline layouts" do
mock_app do
layout { %(h1\n | THIS. IS. \n == yield.upcase ) }
@@ -33,27 +33,27 @@ def slim_app(&block)
assert ok?
assert_equal "<h1>THIS. IS. <EM>SPARTA</EM></h1>", body
end
-
+
it "renders with file layouts" do
slim_app { slim('| Hello World', :layout => :layout2) }
assert ok?
assert_equal "<h1>Slim Layout!</h1><p>Hello World</p>", body
end
-
+
it "raises error if template not found" do
mock_app { get('/') { slim(:no_such_template) } }
assert_raise(Errno::ENOENT) { get('/') }
end
-
+
HTML4_DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
-
+
it "passes slim options to the slim engine" do
mock_app { get('/') { slim("x foo='bar'", :attr_wrapper => "'") }}
get '/'
assert ok?
assert_body "<x foo='bar'></x>"
end
-
+
it "passes default slim options to the slim engine" do
mock_app do
set :slim, :attr_wrapper => "'"
@@ -63,7 +63,7 @@ def slim_app(&block)
assert ok?
assert_body "<x foo='bar'></x>"
end
-
+
it "merges the default slim options with the overrides and passes them to the slim engine" do
mock_app do
set :slim, :attr_wrapper => "'"
View
2  test/templates_test.rb
@@ -288,7 +288,7 @@ def find_template(views, name, engine, &block)
@@ foo
this is foo
-@@ bar
+@@ bar
There's a space after 'bar'!
@@ foo bar
View
2  test/yajl_test.rb
@@ -50,7 +50,7 @@ def yajl_app(&block)
it 'decorates the json with a callback' do
yajl_app do
yajl(
- 'json = { :foo => "bar" }',
+ 'json = { :foo => "bar" }',
{ :callback => 'baz' }
)
end
Please sign in to comment.
Something went wrong with that request. Please try again.