rack_guarantee_trailing_new_line 0.1.0
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.
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rack'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Rack
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              class GuaranteeTrailingNewLine
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                attr_reader :app
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize(app)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  @app = app
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                def call(env)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  dup._call(env)
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def _call(env)
         
     | 
| 
      
 18 
     | 
    
         
            +
                  status, header, body = @app.call(env)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  Rack::Response.new(body, status, header).tap do |r|
         
     | 
| 
      
 20 
     | 
    
         
            +
                    r.headers['Content-Length'] = (r.headers.fetch('Content-Length', 0).to_i + 1).to_s
         
     | 
| 
      
 21 
     | 
    
         
            +
                    r.body.push "\n"
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end.finish
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rack/test'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'minitest/autorun'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rack_guarantee_trailing_new_line'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class MiniTest::Unit::TestCase
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              include Rack::Test::Methods
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              def app
         
     | 
| 
      
 10 
     | 
    
         
            +
                Rack::Builder.app do
         
     | 
| 
      
 11 
     | 
    
         
            +
                  use Rack::GuaranteeTrailingNewLine
         
     | 
| 
      
 12 
     | 
    
         
            +
                  run lambda { |env| [200, {'Content-Type' => 'text/plain', 'Content-Length' => '2'}, 'OK'] }
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 17 
     | 
    
         
            +
                get "/"
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def test_the_newline_is_added
         
     | 
| 
      
 21 
     | 
    
         
            +
                assert_equal "OK\n", last_response.body
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              def test_the_content_length_header_is_modified
         
     | 
| 
      
 25 
     | 
    
         
            +
                assert_equal "3", last_response.headers.fetch("Content-Length")
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: rack_guarantee_trailing_new_line
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Lee Hambley
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-09-20 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: minitest
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 30 
     | 
    
         
            +
            description: Adds a trailing new line to all Rack responses
         
     | 
| 
      
 31 
     | 
    
         
            +
            email: lee.hambley@gmail.com
         
     | 
| 
      
 32 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 33 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 34 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 35 
     | 
    
         
            +
            files:
         
     | 
| 
      
 36 
     | 
    
         
            +
            - rack_guarantee_trailing_new_line.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - test_rack_guarantee_trailing_new_line.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            homepage: 
         
     | 
| 
      
 39 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 40 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 41 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 42 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 43 
     | 
    
         
            +
            - .
         
     | 
| 
      
 44 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 45 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 46 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 47 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 48 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 49 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 50 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 52 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 53 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 54 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 55 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 56 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 57 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 58 
     | 
    
         
            +
            rubygems_version: 1.8.23
         
     | 
| 
      
 59 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 60 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 61 
     | 
    
         
            +
            summary: Trailing new lines, yes please.
         
     | 
| 
      
 62 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 63 
     | 
    
         
            +
            - test_rack_guarantee_trailing_new_line.rb
         
     | 
| 
      
 64 
     | 
    
         
            +
            has_rdoc: 
         
     |