machined 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,11 +8,11 @@ module Machined
8
8
  # middleware or application. It's basically
9
9
  # a simplified version of ActionDispatch::Static.
10
10
  class Static
11
- def initialize(app, root = '.', cache_control = nil)
11
+ def initialize(app, root = '.', headers = {})
12
12
  @app = app
13
13
  @root = File.expand_path(root)
14
14
  @compiled_root = /^#{Regexp.escape(@root)}/
15
- @file_server = ::Rack::File.new(@root, 'Cache-Control' => cache_control)
15
+ @file_server = ::Rack::File.new(@root, headers)
16
16
  end
17
17
 
18
18
  def call(env)
@@ -1,3 +1,3 @@
1
1
  module Machined
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
@@ -2,36 +2,36 @@ require 'spec_helper'
2
2
 
3
3
  describe Machined::Middleware::Static do
4
4
  include Rack::Test::Methods
5
-
5
+
6
6
  let(:root) { create_construct }
7
7
  after(:each) { root.destroy! }
8
-
8
+
9
9
  let(:app) do
10
10
  Rack::Builder.new.tap do |app|
11
- app.use Machined::Middleware::Static, root, 'public, max-age=60'
11
+ app.use Machined::Middleware::Static, root, 'Cache-control' => 'public, max-age=60'
12
12
  app.run Proc.new { |env| [200, {'Content-Type' => 'text/plain'}, ['Hello, World!']] }
13
13
  end.to_app
14
14
  end
15
-
15
+
16
16
  it 'serves dynamic content' do
17
17
  get('/nofile').body.should == 'Hello, World!'
18
18
  end
19
-
19
+
20
20
  it 'sets cache control headers' do
21
21
  root.file 'file.txt', 'File Content'
22
22
  get('/file.txt').headers['Cache-Control'].should == 'public, max-age=60'
23
23
  end
24
-
24
+
25
25
  it 'serves static files in the root directory' do
26
26
  root.file 'file.txt', 'File Content'
27
27
  get('/file.txt').body.should == 'File Content'
28
28
  end
29
-
29
+
30
30
  it 'serves static files in a subdirectory' do
31
31
  root.file 'sub/directory/file.txt', 'Subdirectory File Content'
32
32
  get('/sub/directory/file.txt').body.should == 'Subdirectory File Content'
33
33
  end
34
-
34
+
35
35
  it 'serves static index file in the root directory' do
36
36
  root.file 'index.html', 'Static Index Content'
37
37
  get('/index.html').body.should == 'Static Index Content'
@@ -39,14 +39,14 @@ describe Machined::Middleware::Static do
39
39
  get('/').body.should == 'Static Index Content'
40
40
  get('').body.should == 'Static Index Content'
41
41
  end
42
-
42
+
43
43
  it 'serves static index file in directory' do
44
44
  root.file 'foo/index.html', 'Static Index Content in Directory'
45
45
  get('/foo/index.html').body.should == 'Static Index Content in Directory'
46
46
  get('/foo/').body.should == 'Static Index Content in Directory'
47
47
  get('/foo').body.should == 'Static Index Content in Directory'
48
48
  end
49
-
49
+
50
50
  it 'serves static html file in directory' do
51
51
  root.file 'foo/bar.html', 'HTML Content in Directory'
52
52
  get('/foo/bar.html').body.should == 'HTML Content in Directory'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: machined
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -428,7 +428,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
428
428
  version: '0'
429
429
  segments:
430
430
  - 0
431
- hash: -1758282341700844957
431
+ hash: 3230074138858488384
432
432
  required_rubygems_version: !ruby/object:Gem::Requirement
433
433
  none: false
434
434
  requirements:
@@ -437,7 +437,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
437
437
  version: '0'
438
438
  segments:
439
439
  - 0
440
- hash: -1758282341700844957
440
+ hash: 3230074138858488384
441
441
  requirements: []
442
442
  rubyforge_project: machined
443
443
  rubygems_version: 1.8.23