cuba-sendfile 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0084ae1453a3893ad7604b40124c24a73c248e15
4
- data.tar.gz: a021a95ccbbfaba97470fa001dc7f70838ed53a8
3
+ metadata.gz: 54b99567f95e4589cd7887ec97b1dd3720ea18cc
4
+ data.tar.gz: 24dea4bfd2c0cf32ff09a406c150490372e509ce
5
5
  SHA512:
6
- metadata.gz: a58f9109dc76cd561566282708b8866bb5ae47821a92a9ffe69d3ffef00e9104858cff3b4261292d373a96bf38bebd9e53173bf707bdf7c6602ccd9cc08547e4
7
- data.tar.gz: b8af6b451fde9b6567dbe3e0671f47b3695c1ed6102a3582ca1e18ef14be1e061d6f5f34362a5244529b1473c2be7fc8ebdc0134276025e769b16dd9a817cd5b
6
+ metadata.gz: 1cb2f5f844556602a43341d7c55985ca6041e4a13f67343ac6d6b071c020404fc592075ec12f9ccc4f6be7d98d8b627008d5d45bd2096abcd9ac5e08b98fe5e5
7
+ data.tar.gz: fe91e2e44c214c41a58bbb1da138bb252b55f4482ba950bb4dcf2edab1c39307268546f4de826b6b0ca4289d5a9bfc8fe1f0d69b30c698b02ca63d81f6aeca13
data/README.md CHANGED
@@ -10,23 +10,32 @@ Usage
10
10
  require "cuba"
11
11
  require "cuba/send_file"
12
12
 
13
- Cuba.plugin(Cuba::SendFile)
13
+ Cuba.plugin(SendFile)
14
14
 
15
15
  Cuba.define do
16
- on root do
17
- send_file("foo.png")
18
- end
19
-
20
- on "/download" do
21
- disposition = 'attachment; filename="foo.png"'
22
- send_file("foo.png", "Content-Disposition" => disposition)
16
+ on "foo" do
17
+ send_file("foo.pdf")
23
18
  end
24
19
  end
25
20
  ```
26
21
 
22
+ For **attachments**, it's recommended to use the HTML5 [download][download] attribute.
23
+
24
+ ```html
25
+ <a href="/foo" download>Download foo</a>
26
+ ```
27
+
28
+ You can specify a filename too:
29
+
30
+ ```html
31
+ <a href="/foo" download="bar.pdf">Download bar</a>
32
+ ```
33
+
27
34
  Installation
28
35
  ------------
29
36
 
30
37
  ```
31
38
  $ gem install cuba-sendfile
32
39
  ```
40
+
41
+ [download]: http://davidwalsh.name/download-attribute
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cuba-sendfile"
3
- s.version = "0.0.1"
4
- s.summary = "File sending for Cuba"
3
+ s.version = "0.0.2"
4
+ s.summary = "File sending for Cuba."
5
5
  s.description = s.summary
6
6
  s.authors = ["Francesco Rodríguez"]
7
7
  s.email = ["frodsan@me.com"]
@@ -1,12 +1,8 @@
1
- class Cuba
2
- module SendFile
3
- def send_file(path, headers = {})
4
- file = Rack::File.new(nil, headers)
5
- file.path = path
1
+ module SendFile
2
+ def send_file(path)
3
+ file = Rack::File.new(nil)
4
+ file.path = path
6
5
 
7
- result = file.serving(env)
8
-
9
- halt([result[0], result[1], file])
10
- end
6
+ halt(file.serving(env))
11
7
  end
12
8
  end
@@ -3,16 +3,12 @@ require_relative "../lib/cuba/send_file"
3
3
 
4
4
  FILE = __dir__ + "/foo.txt"
5
5
 
6
- Cuba.plugin(Cuba::SendFile)
6
+ Cuba.plugin(SendFile)
7
7
 
8
8
  Cuba.define do
9
9
  on root do
10
10
  send_file(FILE)
11
11
  end
12
-
13
- on "custom" do
14
- send_file(FILE, "Content-Disposition" => "disposition")
15
- end
16
12
  end
17
13
 
18
14
  scope do
@@ -30,10 +26,4 @@ scope do
30
26
  assert_equal "Hello World\n".length.to_s, last_response["Content-Length"]
31
27
  assert_equal File.mtime(FILE).httpdate, last_response["Last-Modified"]
32
28
  end
33
-
34
- test "sets custom header" do
35
- get "/custom"
36
-
37
- assert_equal "disposition", last_response["Content-Disposition"]
38
- end
39
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuba-sendfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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-02-05 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cuba
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: File sending for Cuba
55
+ description: File sending for Cuba.
56
56
  email:
57
57
  - frodsan@me.com
58
58
  executables: []
@@ -89,5 +89,5 @@ rubyforge_project:
89
89
  rubygems_version: 2.2.0
90
90
  signing_key:
91
91
  specification_version: 4
92
- summary: File sending for Cuba
92
+ summary: File sending for Cuba.
93
93
  test_files: []