sinatra-sinatra 0.8.10 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +5 -1
- data/README.rdoc +8 -2
- data/Rakefile +6 -1
- data/lib/sinatra.rb +5 -1
- data/lib/sinatra/base.rb +19 -20
- data/sinatra.gemspec +2 -2
- metadata +2 -2
data/CHANGES
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= 0.9.0
|
1
|
+
= 0.9.0 / 2009-01-18
|
2
2
|
|
3
3
|
* Works with and requires Rack >= 0.9.1
|
4
4
|
|
@@ -45,6 +45,10 @@
|
|
45
45
|
has the status code specified. It's also possible to register an error
|
46
46
|
page for a range of status codes: "error(500..599)".
|
47
47
|
|
48
|
+
* In-file templates are now automatically imported from the file that
|
49
|
+
requires 'sinatra'. The use_in_file_templates! method is still available
|
50
|
+
for loading templates from other files.
|
51
|
+
|
48
52
|
* Sinatra's testing support is no longer dependent on Test::Unit. Requiring
|
49
53
|
'sinatra/test' adds the Sinatra::Test module and Sinatra::TestHarness
|
50
54
|
class, which can be used with any test framework. The 'sinatra/test/unit',
|
data/README.rdoc
CHANGED
@@ -165,12 +165,13 @@ other templates.
|
|
165
165
|
|
166
166
|
Templates may be defined at the end of the source file:
|
167
167
|
|
168
|
+
require 'rubygems'
|
169
|
+
require 'sinatra'
|
170
|
+
|
168
171
|
get '/' do
|
169
172
|
haml :index
|
170
173
|
end
|
171
174
|
|
172
|
-
use_in_file_templates!
|
173
|
-
|
174
175
|
__END__
|
175
176
|
|
176
177
|
@@ layout
|
@@ -180,6 +181,11 @@ Templates may be defined at the end of the source file:
|
|
180
181
|
@@ index
|
181
182
|
%div.title Hello world!!!!!
|
182
183
|
|
184
|
+
NOTE: Sinatra will automaticly load any in-file-templates in the
|
185
|
+
source file that first required sinatra. If you have in-file-templates
|
186
|
+
in another source file you will need to explicitly call
|
187
|
+
+use_in_file_templates! on main in that file.
|
188
|
+
|
183
189
|
It's also possible to define named templates using the top-level template
|
184
190
|
method:
|
185
191
|
|
data/Rakefile
CHANGED
@@ -57,7 +57,12 @@ file package('.gem') => %w[dist/ sinatra.gemspec] + spec.files do |f|
|
|
57
57
|
end
|
58
58
|
|
59
59
|
file package('.tar.gz') => %w[dist/] + spec.files do |f|
|
60
|
-
sh
|
60
|
+
sh <<-SH
|
61
|
+
git archive \
|
62
|
+
--prefix=sinatra-#{source_version}/ \
|
63
|
+
--format=tar \
|
64
|
+
HEAD | gzip > #{f.name}
|
65
|
+
SH
|
61
66
|
end
|
62
67
|
|
63
68
|
# Rubyforge Release / Publish Tasks ==================================
|
data/lib/sinatra.rb
CHANGED
data/lib/sinatra/base.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rack'
|
|
4
4
|
require 'rack/builder'
|
5
5
|
|
6
6
|
module Sinatra
|
7
|
-
VERSION = '0.
|
7
|
+
VERSION = '0.9.0'
|
8
8
|
|
9
9
|
class Request < Rack::Request
|
10
10
|
def user_agent
|
@@ -380,14 +380,8 @@ module Sinatra
|
|
380
380
|
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
|
381
381
|
end
|
382
382
|
|
383
|
-
def invoke(
|
384
|
-
res = catch(:halt) {
|
385
|
-
if handler.respond_to?(:call)
|
386
|
-
instance_eval(&handler)
|
387
|
-
else
|
388
|
-
send(handler)
|
389
|
-
end
|
390
|
-
}
|
383
|
+
def invoke(block)
|
384
|
+
res = catch(:halt) { instance_eval(&block) }
|
391
385
|
case
|
392
386
|
when res.respond_to?(:to_str)
|
393
387
|
@response.body = [res]
|
@@ -499,8 +493,13 @@ module Sinatra
|
|
499
493
|
end
|
500
494
|
|
501
495
|
def use_in_file_templates!
|
502
|
-
line = caller.detect
|
503
|
-
|
496
|
+
line = caller.detect do |s|
|
497
|
+
[
|
498
|
+
/lib\/sinatra.*\.rb/,
|
499
|
+
/\(.*\)/,
|
500
|
+
/rubygems\/custom_require\.rb/
|
501
|
+
].all? { |x| s !~ x }
|
502
|
+
end
|
504
503
|
file = line.sub(/:\d+.*$/, '')
|
505
504
|
if data = ::IO.read(file).split('__END__')[1]
|
506
505
|
data.gsub!(/\r\n/, "\n")
|
@@ -562,10 +561,10 @@ module Sinatra
|
|
562
561
|
|
563
562
|
def get(path, opts={}, &block)
|
564
563
|
conditions = @conditions.dup
|
565
|
-
|
564
|
+
route('GET', path, opts, &block)
|
566
565
|
|
567
566
|
@conditions = conditions
|
568
|
-
head(path, opts) { invoke(
|
567
|
+
head(path, opts) { invoke(block) ; [] }
|
569
568
|
end
|
570
569
|
|
571
570
|
def put(path, opts={}, &bk); route 'PUT', path, opts, &bk; end
|
@@ -574,21 +573,20 @@ module Sinatra
|
|
574
573
|
def head(path, opts={}, &bk); route 'HEAD', path, opts, &bk; end
|
575
574
|
|
576
575
|
private
|
577
|
-
def route(
|
576
|
+
def route(verb, path, opts={}, &block)
|
578
577
|
host_name opts[:host] if opts.key?(:host)
|
579
578
|
user_agent opts[:agent] if opts.key?(:agent)
|
580
579
|
accept_mime_types opts[:provides] if opts.key?(:provides)
|
581
580
|
|
582
581
|
pattern, keys = compile(path)
|
583
582
|
conditions, @conditions = @conditions, []
|
584
|
-
method_name = "route { #{method} #{path} }"
|
585
|
-
nmethods = instance_methods.grep(rx = /#{Regexp.escape(method_name)}/).size
|
586
|
-
method_name += " [#{nmethods}]"
|
587
583
|
|
588
|
-
define_method
|
584
|
+
define_method "#{verb} #{path}", &block
|
585
|
+
unbound_method = instance_method("#{verb} #{path}")
|
586
|
+
block = lambda { unbound_method.bind(self).call }
|
589
587
|
|
590
|
-
(routes[
|
591
|
-
push([pattern, keys, conditions,
|
588
|
+
(routes[verb] ||= []).
|
589
|
+
push([pattern, keys, conditions, block]).last
|
592
590
|
end
|
593
591
|
|
594
592
|
def compile(path)
|
@@ -805,6 +803,7 @@ module Sinatra
|
|
805
803
|
def self.reload!
|
806
804
|
@reloading = true
|
807
805
|
superclass.send :inherited, self
|
806
|
+
$LOADED_FEATURES.delete("sinatra.rb")
|
808
807
|
::Kernel.load app_file
|
809
808
|
@reloading = false
|
810
809
|
end
|
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 = '0.
|
7
|
-
s.date = '2009-01-
|
6
|
+
s.version = '0.9.0'
|
7
|
+
s.date = '2009-01-18'
|
8
8
|
|
9
9
|
s.description = "Classy web-development dressed in a DSL"
|
10
10
|
s.summary = "Classy web-development dressed in a DSL"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|