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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d128b6c5360b9eed68445296dea58ebc5fb57a75
4
- data.tar.gz: 5dda0b3d9e750714f44ffb31888b9ef133fbf6a9
3
+ metadata.gz: 20c9ef01a7d011ecf3133f5067ed69b3b1ead35c
4
+ data.tar.gz: c5e253d1e115f2df07f337f74030e1ee000fb3a8
5
5
  SHA512:
6
- metadata.gz: e531dec674c04e74b2f3f46c8e0f417b913f8c51402a8b82bdbfb3f2f5ace3b650e7c7343122aaf4805d54be67b464788ad2c2a8600c951ec87b16173cdf5293
7
- data.tar.gz: d07d1fc5ae750f0b4c77f6933f582eb097b9f0c20225feffef47dcc13cecd49b4edced8192a3fb332cc25263f48353db2a9eed6782e61a1eb16597b7f24162e7
6
+ metadata.gz: da2892de30ce25639623a0472687d1bdb63e9722fcf88fe82212b83167b58434dff2ba5244daac9a000183c8be82a6cfe053581dfc4a0d272138debea96f5a2c
7
+ data.tar.gz: 9c161190a8a78b96e78f0084c33eccaa619a54c79e7371320bbeb2562a43f2e1ce664ca8c375adb170e3e838d3c868e6bb527101f26af527a308693dedc9f5fe
data/.gems CHANGED
@@ -1,3 +1,4 @@
1
1
  cuba -v 3.1.1
2
2
  cutest -v 1.2.1
3
3
  rack-test -v 0.6.2
4
+ hobbit -v 0.6.0
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
- The next example uses [Cuba][cuba]:
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 **attachments**, it's recommended to use the HTML5 [download][download] attribute.
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
@@ -1,3 +1,5 @@
1
+ require "rack/file"
2
+
1
3
  module SendFile
2
4
  def send_file(path)
3
5
  file = Rack::File.new(nil)
@@ -0,0 +1,4 @@
1
+ .PHONY: test
2
+
3
+ test:
4
+ cutest test/*.rb
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "send_file"
3
- s.version = "1.0.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
@@ -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.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-09 00:00:00.000000000 Z
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