sinatra-respond_to 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.8.0 / 2011-10-09
2
+
3
+ * Compatibility with Sinatra 1.3
4
+
1
5
  === 0.7.0 / 2011-03-20
2
6
 
3
7
  * Compatibility with Sinatra 1.2
data/Gemfile.lock CHANGED
@@ -1,40 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sinatra-respond_to (0.7.0)
5
- sinatra (~> 1.2)
4
+ sinatra-respond_to (0.8.0)
5
+ sinatra (~> 1.3)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- builder (2.1.2)
11
- diff-lcs (1.1.2)
12
- haml (3.0.22)
13
- rack (1.2.1)
14
- rack-test (0.5.6)
10
+ builder (3.0.0)
11
+ diff-lcs (1.1.3)
12
+ haml (3.1.3)
13
+ rack (1.3.5)
14
+ rack-protection (1.1.4)
15
+ rack
16
+ rack-test (0.5.7)
15
17
  rack (>= 1.0)
16
- rcov (0.9.9)
18
+ rcov (0.9.11)
17
19
  rspec (2.5.0)
18
20
  rspec-core (~> 2.5.0)
19
21
  rspec-expectations (~> 2.5.0)
20
22
  rspec-mocks (~> 2.5.0)
21
- rspec-core (2.5.1)
23
+ rspec-core (2.5.2)
22
24
  rspec-expectations (2.5.0)
23
25
  diff-lcs (~> 1.1.2)
24
26
  rspec-mocks (2.5.0)
25
- sinatra (1.2.1)
26
- rack (~> 1.1)
27
- tilt (< 2.0, >= 1.2.2)
28
- tilt (1.2.2)
27
+ sass (3.1.10)
28
+ sinatra (1.3.1)
29
+ rack (~> 1.3, >= 1.3.4)
30
+ rack-protection (~> 1.1, >= 1.1.2)
31
+ tilt (~> 1.3, >= 1.3.3)
32
+ tilt (1.3.3)
29
33
 
30
34
  PLATFORMS
31
35
  ruby
32
36
 
33
37
  DEPENDENCIES
34
38
  builder (>= 2.0)
35
- bundler (~> 1.0.10)
39
+ bundler (~> 1.1.rc)
36
40
  haml (>= 3.0)
37
41
  rack-test (~> 0.5.6)
38
42
  rcov (~> 0.9.8)
39
43
  rspec (~> 2.5.0)
44
+ sass (>= 3.0)
40
45
  sinatra-respond_to!
data/Rakefile CHANGED
@@ -1,12 +1,11 @@
1
- require 'rubygems'
2
- require 'bundler'
1
+ require 'bundler/setup'
3
2
  Bundler::GemHelper.install_tasks
4
3
 
5
4
  begin
6
5
  require 'rspec/core/rake_task'
7
6
  desc 'Run specs'
8
7
  RSpec::Core::RakeTask.new do |t|
9
- t.rcov = true
8
+ t.rcov = true unless RUBY_VERSION =~ /^1\.9/
10
9
  t.rcov_opts = ['--sort coverage --text-summary --sort-reverse']
11
10
  t.rcov_opts << "--comments --exclude spec,pkg,#{ENV['GEM_HOME']}"
12
11
  end
@@ -13,7 +13,7 @@ module Sinatra
13
13
  module RespondTo
14
14
  class UnhandledFormat < Sinatra::NotFound; end
15
15
  class MissingTemplate < Sinatra::NotFound
16
- def code; 500 end
16
+ def code; 404 end
17
17
  end
18
18
 
19
19
  def self.registered(app)
@@ -36,7 +36,7 @@ module Sinatra
36
36
  # Let through sinatra image urls in development
37
37
  next if self.class.development? && request.path_info =~ %r{/__sinatra__/.*?.png}
38
38
 
39
- unless options.static? && options.public? && (request.get? || request.head?) && static_file?(request.path_info)
39
+ unless settings.static? && settings.public_folder? && (request.get? || request.head?) && static_file?(request.path_info)
40
40
  if request.params.has_key? 'format'
41
41
  format params['format']
42
42
  else
@@ -46,12 +46,12 @@ module Sinatra
46
46
  # for.
47
47
  request.path_info = request.path_info.sub %r{\.([^\./]+)$}, ''
48
48
 
49
- format $1 || (request.xhr? && options.assume_xhr_is_js? ? :js : options.default_content)
49
+ format $1 || (request.xhr? && settings.assume_xhr_is_js? ? :js : settings.default_content)
50
50
  end
51
51
  end
52
52
  end
53
53
 
54
- app.configure :development do |dev|
54
+ app.configure :development do |dev|
55
55
  dev.error UnhandledFormat do
56
56
  content_type :html, :charset => 'utf-8'
57
57
 
@@ -79,7 +79,7 @@ module Sinatra
79
79
 
80
80
  dev.error MissingTemplate do
81
81
  content_type :html, :charset => 'utf-8'
82
- response.status = request.env['sinatra.error'].code
82
+ response.status = 500
83
83
 
84
84
  engine = request.env['sinatra.error'].message.split('.').last
85
85
  engine = 'haml' unless ['haml', 'builder', 'erb'].include? engine
@@ -124,39 +124,30 @@ module Sinatra
124
124
  </html>
125
125
  HTML
126
126
  end
127
-
128
- end
129
-
130
- app.class_eval do
131
- # Changes in 1.0 Sinatra reuse render for layout so we store the
132
- # original value to tell us if this is an automatic attempt to do a
133
- # layout call. If it is, it might fail with Errno::ENOENT and we want
134
- # to pass that back to sinatra since it isn't a MissingTemplate error
135
- alias :render_without_format :render
136
- def render(*args, &block)
137
- assumed_layout = args[1] == :layout
138
- args[1] = "#{args[1]}.#{format}".to_sym if args[1].is_a?(::Symbol)
139
- render_without_format *args, &block
140
- rescue Errno::ENOENT => e
141
- raise MissingTemplate, "#{args[1]}.#{args[0]}" unless assumed_layout
142
- raise e
143
- end
144
- private :render
145
127
  end
146
128
  end
147
129
 
148
130
  module Helpers
131
+ # Changes in 1.0 Sinatra reuse render for layout so we store the
132
+ # original value to tell us if this is an automatic attempt to do a
133
+ # layout call. If it is, it might fail with Errno::ENOENT and we want
134
+ # to pass that back to sinatra since it isn't a MissingTemplate error
135
+ def render(*args, &block)
136
+ assumed_layout = args[1] == :layout
137
+ args[1] = "#{args[1]}.#{format}".to_sym if args[1].is_a?(::Symbol)
138
+ super *args, &block
139
+ rescue Errno::ENOENT
140
+ raise MissingTemplate, "#{args[1]}.#{args[0]}" unless assumed_layout
141
+ raise # Reraise original error
142
+ end
143
+ private :render
144
+
149
145
  # Patch the content_type function to remember the set type
150
146
  # This helps cut down on time in the format helper so it
151
147
  # doesn't have to do a reverse lookup on the header
152
- def self.included(klass)
153
- klass.class_eval do
154
- alias :content_type_without_save :content_type
155
- def content_type(*args)
156
- @_format = args.first.to_sym
157
- content_type_without_save *args
158
- end
159
- end
148
+ def content_type(*args)
149
+ @_format = args.first.to_sym
150
+ super
160
151
  end
161
152
 
162
153
  def format(val=nil)
@@ -174,7 +165,7 @@ module Sinatra
174
165
  # This is mostly just a helper so request.path_info isn't changed when
175
166
  # serving files from the public directory
176
167
  def static_file?(path)
177
- public_dir = File.expand_path(options.public)
168
+ public_dir = File.expand_path(settings.public_folder)
178
169
  path = File.expand_path(File.join(public_dir, unescape(path)))
179
170
 
180
171
  path[0, public_dir.length] == public_dir && File.file?(path)
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module RespondTo
3
- Version = '0.7.0'
3
+ Version = '0.8.0'
4
4
  end
5
5
  end
@@ -12,14 +12,15 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.required_rubygems_version = '>= 1.3.6'
14
14
 
15
- s.add_runtime_dependency 'sinatra', '~> 1.2'
15
+ s.add_runtime_dependency 'sinatra', '~> 1.3'
16
16
 
17
17
  s.add_development_dependency 'rspec', '~> 2.5.0'
18
18
  s.add_development_dependency 'rack-test', '~> 0.5.6'
19
19
  s.add_development_dependency 'rcov', '~> 0.9.8'
20
20
  s.add_development_dependency 'builder', '>= 2.0'
21
21
  s.add_development_dependency 'haml', '>= 3.0'
22
- s.add_development_dependency 'bundler', '~> 1.0.10'
22
+ s.add_development_dependency 'sass', '>= 3.0'
23
+ s.add_development_dependency 'bundler', '~> 1.1.rc'
23
24
 
24
25
  s.files = `git ls-files`.split("\n")
25
26
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/spec/app/test_app.rb CHANGED
@@ -8,7 +8,8 @@ class TestApp < Sinatra::Base
8
8
  register Sinatra::RespondTo
9
9
 
10
10
  set :views, File.join(File.dirname(__FILE__), 'views')
11
- set :public, File.join(File.dirname(__FILE__), 'public')
11
+ set :public_folder, File.join(File.dirname(__FILE__), 'public')
12
+ set :show_exceptions, false
12
13
 
13
14
  get '/resource' do
14
15
  respond_to do |wants|
@@ -52,4 +53,4 @@ class TestApp < Sinatra::Base
52
53
  wants.css { sass :missing }
53
54
  end
54
55
  end
55
- end
56
+ end
@@ -5,7 +5,7 @@ describe Sinatra::RespondTo do
5
5
  ::Sinatra::Base.mime_type(sym)
6
6
  end
7
7
 
8
- describe "options" do
8
+ describe "settings" do
9
9
  it "should initialize with :default_content set to :html" do
10
10
  TestApp.default_content.should == :html
11
11
  end
@@ -197,7 +197,7 @@ describe Sinatra::RespondTo do
197
197
  it "should show the /__sinatra__/500.png" do
198
198
  get '/missing-template'
199
199
 
200
- last_response.body.should =~ %r{src='/__sinatra__/500.png'}
200
+ last_response.body.should =~ %r{src=(?<quote>['"'])/__sinatra__/500.png\k<quote>}
201
201
  end
202
202
 
203
203
  it "should provide a contextual code example for the template engine" do
@@ -341,7 +341,7 @@ describe Sinatra::RespondTo do
341
341
  TestApp.disable :static
342
342
  end
343
343
 
344
- def options
344
+ def settings
345
345
  TestApp
346
346
  end
347
347
 
metadata CHANGED
@@ -1,105 +1,111 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sinatra-respond_to
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
4
5
  prerelease:
5
- version: 0.7.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Chris Hoffman
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-03-20 00:00:00 -05:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: sinatra
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70288457045960 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
18
+ requirements:
22
19
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "1.2"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70288457045960
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70288457044660 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
29
+ requirements:
33
30
  - - ~>
34
- - !ruby/object:Gem::Version
31
+ - !ruby/object:Gem::Version
35
32
  version: 2.5.0
36
33
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: rack-test
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70288457044660
36
+ - !ruby/object:Gem::Dependency
37
+ name: rack-test
38
+ requirement: &70288457043920 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
40
+ requirements:
44
41
  - - ~>
45
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
46
43
  version: 0.5.6
47
44
  type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: rcov
51
45
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70288457043920
47
+ - !ruby/object:Gem::Dependency
48
+ name: rcov
49
+ requirement: &70288457043240 !ruby/object:Gem::Requirement
53
50
  none: false
54
- requirements:
51
+ requirements:
55
52
  - - ~>
56
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
57
54
  version: 0.9.8
58
55
  type: :development
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: builder
62
56
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70288457043240
58
+ - !ruby/object:Gem::Dependency
59
+ name: builder
60
+ requirement: &70288457042560 !ruby/object:Gem::Requirement
64
61
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "2.0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '2.0'
69
66
  type: :development
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
67
+ prerelease: false
68
+ version_requirements: *70288457042560
69
+ - !ruby/object:Gem::Dependency
72
70
  name: haml
71
+ requirement: &70288457041720 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '3.0'
77
+ type: :development
73
78
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
79
+ version_requirements: *70288457041720
80
+ - !ruby/object:Gem::Dependency
81
+ name: sass
82
+ requirement: &70288457040280 !ruby/object:Gem::Requirement
75
83
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "3.0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '3.0'
80
88
  type: :development
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: bundler
84
89
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
90
+ version_requirements: *70288457040280
91
+ - !ruby/object:Gem::Dependency
92
+ name: bundler
93
+ requirement: &70288457038780 !ruby/object:Gem::Requirement
86
94
  none: false
87
- requirements:
95
+ requirements:
88
96
  - - ~>
89
- - !ruby/object:Gem::Version
90
- version: 1.0.10
97
+ - !ruby/object:Gem::Version
98
+ version: 1.1.rc
91
99
  type: :development
92
- version_requirements: *id007
100
+ prerelease: false
101
+ version_requirements: *70288457038780
93
102
  description:
94
- email:
103
+ email:
95
104
  - cehoffman@gmail.com
96
105
  executables: []
97
-
98
106
  extensions: []
99
-
100
107
  extra_rdoc_files: []
101
-
102
- files:
108
+ files:
103
109
  - .gitignore
104
110
  - .rspec
105
111
  - Changelog.rdoc
@@ -121,35 +127,34 @@ files:
121
127
  - spec/app/views/resource.xml.builder
122
128
  - spec/extension_spec.rb
123
129
  - spec/spec_helper.rb
124
- has_rdoc: true
125
130
  homepage: http://github.com/cehoffman/sinatra-respond_to
126
131
  licenses: []
127
-
128
132
  post_install_message:
129
133
  rdoc_options: []
130
-
131
- require_paths:
134
+ require_paths:
132
135
  - lib
133
- required_ruby_version: !ruby/object:Gem::Requirement
136
+ required_ruby_version: !ruby/object:Gem::Requirement
134
137
  none: false
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: "0"
139
- required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ segments:
143
+ - 0
144
+ hash: 890127812341403240
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
146
  none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
144
150
  version: 1.3.6
145
151
  requirements: []
146
-
147
152
  rubyforge_project:
148
- rubygems_version: 1.6.2
153
+ rubygems_version: 1.8.11
149
154
  signing_key:
150
155
  specification_version: 3
151
156
  summary: A respond_to style Rails block for baked-in web service support in Sinatra
152
- test_files:
157
+ test_files:
153
158
  - spec/app/production_error_app.rb
154
159
  - spec/app/public/static folder/.keep
155
160
  - spec/app/public/static.txt