runit-man 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/runit-man/app.rb CHANGED
@@ -14,6 +14,37 @@ if RUBY_VERSION >= '1.9'
14
14
  Encoding.default_internal = "utf-8"
15
15
  end
16
16
 
17
+ if Sinatra::VERSION < '1.3.0' && Rack.release >= '1.3'
18
+ # Monkey patch old Sinatra to use Rack::File to serve files.
19
+ $stdout.puts 'Use custom Rack::File send_file'
20
+ $stdout.flush
21
+
22
+ Sinatra::Helpers.class_eval do
23
+ # Got from Sinatra 1.3.0 sources
24
+ def send_file(path, opts={})
25
+ if opts[:type] or not response['Content-Type']
26
+ content_type opts[:type] || File.extname(path), :default => 'application/octet-stream'
27
+ end
28
+
29
+ if opts[:disposition] == 'attachment' || opts[:filename]
30
+ attachment opts[:filename] || path
31
+ elsif opts[:disposition] == 'inline'
32
+ response['Content-Disposition'] = 'inline'
33
+ end
34
+
35
+ last_modified opts[:last_modified] if opts[:last_modified]
36
+
37
+ file = Rack::File.new nil
38
+ file.path = path
39
+ result = file.serving env
40
+ result[1].each { |k,v| headers[k] ||= v }
41
+ halt result[0], result[2]
42
+ rescue Errno::ENOENT
43
+ not_found
44
+ end
45
+ end
46
+ end
47
+
17
48
  class RunitMan < Sinatra::Base
18
49
  VERSION = RunitManVersion::VERSION
19
50
  MIN_TAIL = 100
@@ -1,3 +1,9 @@
1
+ # try to use sendfile when available
2
+ begin
3
+ require 'sendfile'
4
+ rescue LoadError
5
+ end
6
+
1
7
  Rainbows! do
2
8
  use :ThreadSpawn
3
9
  end
@@ -1,4 +1,4 @@
1
1
  module RunitManVersion
2
- VERSION = '2.3.3'.freeze
2
+ VERSION = '2.3.4'.freeze
3
3
  end
4
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runit-man
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 3
10
- version: 2.3.3
9
+ - 4
10
+ version: 2.3.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akzhan Abdulin