publicious 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,14 @@ if defined?(Rails)
3
3
  require 'publicious/mime_types'
4
4
  end
5
5
 
6
+ require 'logger'
7
+
6
8
  class Publicious
7
9
  FILE_METHODS = %w(GET HEAD).freeze
10
+
11
+ @@logger = Logger.new($stdout)
12
+ @@logger.level = Logger::DEBUG
13
+ cattr_accessor :logger
8
14
 
9
15
  def initialize(app)
10
16
  @app = app
@@ -16,7 +22,7 @@ class Publicious
16
22
  end
17
23
 
18
24
  def call(env)
19
- puts "we're in Publicious"
25
+
20
26
  request = Rack::Request.new(env)
21
27
  return @app.call(env) unless FILE_METHODS.include?(request.request_method)
22
28
 
@@ -34,7 +40,8 @@ class Publicious
34
40
 
35
41
  # Make sure pricks aren't ../../config/database.yml ing us
36
42
  respond_not_found! unless file_name.gsub(%r[^#{path}], "") == request.path_info
37
-
43
+
44
+ klass.logger.info "Publicious middleware served #{request.path_info} with #{file_name}"
38
45
  Rack::Response.new(
39
46
  File.open(file_name),
40
47
  200,'Content-Type' => content_type_for_file(file_name)
@@ -1,9 +1,6 @@
1
- #class PubliciousRailtie < Rails::Railtie
2
- # config.app.middelware.insert_before(Rack::Lock, Publicious)
3
- #end
4
-
5
1
  class MyRailtie < Rails::Railtie
6
- initializer "my_railtie.configure_rails_initialization" do |app|
2
+ initializer "publicious.configure_middleware" do |app|
7
3
  app.middleware.insert_before(Rack::Lock, Publicious)
4
+ Publicious.logger = Rails.logger
8
5
  end
9
6
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{publicious}
3
- s.version = "0.3.0"
3
+ s.version = "0.3.1"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Justin French", "Daniel Neighman"]
@@ -5,6 +5,8 @@ require "rails"
5
5
  require "action_controller"
6
6
  require "publicious"
7
7
 
8
+ Publicious.logger.level = Logger::ERROR # Silence INFO logs from the middleware during tests
9
+
8
10
  RAILS_ROOT = "/tmp"
9
11
 
10
12
  NOT_FOUND_APP = lambda{|e| Rack::Response.new("NOT FOUND", 404).finish}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Justin French
@@ -32,7 +32,6 @@ files:
32
32
  - lib/publicious/railtie.rb
33
33
  - lib/publicious.rb
34
34
  - MIT-LICENSE
35
- - publicious-0.3.0.gem
36
35
  - publicious.gemspec
37
36
  - Rakefile
38
37
  - README.textile