sinatra-xsendfile 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,10 +11,10 @@
11
11
  ##Example
12
12
  require 'rubygems'
13
13
  require 'sinatra'
14
- require 'sinatra/x_send_file'
14
+ require 'sinatra-xsendfile'
15
15
 
16
16
  configure :production do
17
- Sinatra::XSendFile.replace_send_file! #replaces sinatra's send_file with x_send_file
17
+ Sinatra::Xsendfile.replace_send_file! #replaces sinatra's send_file with x_send_file
18
18
  set :xsf_header, 'X-Accel-Redirect' #setting default(X-SendFile) header (nginx)
19
19
  end
20
20
 
data/Rakefile CHANGED
@@ -4,28 +4,6 @@ require 'rake/gempackagetask'
4
4
 
5
5
  task :default => :test
6
6
 
7
- begin
8
- require 'jeweler'
9
- Jeweler::Tasks.new do |gemspec|
10
- gemspec.name = "sinatra-xsendfile"
11
- gemspec.version = "0.2.2"
12
- gemspec.summary = gemspec.description = "X-SendFile helpers for Sinatra"
13
- gemspec.email = "vasily@polovnyov.ru"
14
- gemspec.homepage = "http://github.com/vast/sinatra-xsendfile"
15
- gemspec.authors = ["Vasily Polovnyov"]
16
-
17
- gemspec.add_dependency 'sinatra', '>=0.9.1'
18
-
19
- gemspec.add_development_dependency 'rack-test', '>=0.3.0'
20
-
21
- gemspec.test_files = Dir.glob('test/*')
22
- gemspec.files = ["LICENSE", "README.md", "Rakefile"] + Dir.glob('lib/**/*') + gemspec.test_files
23
-
24
- end
25
- rescue LoadError
26
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
27
- end
28
-
29
7
  Rake::TestTask.new do |t|
30
8
  t.libs << "test"
31
9
  t.test_files = FileList['test/*_test.rb']
@@ -0,0 +1,5 @@
1
+ module Sinatra
2
+ module Xsendfile
3
+ VERSION = "0.3.0"
4
+ end
5
+ end
@@ -1,11 +1,9 @@
1
- require 'sinatra/base'
2
1
  module Sinatra
3
- module XSendFile
2
+ module Xsendfile
4
3
  def x_send_file(path, opts = {})
5
- content_type _mime_type(opts[:type]) ||
6
- _mime_type(File.extname(path)) ||
7
- response['Content-Type'] ||
8
- 'application/octet-stream'
4
+ if opts[:type] or not response['Content-Type']
5
+ content_type(opts[:type] || File.extname(path) || 'application/octet-stream')
6
+ end
9
7
 
10
8
  if opts[:disposition] == 'attachment' || opts[:filename]
11
9
  attachment opts[:filename] || path
@@ -24,19 +22,11 @@ module Sinatra
24
22
  not_found
25
23
  end
26
24
 
27
- def _mime_type(type)
28
- if respond_to?(:mime_type)
29
- mime_type(type)
30
- else
31
- media_type(type)
32
- end
33
- end
34
-
35
25
  def self.replace_send_file!
36
26
  Sinatra::Helpers.send(:alias_method, :old_send_file, :send_file)
37
27
  Sinatra::Helpers.module_eval("def send_file(path, opts={}); x_send_file(path, opts); end;")
38
28
  end
39
29
  end
40
30
 
41
- helpers XSendFile
42
- end
31
+ helpers Xsendfile
32
+ end
data/test/sinatra_app.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require 'rubygems'
2
2
  require 'sinatra'
3
- require 'lib/sinatra/x_send_file'
3
+ require 'lib/sinatra-xsendfile'
4
4
 
5
5
 
6
6
  set :xsf_header, 'x-test-send-file'
7
7
 
8
- Sinatra::XSendFile.replace_send_file!
8
+ Sinatra::Xsendfile.replace_send_file!
9
9
 
10
10
  get '/' do
11
11
  x_send_file(__FILE__)
@@ -4,7 +4,7 @@ require 'rack/test'
4
4
 
5
5
  set :environment, :test
6
6
 
7
- class SinatraXSendFileTest < Test::Unit::TestCase
7
+ class SinatraXsendfileTest < Test::Unit::TestCase
8
8
  include Rack::Test::Methods
9
9
 
10
10
  def app
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-xsendfile
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Vasily Polovnyov
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-19 00:00:00 +04:00
18
+ date: 2010-12-18 00:00:00 +03:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: sinatra
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 57
27
30
  segments:
28
31
  - 0
29
32
  - 9
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: rack-test
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 19
41
46
  segments:
42
47
  - 0
43
48
  - 3
@@ -45,7 +50,7 @@ dependencies:
45
50
  version: 0.3.0
46
51
  type: :development
47
52
  version_requirements: *id002
48
- description: X-SendFile helpers for Sinatra
53
+ description: X-SendFile helper for Sinatra
49
54
  email: vasily@polovnyov.ru
50
55
  executables: []
51
56
 
@@ -58,39 +63,44 @@ files:
58
63
  - LICENSE
59
64
  - README.md
60
65
  - Rakefile
61
- - lib/sinatra/x_send_file.rb
66
+ - lib/sinatra-xsendfile/version.rb
67
+ - lib/sinatra-xsendfile.rb
62
68
  - test/sinatra_app.rb
63
- - test/sinatra_x_send_file_test.rb
69
+ - test/sinatra_xsendfile_test.rb
64
70
  has_rdoc: true
65
71
  homepage: http://github.com/vast/sinatra-xsendfile
66
72
  licenses: []
67
73
 
68
74
  post_install_message:
69
- rdoc_options:
70
- - --charset=UTF-8
75
+ rdoc_options: []
76
+
71
77
  require_paths:
72
78
  - lib
73
79
  required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
74
81
  requirements:
75
82
  - - ">="
76
83
  - !ruby/object:Gem::Version
84
+ hash: 3
77
85
  segments:
78
86
  - 0
79
87
  version: "0"
80
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
81
90
  requirements:
82
91
  - - ">="
83
92
  - !ruby/object:Gem::Version
93
+ hash: 3
84
94
  segments:
85
95
  - 0
86
96
  version: "0"
87
97
  requirements: []
88
98
 
89
99
  rubyforge_project:
90
- rubygems_version: 1.3.6
100
+ rubygems_version: 1.3.7
91
101
  signing_key:
92
102
  specification_version: 3
93
- summary: X-SendFile helpers for Sinatra
103
+ summary: X-SendFile helper for Sinatra
94
104
  test_files:
95
- - test/sinatra_x_send_file_test.rb
105
+ - test/sinatra_xsendfile_test.rb
96
106
  - test/sinatra_app.rb