sinatra 1.3.0.b → 1.3.0.c
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- data/CHANGES +15 -2
- data/Gemfile +10 -1
- data/README.rdoc +3 -0
- data/lib/sinatra/base.rb +10 -8
- data/sinatra.gemspec +3 -4
- data/test/coffee_test.rb +13 -9
- data/test/helper.rb +4 -0
- data/test/helpers_test.rb +21 -0
- metadata +11 -8
data/CHANGES
CHANGED
@@ -11,14 +11,23 @@
|
|
11
11
|
* Important: 1.8.6 support has been dropped. It is still usable if you use the
|
12
12
|
backports gem, but no longer officially supported. (Konstantin Haase)
|
13
13
|
|
14
|
-
* It is now possible to use a different target class for the top level
|
14
|
+
* It is now possible to use a different target class for the top level DSL (aka
|
15
15
|
classic style) than `Sinatra::Application` by setting `Delegator.target`.
|
16
16
|
This was mainly introduced to ease testing. (Konstantin Haase)
|
17
17
|
|
18
18
|
* Added `request.accept?` and `request.preferred_type` to ease dealing with
|
19
19
|
`Accept` headers. (Konstantin Haase)
|
20
20
|
|
21
|
-
= 1.2.
|
21
|
+
= 1.2.3 / 2011-04-13
|
22
|
+
|
23
|
+
* This release is compatible with Tilt 1.3, it will still work with Tilt 1.2.2,
|
24
|
+
however, if you want to use a newer Tilt version, you have to upgrade to at
|
25
|
+
least this version of Sinatra. (Konstantin Haase)
|
26
|
+
|
27
|
+
* Helpers dealing with time, like `expires`, handle objects that pretend to be
|
28
|
+
numbers, like `ActiveSupport::Duration`, better. (Konstantin Haase)
|
29
|
+
|
30
|
+
= 1.2.2 / 2011-04-08
|
22
31
|
|
23
32
|
* The `:provides => :js` condition now matches both `application/javascript`
|
24
33
|
and `text/javascript`. The `:provides => :xml` condition now matches both
|
@@ -108,6 +117,10 @@
|
|
108
117
|
* Sinatra now ships with a Gemfile for development dependencies, since it eases
|
109
118
|
supporting different platforms, like JRuby. (Konstantin Haase)
|
110
119
|
|
120
|
+
= 1.1.4 / 2011-04-13
|
121
|
+
|
122
|
+
* Compatible with Tilt 1.3. (Konstantin Haase)
|
123
|
+
|
111
124
|
= 1.1.3 / 2011-02-20
|
112
125
|
|
113
126
|
* Fixed issues with `user_agent` condition if the user agent header is missing.
|
data/Gemfile
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
# If you have issues with a gem: `bundle install --without-coffee-script`.
|
8
8
|
|
9
9
|
RUBY_ENGINE = 'ruby' unless defined? RUBY_ENGINE
|
10
|
+
TILT_REPO = "git://github.com/rtomayko/tilt.git"
|
10
11
|
|
11
12
|
source :rubygems unless ENV['QUICK']
|
12
13
|
gemspec
|
@@ -14,6 +15,15 @@ gemspec
|
|
14
15
|
gem 'rake'
|
15
16
|
gem 'rack-test', '>= 0.5.6'
|
16
17
|
|
18
|
+
# Allows stuff like `tilt=1.2.2 bundle install` or `tilt=master ...`.
|
19
|
+
# Used by the CI.
|
20
|
+
tilt = ENV['tilt'].dup || 'stable'
|
21
|
+
tilt.sub! 'tilt-', ''
|
22
|
+
if tilt != 'stable'
|
23
|
+
tilt = {:git => TILT_REPO, :branch => tilt} unless tilt =~ /(\d+\.)+\d+/
|
24
|
+
gem 'tilt', tilt
|
25
|
+
end
|
26
|
+
|
17
27
|
gem 'haml', '>= 3.0', :group => 'haml'
|
18
28
|
gem 'builder', :group => 'builder'
|
19
29
|
gem 'erubis', :group => 'erubis'
|
@@ -39,5 +49,4 @@ platforms :mri_18 do
|
|
39
49
|
# bundler platforms are broken
|
40
50
|
next if RUBY_ENGINE != 'ruby' or RUBY_VERSION > "1.8"
|
41
51
|
gem 'rcov', :group => 'rcov'
|
42
|
-
gem 'therubyracer', :group => 'coffee-script'
|
43
52
|
end
|
data/README.rdoc
CHANGED
@@ -1882,4 +1882,7 @@ SemVerTag.
|
|
1882
1882
|
* {Twitter}[http://twitter.com/sinatra]
|
1883
1883
|
* {Mailing List}[http://groups.google.com/group/sinatrarb/topics]
|
1884
1884
|
* {IRC: #sinatra}[irc://chat.freenode.net/#sinatra] on http://freenode.net
|
1885
|
+
* API documentation for the {latest release}[http://rubydoc.info/gems/sinatra]
|
1886
|
+
or the {current HEAD}[http://rubydoc.info/github/sinatra/sinatra] on
|
1887
|
+
http://rubydoc.info/
|
1885
1888
|
|
data/lib/sinatra/base.rb
CHANGED
@@ -6,7 +6,7 @@ require 'sinatra/showexceptions'
|
|
6
6
|
require 'tilt'
|
7
7
|
|
8
8
|
module Sinatra
|
9
|
-
VERSION = '1.3.0.
|
9
|
+
VERSION = '1.3.0.c'
|
10
10
|
|
11
11
|
# The request object. See Rack::Request for more info:
|
12
12
|
# http://rack.rubyforge.org/doc/classes/Rack/Request.html
|
@@ -340,8 +340,8 @@ module Sinatra
|
|
340
340
|
def expires(amount, *values)
|
341
341
|
values << {} unless values.last.kind_of?(Hash)
|
342
342
|
|
343
|
-
if Integer
|
344
|
-
time = Time.now + amount
|
343
|
+
if amount.is_a? Integer
|
344
|
+
time = Time.now + amount.to_i
|
345
345
|
max_age = amount
|
346
346
|
else
|
347
347
|
time = time_for amount
|
@@ -405,7 +405,7 @@ module Sinatra
|
|
405
405
|
def time_for(value)
|
406
406
|
if value.respond_to? :to_time
|
407
407
|
value.to_time
|
408
|
-
elsif Time
|
408
|
+
elsif value.is_a? Time
|
409
409
|
value
|
410
410
|
elsif value.respond_to? :new_offset
|
411
411
|
# DateTime#to_time does the same on 1.9
|
@@ -415,13 +415,13 @@ module Sinatra
|
|
415
415
|
elsif value.respond_to? :mday
|
416
416
|
# Date#to_time does the same on 1.9
|
417
417
|
Time.local(value.year, value.mon, value.mday)
|
418
|
-
elsif Numeric
|
418
|
+
elsif value.is_a? Numeric
|
419
419
|
Time.at value
|
420
420
|
else
|
421
421
|
Time.parse value.to_s
|
422
422
|
end
|
423
423
|
rescue ArgumentError => boom
|
424
|
-
raise boom
|
424
|
+
raise boom
|
425
425
|
rescue Exception
|
426
426
|
raise ArgumentError, "unable to convert #{value.inspect} to a Time object"
|
427
427
|
end
|
@@ -523,8 +523,9 @@ module Sinatra
|
|
523
523
|
# Calls the given block for every possible template file in views,
|
524
524
|
# named name.ext, where ext is registered on engine.
|
525
525
|
def find_template(views, name, engine)
|
526
|
-
|
527
|
-
|
526
|
+
yield ::File.join(views, "#{name}.#{@preferred_extension}")
|
527
|
+
Tilt.mappings.each do |ext, engines|
|
528
|
+
next unless ext != @preferred_extension and Array(engines).include? engine
|
528
529
|
yield ::File.join(views, "#{name}.#{ext}")
|
529
530
|
end
|
530
531
|
end
|
@@ -585,6 +586,7 @@ module Sinatra
|
|
585
586
|
template.new(path, line.to_i, options) { body }
|
586
587
|
else
|
587
588
|
found = false
|
589
|
+
@preferred_extension = engine.to_s
|
588
590
|
find_template(views, data, template) do |file|
|
589
591
|
path ||= file # keep the initial path rather than the last one
|
590
592
|
if found = File.exists?(file)
|
data/sinatra.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'sinatra'
|
6
|
-
s.version = '1.3.0.
|
7
|
-
s.date = '2011-04-
|
6
|
+
s.version = '1.3.0.c'
|
7
|
+
s.date = '2011-04-13'
|
8
8
|
|
9
9
|
s.description = "Classy web-development dressed in a DSL"
|
10
10
|
s.summary = "Classy web-development dressed in a DSL"
|
@@ -123,10 +123,9 @@ Gem::Specification.new do |s|
|
|
123
123
|
|
124
124
|
s.extra_rdoc_files = %w[README.rdoc README.de.rdoc README.jp.rdoc README.fr.rdoc README.es.rdoc README.hu.rdoc README.zh.rdoc LICENSE]
|
125
125
|
s.add_dependency 'rack', '~> 1.2'
|
126
|
-
s.add_dependency 'tilt', '
|
126
|
+
s.add_dependency 'tilt', '~> 1.2', '>= 1.2.2'
|
127
127
|
s.add_development_dependency 'shotgun', '~> 0.6'
|
128
128
|
|
129
|
-
s.has_rdoc = true
|
130
129
|
s.homepage = "http://sinatra.rubyforge.org"
|
131
130
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra", "--main", "README.rdoc"]
|
132
131
|
s.require_paths = %w[lib]
|
data/test/coffee_test.rb
CHANGED
@@ -2,6 +2,13 @@ require File.dirname(__FILE__) + '/helper'
|
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'coffee-script'
|
5
|
+
require 'execjs'
|
6
|
+
|
7
|
+
begin
|
8
|
+
ExecJS.compile '1'
|
9
|
+
rescue Exception
|
10
|
+
raise LoadError, 'unable to execute JavaScript'
|
11
|
+
end
|
5
12
|
|
6
13
|
class CoffeeTest < Test::Unit::TestCase
|
7
14
|
def coffee_app(options = {}, &block)
|
@@ -16,7 +23,7 @@ class CoffeeTest < Test::Unit::TestCase
|
|
16
23
|
it 'renders inline Coffee strings' do
|
17
24
|
coffee_app { coffee "alert 'Aye!'\n" }
|
18
25
|
assert ok?
|
19
|
-
|
26
|
+
assert body.include?("alert('Aye!');")
|
20
27
|
end
|
21
28
|
|
22
29
|
it 'defaults content type to javascript' do
|
@@ -45,13 +52,13 @@ class CoffeeTest < Test::Unit::TestCase
|
|
45
52
|
it 'renders .coffee files in views path' do
|
46
53
|
coffee_app { coffee :hello }
|
47
54
|
assert ok?
|
48
|
-
|
55
|
+
assert_include body, "alert(\"Aye!\");"
|
49
56
|
end
|
50
57
|
|
51
58
|
it 'ignores the layout option' do
|
52
59
|
coffee_app { coffee :hello, :layout => :layout2 }
|
53
60
|
assert ok?
|
54
|
-
|
61
|
+
assert_include body, "alert(\"Aye!\");"
|
55
62
|
end
|
56
63
|
|
57
64
|
it "raises error if template not found" do
|
@@ -62,21 +69,18 @@ class CoffeeTest < Test::Unit::TestCase
|
|
62
69
|
end
|
63
70
|
|
64
71
|
it "passes coffee options to the coffee engine" do
|
65
|
-
coffee_app {
|
66
|
-
coffee "alert 'Aye!'\n",
|
67
|
-
:no_wrap => true
|
68
|
-
}
|
72
|
+
coffee_app { coffee "alert 'Aye!'\n", :no_wrap => true }
|
69
73
|
assert ok?
|
70
74
|
assert_equal "alert('Aye!');", body
|
71
75
|
end
|
72
76
|
|
73
77
|
it "passes default coffee options to the coffee engine" do
|
74
|
-
mock_app
|
78
|
+
mock_app do
|
75
79
|
set :coffee, :no_wrap => true # default coffee style is :nested
|
76
80
|
get '/' do
|
77
81
|
coffee "alert 'Aye!'\n"
|
78
82
|
end
|
79
|
-
|
83
|
+
end
|
80
84
|
get '/'
|
81
85
|
assert ok?
|
82
86
|
assert_equal "alert('Aye!');", body
|
data/test/helper.rb
CHANGED
@@ -65,6 +65,10 @@ class Test::Unit::TestCase
|
|
65
65
|
assert_equal value.lstrip.gsub(/\s*\n\s*/, ""), body.lstrip.gsub(/\s*\n\s*/, "")
|
66
66
|
end
|
67
67
|
|
68
|
+
def assert_include(str, substr)
|
69
|
+
assert str.include?(substr), "expected #{str.inspect} to include #{substr.inspect}"
|
70
|
+
end
|
71
|
+
|
68
72
|
# Delegate other missing methods to response.
|
69
73
|
def method_missing(name, *args, &block)
|
70
74
|
if response && response.respond_to?(name)
|
data/test/helpers_test.rb
CHANGED
@@ -638,6 +638,18 @@ class HelpersTest < Test::Unit::TestCase
|
|
638
638
|
get '/baz' do
|
639
639
|
expires Time.at(0)
|
640
640
|
end
|
641
|
+
|
642
|
+
get '/blah' do
|
643
|
+
obj = Object.new
|
644
|
+
def obj.method_missing(*a, &b) 60.send(*a, &b) end
|
645
|
+
def obj.is_a?(thing) 60.is_a?(thing) end
|
646
|
+
expires obj, :public, :no_cache
|
647
|
+
'Hello World'
|
648
|
+
end
|
649
|
+
|
650
|
+
get '/boom' do
|
651
|
+
expires '1000'
|
652
|
+
end
|
641
653
|
end
|
642
654
|
end
|
643
655
|
|
@@ -660,6 +672,15 @@ class HelpersTest < Test::Unit::TestCase
|
|
660
672
|
get '/baz'
|
661
673
|
assert_equal 'Thu, 01 Jan 1970 00:00:00 GMT', response['Expires']
|
662
674
|
end
|
675
|
+
|
676
|
+
it 'accepts values pretending to be a Numeric (like ActiveSupport::Duration)' do
|
677
|
+
get '/blah'
|
678
|
+
assert_equal ['public', 'no-cache', 'max-age=60'], response['Cache-Control'].split(', ')
|
679
|
+
end
|
680
|
+
|
681
|
+
it 'fails when Time.parse raises an ArgumentError' do
|
682
|
+
assert_raise(ArgumentError) { get '/boom' }
|
683
|
+
end
|
663
684
|
end
|
664
685
|
|
665
686
|
describe 'last_modified' do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.3.0.
|
5
|
+
version: 1.3.0.c
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Blake Mizerany
|
@@ -13,12 +13,11 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2011-04-
|
16
|
+
date: 2011-04-13 00:00:00 +02:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: rack
|
21
|
-
prerelease: false
|
22
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
22
|
none: false
|
24
23
|
requirements:
|
@@ -26,24 +25,24 @@ dependencies:
|
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
version: "1.2"
|
28
27
|
type: :runtime
|
28
|
+
prerelease: false
|
29
29
|
version_requirements: *id001
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: tilt
|
32
|
-
prerelease: false
|
33
32
|
requirement: &id002 !ruby/object:Gem::Requirement
|
34
33
|
none: false
|
35
34
|
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: "1.2"
|
36
38
|
- - ">="
|
37
39
|
- !ruby/object:Gem::Version
|
38
40
|
version: 1.2.2
|
39
|
-
- - <
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: "2.0"
|
42
41
|
type: :runtime
|
42
|
+
prerelease: false
|
43
43
|
version_requirements: *id002
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: shotgun
|
46
|
-
prerelease: false
|
47
46
|
requirement: &id003 !ruby/object:Gem::Requirement
|
48
47
|
none: false
|
49
48
|
requirements:
|
@@ -51,6 +50,7 @@ dependencies:
|
|
51
50
|
- !ruby/object:Gem::Version
|
52
51
|
version: "0.6"
|
53
52
|
type: :development
|
53
|
+
prerelease: false
|
54
54
|
version_requirements: *id003
|
55
55
|
description: Classy web-development dressed in a DSL
|
56
56
|
email: sinatrarb@googlegroups.com
|
@@ -189,6 +189,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
189
|
requirements:
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
+
hash: -1589888549486616538
|
193
|
+
segments:
|
194
|
+
- 0
|
192
195
|
version: "0"
|
193
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
197
|
none: false
|