haml_interceptor 0.4.0 → 0.4.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.
- data/TODO.md +0 -1
- data/VERSION +1 -1
- data/haml_interceptor.gemspec +1 -1
- data/lib/haml_interceptor.rb +5 -1
- data/test/sample_app.rb +3 -0
- data/test/test_haml_interceptor.rb +6 -0
- metadata +2 -2
    
        data/TODO.md
    CHANGED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            * Recursively parse JSON bodies for HTML to Hamlize
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.4. | 
| 1 | 
            +
            0.4.1
         | 
    
        data/haml_interceptor.gemspec
    CHANGED
    
    
    
        data/lib/haml_interceptor.rb
    CHANGED
    
    | @@ -7,7 +7,11 @@ class HamlInterceptor | |
| 7 7 |  | 
| 8 8 | 
             
              def call(env)
         | 
| 9 9 | 
             
                status, headers, resp = @app.call(env)
         | 
| 10 | 
            -
                body = resp. | 
| 10 | 
            +
                body = if resp.respond_to?(:body)
         | 
| 11 | 
            +
                  resp.body.respond_to?(:join) ? resp.body.join : resp.body
         | 
| 12 | 
            +
                else
         | 
| 13 | 
            +
                  resp
         | 
| 14 | 
            +
                end
         | 
| 11 15 |  | 
| 12 16 | 
             
                if js_response?(env, headers)
         | 
| 13 17 | 
             
                  body = parse(body)
         | 
    
        data/test/sample_app.rb
    CHANGED
    
    | @@ -12,6 +12,9 @@ class SampleApp | |
| 12 12 | 
             
                elsif request.path == '/json'
         | 
| 13 13 | 
             
                  content_type = 'application/javascript'
         | 
| 14 14 | 
             
                  body = JSON.generate({:name => 'Boneshaker', :markup => '<h1>Boneshaker</h1><div id="author"><p>by Cherie Priest</p></div>'})
         | 
| 15 | 
            +
                elsif request.path == '/empty'
         | 
| 16 | 
            +
                  content_type = 'text/html'
         | 
| 17 | 
            +
                  body = []
         | 
| 15 18 | 
             
                end
         | 
| 16 19 |  | 
| 17 20 | 
             
                return Rack::Response.new(body, 200, {'Content-Type' => content_type}).finish
         | 
| @@ -38,4 +38,10 @@ HAML | |
| 38 38 | 
             
                assert_equal JSON.parse('{"name":"Boneshaker\n", "markup":"%h1 Boneshaker\n#author\n  %p by Cherie Priest\n"}'),
         | 
| 39 39 | 
             
                  JSON.parse(last_response.body)
         | 
| 40 40 | 
             
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              def test_it_should_handle_empty_bodies
         | 
| 43 | 
            +
                assert_nothing_raised do
         | 
| 44 | 
            +
                  get '/empty'
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 41 47 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 | 
             
            name: haml_interceptor
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 4 | 
             
              prerelease: 
         | 
| 5 | 
            -
              version: 0.4. | 
| 5 | 
            +
              version: 0.4.1
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors: 
         | 
| 8 8 | 
             
            - Ben Scofield
         | 
| @@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 149 149 | 
             
              requirements: 
         | 
| 150 150 | 
             
              - - ">="
         | 
| 151 151 | 
             
                - !ruby/object:Gem::Version 
         | 
| 152 | 
            -
                  hash:  | 
| 152 | 
            +
                  hash: 3461632714940041838
         | 
| 153 153 | 
             
                  segments: 
         | 
| 154 154 | 
             
                  - 0
         | 
| 155 155 | 
             
                  version: "0"
         |