rack-robotz 0.0.3 → 0.0.4
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/README.md +0 -1
- data/lib/rack/robotz/middleware.rb +2 -3
- data/test/unit/defaults_test.rb +0 -5
- data/test/unit/middleware_test.rb +3 -3
- metadata +4 -4
    
        data/README.md
    CHANGED
    
    
| @@ -2,12 +2,11 @@ module Rack | |
| 2 2 |  | 
| 3 3 | 
             
              class Robotz
         | 
| 4 4 |  | 
| 5 | 
            -
                VERSION = '0.0. | 
| 5 | 
            +
                VERSION = '0.0.4'
         | 
| 6 6 |  | 
| 7 7 | 
             
                def initialize(app, items = {"User-Agent" => "*", "Disallow" => "/"})
         | 
| 8 8 | 
             
                  @app = app
         | 
| 9 9 | 
             
                  @items = items
         | 
| 10 | 
            -
                  @is_enabled = %w{1 true yes}.include?(ENV["DISABLE_ROBOTS"])
         | 
| 11 10 | 
             
                end
         | 
| 12 11 |  | 
| 13 12 | 
             
                def to_s
         | 
| @@ -15,7 +14,7 @@ module Rack | |
| 15 14 | 
             
                end
         | 
| 16 15 |  | 
| 17 16 | 
             
                def call(env)
         | 
| 18 | 
            -
                  if  | 
| 17 | 
            +
                  if env['PATH_INFO'] == '/robots.txt'
         | 
| 19 18 | 
             
                    [200, { 'Content-Type' => 'text/plain' }, [to_s]]
         | 
| 20 19 | 
             
                  else
         | 
| 21 20 | 
             
                    @app.call(env)
         | 
    
        data/test/unit/defaults_test.rb
    CHANGED
    
    | @@ -3,16 +3,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper')) | |
| 3 3 | 
             
            class DefaultsTest < MiniTest::Unit::TestCase
         | 
| 4 4 | 
             
              include Rack::Test::Methods
         | 
| 5 5 |  | 
| 6 | 
            -
              def setup
         | 
| 7 | 
            -
                ENV.delete 'DISABLE_ROBOTS'
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 6 | 
             
              def app
         | 
| 11 7 | 
             
                Rack::Robotz.new TestApp
         | 
| 12 8 | 
             
              end
         | 
| 13 9 |  | 
| 14 10 | 
             
              def test_it_should_use_default_content
         | 
| 15 | 
            -
                ENV['DISABLE_ROBOTS'] = 'true'
         | 
| 16 11 | 
             
                get "/robots.txt"
         | 
| 17 12 | 
             
                assert_equal last_response.status, 200
         | 
| 18 13 | 
             
                assert_equal last_response.body, "User-Agent: *\nDisallow: /"
         | 
| @@ -12,20 +12,20 @@ class MiddlewareTest < MiniTest::Unit::TestCase | |
| 12 12 | 
             
              end
         | 
| 13 13 |  | 
| 14 14 | 
             
              def test_should_generate_robots_txt_when_env_variable_set
         | 
| 15 | 
            +
                # we used to take that ENV variable into account
         | 
| 15 16 | 
             
                ENV['DISABLE_ROBOTS'] = 'true'
         | 
| 16 17 | 
             
                get "/robots.txt"
         | 
| 17 18 | 
             
                assert_equal last_response.status, 200
         | 
| 18 19 | 
             
                assert_equal last_response.body, "User-Agent: *\nDisallow: /"
         | 
| 19 20 | 
             
              end
         | 
| 20 21 |  | 
| 21 | 
            -
              def  | 
| 22 | 
            +
              def test_should_generate_robots_txt_when_env_variable_not_set
         | 
| 22 23 | 
             
                get "/robots.txt"
         | 
| 23 24 | 
             
                assert_equal last_response.status, 200
         | 
| 24 | 
            -
                assert_equal last_response.body,  | 
| 25 | 
            +
                assert_equal last_response.body, "User-Agent: *\nDisallow: /"
         | 
| 25 26 | 
             
              end
         | 
| 26 27 |  | 
| 27 28 | 
             
              def test_should_not_affect_other_urls
         | 
| 28 | 
            -
                ENV['DISABLE_ROBOTS'] = 'true'
         | 
| 29 29 | 
             
                get "/"
         | 
| 30 30 | 
             
                assert_equal last_response.status, 200
         | 
| 31 31 | 
             
                assert_equal last_response.body, 'meow!'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rack-robotz
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.4
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2013- | 
| 13 | 
            +
            date: 2013-07-30 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: rack
         | 
| @@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 106 106 | 
             
                  version: '0'
         | 
| 107 107 | 
             
                  segments:
         | 
| 108 108 | 
             
                  - 0
         | 
| 109 | 
            -
                  hash:  | 
| 109 | 
            +
                  hash: 2201003892328491813
         | 
| 110 110 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 111 111 | 
             
              none: false
         | 
| 112 112 | 
             
              requirements:
         | 
| @@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 115 115 | 
             
                  version: '0'
         | 
| 116 116 | 
             
                  segments:
         | 
| 117 117 | 
             
                  - 0
         | 
| 118 | 
            -
                  hash:  | 
| 118 | 
            +
                  hash: 2201003892328491813
         | 
| 119 119 | 
             
            requirements: []
         | 
| 120 120 | 
             
            rubyforge_project: 
         | 
| 121 121 | 
             
            rubygems_version: 1.8.23
         |