send_file 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/.gems +1 -0
- data/README.md +20 -4
- data/lib/send_file.rb +2 -0
- data/makefile +4 -0
- data/send_file.gemspec +2 -1
- data/test/hobbit.rb +38 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c9ef01a7d011ecf3133f5067ed69b3b1ead35c
|
4
|
+
data.tar.gz: c5e253d1e115f2df07f337f74030e1ee000fb3a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da2892de30ce25639623a0472687d1bdb63e9722fcf88fe82212b83167b58434dff2ba5244daac9a000183c8be82a6cfe053581dfc4a0d272138debea96f5a2c
|
7
|
+
data.tar.gz: 9c161190a8a78b96e78f0084c33eccaa619a54c79e7371320bbeb2562a43f2e1ce664ca8c375adb170e3e838d3c868e6bb527101f26af527a308693dedc9f5fe
|
data/.gems
CHANGED
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Make sure your application implements two methods: `env` and `halt`,
|
|
10
10
|
where `env` returns a hash with the Rack environment and `halt` returns
|
11
11
|
an array response like `[status, headers, [body]]`.
|
12
12
|
|
13
|
-
|
13
|
+
### Using [Cuba][cuba]
|
14
14
|
|
15
15
|
```ruby
|
16
16
|
require "cuba"
|
@@ -25,19 +25,34 @@ Cuba.define do
|
|
25
25
|
end
|
26
26
|
```
|
27
27
|
|
28
|
+
### Using [Hobbit][hobbit]
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require "hobbit"
|
32
|
+
require "send_file"
|
33
|
+
|
34
|
+
class App < Hobbit::Base
|
35
|
+
include Sendfile
|
36
|
+
|
37
|
+
get "/foo" do
|
38
|
+
send_file("foo.pdf")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
28
43
|
Attachments
|
29
44
|
-----------
|
30
45
|
|
31
|
-
For
|
46
|
+
For attachments, it's recommended to use the HTML5 [download][download] attribute.
|
32
47
|
|
33
48
|
```html
|
34
|
-
<a href="/foo" download>Download foo</a>
|
49
|
+
<a href="/foo" download>Download foo.pdf</a>
|
35
50
|
```
|
36
51
|
|
37
52
|
You can specify a filename too:
|
38
53
|
|
39
54
|
```html
|
40
|
-
<a href="/foo" download="bar.pdf">Download bar</a>
|
55
|
+
<a href="/foo" download="bar.pdf">Download bar.pdf</a>
|
41
56
|
```
|
42
57
|
|
43
58
|
Installation
|
@@ -48,4 +63,5 @@ $ gem install send_file
|
|
48
63
|
```
|
49
64
|
|
50
65
|
[cuba]: https://github.com/soveran/cuba
|
66
|
+
[hobbit]: https://github.com/patriciomacadden/hobbit
|
51
67
|
[download]: http://davidwalsh.name/download-attribute
|
data/lib/send_file.rb
CHANGED
data/makefile
ADDED
data/send_file.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "send_file"
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.1"
|
4
4
|
s.summary = "File sending for Rack applications."
|
5
5
|
s.description = s.summary
|
6
6
|
s.authors = ["Francesco Rodríguez"]
|
@@ -12,5 +12,6 @@ Gem::Specification.new do |s|
|
|
12
12
|
|
13
13
|
s.add_development_dependency "cuba"
|
14
14
|
s.add_development_dependency "cutest"
|
15
|
+
s.add_development_dependency "hobbit"
|
15
16
|
s.add_development_dependency "rack-test"
|
16
17
|
end
|
data/test/hobbit.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "hobbit"
|
2
|
+
require "rack/test"
|
3
|
+
require_relative "../lib/send_file"
|
4
|
+
|
5
|
+
FILE = File.join(__dir__, "foo.txt")
|
6
|
+
|
7
|
+
class App < Hobbit::Base
|
8
|
+
include SendFile
|
9
|
+
|
10
|
+
get "/" do
|
11
|
+
send_file(FILE)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Cutest::Scope
|
16
|
+
include Rack::Test::Methods
|
17
|
+
|
18
|
+
def app
|
19
|
+
App
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
scope do
|
24
|
+
test "sends the contents of the file" do
|
25
|
+
get "/"
|
26
|
+
|
27
|
+
assert_equal 200, last_response.status
|
28
|
+
assert_equal "Hello World\n", last_response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
test "sets response headers" do
|
32
|
+
get "/"
|
33
|
+
|
34
|
+
assert_equal "text/plain", last_response["Content-Type"]
|
35
|
+
assert_equal "Hello World\n".length.to_s, last_response["Content-Length"]
|
36
|
+
assert_equal File.mtime(FILE).httpdate, last_response["Last-Modified"]
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: send_file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodríguez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuba
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hobbit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rack-test
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -63,9 +77,11 @@ files:
|
|
63
77
|
- LICENSE
|
64
78
|
- README.md
|
65
79
|
- lib/send_file.rb
|
80
|
+
- makefile
|
66
81
|
- send_file.gemspec
|
67
82
|
- test/cuba.rb
|
68
83
|
- test/foo.txt
|
84
|
+
- test/hobbit.rb
|
69
85
|
homepage: https://github.com/frodsan/send_file
|
70
86
|
licenses:
|
71
87
|
- MIT
|