sinatra 1.2.2 → 1.2.3
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 +13 -0
- data/Gemfile +10 -0
- data/README.rdoc +3 -0
- data/lib/sinatra/base.rb +10 -8
- data/sinatra.gemspec +2 -3
- data/test/coffee_test.rb +13 -9
- data/test/helper.rb +4 -0
- data/test/helpers_test.rb +13 -0
- metadata +8 -5
data/CHANGES
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
= 1.2.3 / 2011-04-13
|
2
|
+
|
3
|
+
* This release is compatible with Tilt 1.3, it will still work with Tilt 1.2.2,
|
4
|
+
however, if you want to use a newer Tilt version, you have to upgrade to at
|
5
|
+
least this version of Sinatra. (Konstantin Haase)
|
6
|
+
|
7
|
+
* Helpers dealing with time, like `expires`, handle objects that pretend to be
|
8
|
+
numbers, like `ActiveSupport::Duration`, better. (Konstantin Haase)
|
9
|
+
|
1
10
|
= 1.2.2 / 2011-04-08
|
2
11
|
|
3
12
|
* The `:provides => :js` condition now matches both `application/javascript`
|
@@ -88,6 +97,10 @@
|
|
88
97
|
* Sinatra now ships with a Gemfile for development dependencies, since it eases
|
89
98
|
supporting different platforms, like JRuby. (Konstantin Haase)
|
90
99
|
|
100
|
+
= 1.1.4 / 2011-04-13
|
101
|
+
|
102
|
+
* Compatible with Tilt 1.3. (Konstantin Haase)
|
103
|
+
|
91
104
|
= 1.1.3 / 2011-02-20
|
92
105
|
|
93
106
|
* 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'
|
data/README.rdoc
CHANGED
@@ -1855,4 +1855,7 @@ SemVerTag.
|
|
1855
1855
|
* {Twitter}[http://twitter.com/sinatra]
|
1856
1856
|
* {Mailing List}[http://groups.google.com/group/sinatrarb/topics]
|
1857
1857
|
* {IRC: #sinatra}[irc://chat.freenode.net/#sinatra] on http://freenode.net
|
1858
|
+
* API documentation for the {latest release}[http://rubydoc.info/gems/sinatra]
|
1859
|
+
or the {current HEAD}[http://rubydoc.info/github/sinatra/sinatra] on
|
1860
|
+
http://rubydoc.info/
|
1858
1861
|
|
data/lib/sinatra/base.rb
CHANGED
@@ -7,7 +7,7 @@ require 'sinatra/showexceptions'
|
|
7
7
|
require 'tilt'
|
8
8
|
|
9
9
|
module Sinatra
|
10
|
-
VERSION = '1.2.
|
10
|
+
VERSION = '1.2.3'
|
11
11
|
|
12
12
|
# The request object. See Rack::Request for more info:
|
13
13
|
# http://rack.rubyforge.org/doc/classes/Rack/Request.html
|
@@ -345,8 +345,8 @@ module Sinatra
|
|
345
345
|
def expires(amount, *values)
|
346
346
|
values << {} unless values.last.kind_of?(Hash)
|
347
347
|
|
348
|
-
if Integer
|
349
|
-
time = Time.now + amount
|
348
|
+
if amount.is_a? Integer
|
349
|
+
time = Time.now + amount.to_i
|
350
350
|
max_age = amount
|
351
351
|
else
|
352
352
|
time = time_for amount
|
@@ -410,7 +410,7 @@ module Sinatra
|
|
410
410
|
def time_for(value)
|
411
411
|
if value.respond_to? :to_time
|
412
412
|
value.to_time
|
413
|
-
elsif Time
|
413
|
+
elsif value.is_a? Time
|
414
414
|
value
|
415
415
|
elsif value.respond_to? :new_offset
|
416
416
|
# DateTime#to_time does the same on 1.9
|
@@ -420,13 +420,13 @@ module Sinatra
|
|
420
420
|
elsif value.respond_to? :mday
|
421
421
|
# Date#to_time does the same on 1.9
|
422
422
|
Time.local(value.year, value.mon, value.mday)
|
423
|
-
elsif Numeric
|
423
|
+
elsif value.is_a? Numeric
|
424
424
|
Time.at value
|
425
425
|
else
|
426
426
|
Time.parse value.to_s
|
427
427
|
end
|
428
428
|
rescue ArgumentError => boom
|
429
|
-
raise boom
|
429
|
+
raise boom
|
430
430
|
rescue Exception
|
431
431
|
raise ArgumentError, "unable to convert #{value.inspect} to a Time object"
|
432
432
|
end
|
@@ -528,8 +528,9 @@ module Sinatra
|
|
528
528
|
# Calls the given block for every possible template file in views,
|
529
529
|
# named name.ext, where ext is registered on engine.
|
530
530
|
def find_template(views, name, engine)
|
531
|
-
|
532
|
-
|
531
|
+
yield ::File.join(views, "#{name}.#{@preferred_extension}")
|
532
|
+
Tilt.mappings.each do |ext, engines|
|
533
|
+
next unless ext != @preferred_extension and Array(engines).include? engine
|
533
534
|
yield ::File.join(views, "#{name}.#{ext}")
|
534
535
|
end
|
535
536
|
end
|
@@ -590,6 +591,7 @@ module Sinatra
|
|
590
591
|
template.new(path, line.to_i, options) { body }
|
591
592
|
else
|
592
593
|
found = false
|
594
|
+
@preferred_extension = engine.to_s
|
593
595
|
find_template(views, data, template) do |file|
|
594
596
|
path ||= file # keep the initial path rather than the last one
|
595
597
|
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.2.
|
7
|
-
s.date = '2011-04-
|
6
|
+
s.version = '1.2.3'
|
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"
|
@@ -125,7 +125,6 @@ Gem::Specification.new do |s|
|
|
125
125
|
s.add_dependency 'tilt', '>= 1.2.2', '< 2.0'
|
126
126
|
s.add_development_dependency 'shotgun', '~> 0.6'
|
127
127
|
|
128
|
-
s.has_rdoc = true
|
129
128
|
s.homepage = "http://sinatra.rubyforge.org"
|
130
129
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra", "--main", "README.rdoc"]
|
131
130
|
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
@@ -625,6 +625,14 @@ class HelpersTest < Test::Unit::TestCase
|
|
625
625
|
get '/baz' do
|
626
626
|
expires Time.at(0)
|
627
627
|
end
|
628
|
+
|
629
|
+
get '/blah' do
|
630
|
+
obj = Object.new
|
631
|
+
def obj.method_missing(*a, &b) 60.send(*a, &b) end
|
632
|
+
def obj.is_a?(thing) 60.is_a?(thing) end
|
633
|
+
expires obj, :public, :no_cache
|
634
|
+
'Hello World'
|
635
|
+
end
|
628
636
|
end
|
629
637
|
end
|
630
638
|
|
@@ -647,6 +655,11 @@ class HelpersTest < Test::Unit::TestCase
|
|
647
655
|
get '/baz'
|
648
656
|
assert_equal 'Thu, 01 Jan 1970 00:00:00 GMT', response['Expires']
|
649
657
|
end
|
658
|
+
|
659
|
+
it 'accepts values pretending to be a Numeric (like ActiveSupport::Duration)' do
|
660
|
+
get '/blah'
|
661
|
+
assert_equal ['public', 'no-cache', 'max-age=60'], response['Cache-Control'].split(', ')
|
662
|
+
end
|
650
663
|
end
|
651
664
|
|
652
665
|
describe 'last_modified' do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.3
|
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,10 +25,10 @@ dependencies:
|
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
version: "1.1"
|
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:
|
@@ -40,10 +39,10 @@ dependencies:
|
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
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
|
@@ -188,6 +188,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
188
|
requirements:
|
189
189
|
- - ">="
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
+
hash: -4509942912649873200
|
192
|
+
segments:
|
193
|
+
- 0
|
191
194
|
version: "0"
|
192
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
196
|
none: false
|