rack-static-if-present 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f08d4963c1ca67529b9fd48f5d10f0a11993229c
4
+ data.tar.gz: a2fec8713c2bad8010da0dc93cef5d13146b465d
5
+ SHA512:
6
+ metadata.gz: 2f8ff2f1ef2020a6662ab68514f07b40a8b8eadbe8e5872e9f95f479d69f40d645c883a5704a346a924960fb99bbdfe79659de259d005a0f1885c0d1910743c6
7
+ data.tar.gz: e1ccdfaad44a24f44fe38b82b211ad7b644b9a966484e4ddf0e0e64406e265852867df53de98827019446601ea82566cef1440204fd10e64e5beab16a115c77e
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ rack-static-if-present
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in rack-static-if-present.gemspec
4
- gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-static-if-present (0.2.0)
5
- rack (~> 1)
4
+ rack-static-if-present (0.2.1)
5
+ rack (> 1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- rack (1.3.0)
10
+ rack (1.5.2)
11
11
 
12
12
  PLATFORMS
13
13
  ruby
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ desc "Run all the fast tests"
5
+ task :test do
6
+ opts = ENV['TEST'] || '-a'
7
+ specopts = ENV['TESTOPTS'] ||
8
+ "-q -t '^(?!Rack::Adapter|Rack::Session::Memcache|Rack::Server)'"
9
+
10
+ sh "bacon -I./lib:./test -w #{opts} #{specopts}"
11
+ end
data/config.ru CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rack'
3
- require 'lib/rack-static-if-present'
3
+ require './lib/rack-static-if-present'
4
4
 
5
5
  class HelloWorld
6
6
  def call(env)
@@ -2,7 +2,7 @@ module Rack
2
2
  module Static
3
3
  module If
4
4
  module Present
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
8
8
  end
@@ -19,5 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency 'rack', ['~> 1']
22
+ s.add_dependency 'rack', ['> 1']
23
23
  end
data/test/cgi/test ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- ruby -*-
3
+
4
+ $: << File.join(File.dirname(__FILE__), "..", "..", "lib")
5
+
6
+ require 'rack'
7
+ require '../testrequest'
8
+
9
+ Rack::Handler::CGI.run(Rack::Lint.new(TestRequest.new))
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__)) + '/../lib/rack-static-if-present'
2
+ require 'rack/mock'
3
+ require 'ruby-debug'
4
+ class DummyApp
5
+ def call(env)
6
+ [200, {}, ["Hello World"]]
7
+ end
8
+ end
9
+
10
+ describe Rack::StaticIfPresent do
11
+ root = File.expand_path(File.dirname(__FILE__))
12
+
13
+ OPTIONS = {:urls => ["/cgi"], :root => root}
14
+ HASH_OPTIONS = {:urls => {"/cgi/sekret" => 'cgi/test'}, :root => root}
15
+
16
+ @request = Rack::MockRequest.new(Rack::StaticIfPresent.new(DummyApp.new, OPTIONS))
17
+ @hash_request = Rack::MockRequest.new(Rack::StaticIfPresent.new(DummyApp.new, HASH_OPTIONS))
18
+
19
+ it "serves files" do
20
+ res = @request.get("/cgi/test")
21
+ res.should.be.ok
22
+ res.body.should =~ /ruby/
23
+ end
24
+
25
+ # This is the part that is different than Rack:Static
26
+ # Rack::Static's spec:
27
+ # it "404s if url root is known but it can't find the file" do
28
+ it "calls down the chain if url root is known but it can't find the file" do
29
+ res = @request.get("/cgi/foo")
30
+ # res.should.be.not_found
31
+ res.body.should == "Hello World"
32
+ end
33
+
34
+ it "calls down the chain if url root is not known" do
35
+ res = @request.get("/something/else")
36
+ res.should.be.ok
37
+ res.body.should == "Hello World"
38
+ end
39
+
40
+ it "serves hidden files" do
41
+ res = @hash_request.get("/cgi/sekret")
42
+ res.should.be.ok
43
+ res.body.should =~ /ruby/
44
+ end
45
+
46
+ it "calls down the chain if the URI is not specified" do
47
+ res = @hash_request.get("/something/else")
48
+ res.should.be.ok
49
+ res.body.should == "Hello World"
50
+ end
51
+
52
+ it "supports serving fixed cache-control" do
53
+ opts = OPTIONS.merge(:cache_control => 'public')
54
+ request = Rack::MockRequest.new(Rack::StaticIfPresent.new(DummyApp.new, opts))
55
+ res = request.get("/cgi/test")
56
+ res.should.be.ok
57
+ res.headers['Cache-Control'].should == 'public'
58
+ end
59
+
60
+ end
metadata CHANGED
@@ -1,49 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-static-if-present
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Sam Schenkman-Moore
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-05-24 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: rack
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 1
30
- segments:
31
- - 1
32
- version: "1"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>'
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
33
20
  type: :runtime
34
- version_requirements: *id001
35
- description: Not much to explain. Not a lot of code, but wanted it packaged up for easy use/deployment.
36
- email:
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>'
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ description: Not much to explain. Not a lot of code, but wanted it packaged up for
28
+ easy use/deployment.
29
+ email:
37
30
  - samsm@samsm.com
38
31
  executables: []
39
-
40
32
  extensions: []
41
-
42
33
  extra_rdoc_files: []
43
-
44
- files:
34
+ files:
45
35
  - .document
46
36
  - .gitignore
37
+ - .ruby-gemset
38
+ - .ruby-version
47
39
  - Gemfile
48
40
  - Gemfile.lock
49
41
  - LICENSE
@@ -53,42 +45,33 @@ files:
53
45
  - lib/rack-static-if-present.rb
54
46
  - lib/rack-static-if-present/version.rb
55
47
  - rack-static-if-present.gemspec
48
+ - test/cgi/test
56
49
  - test/helper.rb
57
- - test/test_rack-static-if-present.rb
58
- has_rdoc: true
50
+ - test/spec_rack-static-if-present.rb
59
51
  homepage: http://github.com/samsm/rack-static-if-present
60
52
  licenses: []
61
-
53
+ metadata: {}
62
54
  post_install_message:
63
55
  rdoc_options: []
64
-
65
- require_paths:
56
+ require_paths:
66
57
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- hash: 3
82
- segments:
83
- - 0
84
- version: "0"
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
85
68
  requirements: []
86
-
87
69
  rubyforge_project: rack-static-if-present
88
- rubygems_version: 1.3.7
70
+ rubygems_version: 2.0.6
89
71
  signing_key:
90
- specification_version: 3
72
+ specification_version: 4
91
73
  summary: Like Rack::Static. Except only if there is a static file to serve.
92
- test_files:
74
+ test_files:
75
+ - test/cgi/test
93
76
  - test/helper.rb
94
- - test/test_rack-static-if-present.rb
77
+ - test/spec_rack-static-if-present.rb
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestRackStaticIfPresent < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end