sinatra-xsendfile 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,30 +2,50 @@
2
2
 
3
3
  `sinatra-xsendfile` extension provides `x_send_file` helper method for sending files faster
4
4
 
5
+
5
6
  ##XSendFile
6
7
  * in [lighttpd](http://redmine.lighttpd.net/projects/1/wiki/X-LIGHTTPD-send-file);
7
8
  * in [apache](http://tn123.ath.cx/mod_xsendfile/);
8
9
  * in [nginx](http://wiki.nginx.org/NginxXSendfile).
9
10
 
10
11
 
12
+ ##Installation
13
+
14
+ If you use [bundler](http://gembundler.com/), simply specify
15
+ `sinatra-xsendfile` as a dependency in a Gemfile in your project's root:
16
+
17
+ gem 'sinatra-xsendfile'
18
+
19
+ and run `bundle install`.
20
+
21
+ Otherwise install the gem as usual:
22
+
23
+ [sudo] gem install sinatra-xsendfile
24
+
25
+
11
26
  ##Example
12
27
  require 'rubygems'
13
28
  require 'sinatra'
14
- require 'sinatra-xsendfile'
29
+ require 'sinatra/xsendfile'
15
30
 
16
31
  configure :production do
17
- Sinatra::Xsendfile.replace_send_file! #replaces sinatra's send_file with x_send_file
18
- set :xsf_header, 'X-Accel-Redirect' #setting default(X-SendFile) header (nginx)
32
+ Sinatra::Xsendfile.replace_send_file! # replace Sinatra's send_file with x_send_file
33
+ set :xsf_header, 'X-Accel-Redirect' # set x_send_file header (default: X-SendFile)
19
34
  end
20
35
 
21
36
  get '/' do
22
37
  x_send_file(__FILE__)
23
38
  end
24
39
 
25
- get '/nginx' do
26
- x_send_file(__FILE__, :header => 'X-LIGHTTPD-send-file')
40
+ get '/lighttpd' do
41
+ x_send_file(__FILE__, :header => 'X-LIGHTTPD-send-file') # custom header
27
42
  end
28
43
 
29
44
  get '/sendfile' do
30
- send_file(__FILE__) #will work as x_send_file in production
45
+ send_file(__FILE__) # will work as x_send_file in production (see configure block)
31
46
  end
47
+
48
+ *Note* that if your application subclasses `Sinatra::Base` (modular app),
49
+ you have to register the extension in your subclass:
50
+
51
+ helpers Sinatra::Xsendfile
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'rake/testtask'
3
- require 'rake/gempackagetask'
4
3
 
5
4
  task :default => :test
6
5
 
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module Xsendfile
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -13,7 +13,15 @@ module Sinatra
13
13
 
14
14
  header_key = opts[:header] || (settings.respond_to?(:xsf_header) && settings.xsf_header) ||
15
15
  'X-SendFile'
16
- path = File.expand_path(path).gsub(settings.public, '') if header_key == 'X-Accel-Redirect'
16
+
17
+ if header_key == 'X-Accel-Redirect'
18
+ public_folder = if settings.respond_to?(:public_folder)
19
+ settings.public_folder
20
+ else
21
+ settings.public
22
+ end
23
+ path = File.expand_path(path).gsub(public_folder, '')
24
+ end
17
25
 
18
26
  response[header_key] = path
19
27
 
@@ -29,4 +37,4 @@ module Sinatra
29
37
  end
30
38
 
31
39
  helpers Xsendfile
32
- end
40
+ end
data/test/sinatra_app.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'sinatra'
3
- require 'lib/sinatra-xsendfile'
3
+ require 'lib/sinatra/xsendfile'
4
4
 
5
5
 
6
6
  set :xsf_header, 'x-test-send-file'
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-xsendfile
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 3
7
+ - 4
9
8
  - 0
10
- version: 0.3.0
9
+ version: 0.4.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Vasily Polovnyov
@@ -22,11 +21,9 @@ dependencies:
22
21
  name: sinatra
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 57
30
27
  segments:
31
28
  - 0
32
29
  - 9
@@ -38,11 +35,9 @@ dependencies:
38
35
  name: rack-test
39
36
  prerelease: false
40
37
  requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
39
  - - ">="
44
40
  - !ruby/object:Gem::Version
45
- hash: 19
46
41
  segments:
47
42
  - 0
48
43
  - 3
@@ -63,8 +58,8 @@ files:
63
58
  - LICENSE
64
59
  - README.md
65
60
  - Rakefile
66
- - lib/sinatra-xsendfile/version.rb
67
- - lib/sinatra-xsendfile.rb
61
+ - lib/sinatra/xsendfile/version.rb
62
+ - lib/sinatra/xsendfile.rb
68
63
  - test/sinatra_app.rb
69
64
  - test/sinatra_xsendfile_test.rb
70
65
  has_rdoc: true
@@ -77,27 +72,23 @@ rdoc_options: []
77
72
  require_paths:
78
73
  - lib
79
74
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
75
  requirements:
82
76
  - - ">="
83
77
  - !ruby/object:Gem::Version
84
- hash: 3
85
78
  segments:
86
79
  - 0
87
80
  version: "0"
88
81
  required_rubygems_version: !ruby/object:Gem::Requirement
89
- none: false
90
82
  requirements:
91
83
  - - ">="
92
84
  - !ruby/object:Gem::Version
93
- hash: 3
94
85
  segments:
95
86
  - 0
96
87
  version: "0"
97
88
  requirements: []
98
89
 
99
90
  rubyforge_project:
100
- rubygems_version: 1.3.7
91
+ rubygems_version: 1.3.6
101
92
  signing_key:
102
93
  specification_version: 3
103
94
  summary: X-SendFile helper for Sinatra