sinatra-subdomain 0.1.1 → 0.4.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.
- checksums.yaml +7 -0
 - data/.github/FUNDING.yml +3 -0
 - data/.gitignore +3 -1
 - data/.rubocop.yml +23 -0
 - data/.travis.yml +19 -0
 - data/Gemfile +4 -1
 - data/README.md +124 -0
 - data/Rakefile +14 -10
 - data/gemfiles/sinatra_1_4.gemfile +4 -0
 - data/gemfiles/sinatra_2_0.gemfile +4 -0
 - data/gemfiles/sinatra_2_1.gemfile +4 -0
 - data/lib/sinatra/subdomain.rb +78 -10
 - data/lib/sinatra/subdomain/version.rb +5 -3
 - data/sinatra-subdomain.gemspec +14 -6
 - data/test/sinatra-subdomain/ip_address_test.rb +23 -0
 - data/test/sinatra-subdomain/multiple_subdomain_test.rb +8 -0
 - data/test/sinatra-subdomain/multiple_tlds_test.rb +8 -0
 - data/test/sinatra-subdomain/single_tld_test.rb +8 -0
 - data/test/sinatra-subdomain/subdomains_test.rb +44 -0
 - data/test/support/app.rb +35 -0
 - data/test/support/subdomain_tests.rb +71 -0
 - data/test/test_helper.rb +13 -34
 - metadata +121 -46
 - data/Gemfile.lock +0 -49
 - data/README.rdoc +0 -48
 - data/test/multiple_tlds_test.rb +0 -25
 - data/test/subdomain_test.rb +0 -25
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 2f8c53e74401f55a751115abc8e9100a54a5610e8ce6560e796885841e86b8e0
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a4c173180de33d07cd060c566c4d4cff7f83174b31e0e61f3b71386c5a12cab5
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 49bfccce1571b7ea19670bac0aee42959efc3ec6af384a47a949c19d46e2f08f2aaca3ae82dff3c0092d2af7a92d9e60577ce41d3b5311502da509ec8ed9d9ad
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a51325cf941367814569bdf4700f665b90ec54d42e521e49384763049a17db48026298ecaed11986355065f1db54fce195d11964a1c90513670ea8b058f009db
         
     | 
    
        data/.github/FUNDING.yml
    ADDED
    
    
    
        data/.gitignore
    CHANGED
    
    
    
        data/.rubocop.yml
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            inherit_gem:
         
     | 
| 
      
 3 
     | 
    
         
            +
              rubocop-fnando: .rubocop.yml
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            AllCops:
         
     | 
| 
      
 6 
     | 
    
         
            +
              TargetRubyVersion: 2.7
         
     | 
| 
      
 7 
     | 
    
         
            +
              NewCops: enable
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Naming/FileName:
         
     | 
| 
      
 10 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 11 
     | 
    
         
            +
                - lib/sinatra-subdomain.rb
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            Style/OptionalBooleanParameter:
         
     | 
| 
      
 14 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            Metrics/MethodLength:
         
     | 
| 
      
 17 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Metrics/BlockLength:
         
     | 
| 
      
 20 
     | 
    
         
            +
              Enabled: false
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            Metrics/AbcSize:
         
     | 
| 
      
 23 
     | 
    
         
            +
              Enabled: false
         
     | 
    
        data/.travis.yml
    ADDED
    
    | 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            language: ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            cache: bundler
         
     | 
| 
      
 3 
     | 
    
         
            +
            sudo: false
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            notifications:
         
     | 
| 
      
 6 
     | 
    
         
            +
              email: false
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            rvm:
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 2.7.1
         
     | 
| 
      
 10 
     | 
    
         
            +
              - 2.6.5
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            gemfile:
         
     | 
| 
      
 13 
     | 
    
         
            +
              - gemfiles/sinatra_2_1.gemfile
         
     | 
| 
      
 14 
     | 
    
         
            +
              - gemfiles/sinatra_2_0.gemfile
         
     | 
| 
      
 15 
     | 
    
         
            +
              - gemfiles/sinatra_1_4.gemfile
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            env:
         
     | 
| 
      
 18 
     | 
    
         
            +
              global:
         
     | 
| 
      
 19 
     | 
    
         
            +
                secure: Zq3YrKeSaVI0U5bcYDDnCOxbQDHPpPmTrNGe0M2qtVwN1tibpULIdZVMGOjJ4C4Ulk8OXqpI63aLkWm7fKIT0bQXvGK+w3bksUIHk2jODHfKb/ZDDfAoKhfU1APXnxcGbw06/FDyihWJFYdxrLZBilnvDmcqVz47DvmFBAlPuQ4=
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,124 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Sinatra Subdomain
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            [](https://travis-ci.org/fnando/sinatra-subdomain)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](https://codeclimate.com/github/fnando/sinatra-subdomain)
         
     | 
| 
      
 5 
     | 
    
         
            +
            [](https://rubygems.org/gems/sinatra-subdomain)
         
     | 
| 
      
 6 
     | 
    
         
            +
            [](https://rubygems.org/gems/sinatra-subdomain)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            ```
         
     | 
| 
      
 11 
     | 
    
         
            +
            gem install sinatra-subdomain
         
     | 
| 
      
 12 
     | 
    
         
            +
            ```
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 17 
     | 
    
         
            +
            require "sinatra"
         
     | 
| 
      
 18 
     | 
    
         
            +
            require "sinatra/subdomain"
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            # Specify which subdomain you want
         
     | 
| 
      
 21 
     | 
    
         
            +
            subdomain :foo do
         
     | 
| 
      
 22 
     | 
    
         
            +
              get "/" do
         
     | 
| 
      
 23 
     | 
    
         
            +
                "render page for FOO"
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            # If any subdomain is set
         
     | 
| 
      
 28 
     | 
    
         
            +
            subdomain do
         
     | 
| 
      
 29 
     | 
    
         
            +
              get "/" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                "render page for #{subdomain} subdomain"
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
            ```
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            If you're not building a classic app, make sure to register Sinatra::Subdomain
         
     | 
| 
      
 36 
     | 
    
         
            +
            yourself:
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 39 
     | 
    
         
            +
            require "sinatra"
         
     | 
| 
      
 40 
     | 
    
         
            +
            require "sinatra/subdomain"
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            # Specify which subdomain you want
         
     | 
| 
      
 43 
     | 
    
         
            +
            class MyApp < Sinatra::Base
         
     | 
| 
      
 44 
     | 
    
         
            +
              register Sinatra::Subdomain
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              subdomain :foo do
         
     | 
| 
      
 47 
     | 
    
         
            +
                get "/" do
         
     | 
| 
      
 48 
     | 
    
         
            +
                  "render page for FOO"
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              # If any subdomain is set
         
     | 
| 
      
 53 
     | 
    
         
            +
              subdomain do
         
     | 
| 
      
 54 
     | 
    
         
            +
                get "/" do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  "render page for #{subdomain} subdomain"
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
| 
      
 59 
     | 
    
         
            +
            ```
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            You can also pass an array, regular expressions to match subdomains, or a proc:
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 64 
     | 
    
         
            +
            class MyApp < Sinatra::Base
         
     | 
| 
      
 65 
     | 
    
         
            +
              register Sinatra::Subdomain
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              subdomain [:foo, :bar, :zaz] do
         
     | 
| 
      
 68 
     | 
    
         
            +
                get "/" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                  "render page for #{subdomain}"
         
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              # Matches www, www1, www2, etc.
         
     | 
| 
      
 74 
     | 
    
         
            +
              subdomain /\Awww\d*\z/ do
         
     | 
| 
      
 75 
     | 
    
         
            +
                get "/" do
         
     | 
| 
      
 76 
     | 
    
         
            +
                  "render page for #{subdomain} subdomain"
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              app_matcher = lambda do |subdomain|
         
     | 
| 
      
 81 
     | 
    
         
            +
                App.where(subdomain: actual_subdomain).exist?
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              subdomain(app_matcher) do
         
     | 
| 
      
 85 
     | 
    
         
            +
                get "/" do
         
     | 
| 
      
 86 
     | 
    
         
            +
                  "render page for #{subdomain} app"
         
     | 
| 
      
 87 
     | 
    
         
            +
                end
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
            end
         
     | 
| 
      
 90 
     | 
    
         
            +
            ```
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            By default, sinatra-subdomain will consider 1 TLD as in <tt>example.com</tt>.
         
     | 
| 
      
 93 
     | 
    
         
            +
            You can specify your TLD size for domains like <tt>example.com.br</tt> or
         
     | 
| 
      
 94 
     | 
    
         
            +
            <tt>example.co.uk</tt>.
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 97 
     | 
    
         
            +
            require "sinatra"
         
     | 
| 
      
 98 
     | 
    
         
            +
            require "sinatra/subdomain"
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            set :tld_size, 2
         
     | 
| 
      
 101 
     | 
    
         
            +
            ```
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            # License
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
            (The MIT License)
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            Copyright © 2010 - Nando Vieira (http://nandovieira.com)
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy of
         
     | 
| 
      
 110 
     | 
    
         
            +
            this software and associated documentation files (the ‘Software’), to deal in
         
     | 
| 
      
 111 
     | 
    
         
            +
            the Software without restriction, including without limitation the rights to
         
     | 
| 
      
 112 
     | 
    
         
            +
            use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
         
     | 
| 
      
 113 
     | 
    
         
            +
            the Software, and to permit persons to whom the Software is furnished to do so,
         
     | 
| 
      
 114 
     | 
    
         
            +
            subject to the following conditions:
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be included in all
         
     | 
| 
      
 117 
     | 
    
         
            +
            copies or substantial portions of the Software.
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         
     | 
| 
      
 120 
     | 
    
         
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
         
     | 
| 
      
 121 
     | 
    
         
            +
            FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
         
     | 
| 
      
 122 
     | 
    
         
            +
            COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
         
     | 
| 
      
 123 
     | 
    
         
            +
            IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
         
     | 
| 
      
 124 
     | 
    
         
            +
            CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -1,11 +1,15 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
               
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "bundler/gem_tasks"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "rake/testtask"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "rubocop/rake_task"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            Rake::TestTask.new(:test) do |t|
         
     | 
| 
      
 8 
     | 
    
         
            +
              t.libs << "test"
         
     | 
| 
      
 9 
     | 
    
         
            +
              t.test_files = FileList["test/**/*_test.rb"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              t.warning = false
         
     | 
| 
       11 
11 
     | 
    
         
             
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            RuboCop::RakeTask.new
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            task default: %i[test rubocop]
         
     | 
    
        data/lib/sinatra/subdomain.rb
    CHANGED
    
    | 
         @@ -1,29 +1,97 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require "sinatra/base"
         
     | 
| 
       2 
4 
     | 
    
         
             
            require "uri"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "resolv"
         
     | 
| 
       3 
6 
     | 
    
         | 
| 
       4 
7 
     | 
    
         
             
            module Sinatra
         
     | 
| 
       5 
8 
     | 
    
         
             
              module Subdomain
         
     | 
| 
      
 9 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_accessor :app, :subdomain
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                SINATRA_V2 = Gem::Requirement.create([">=2.0"]).satisfied_by?(
         
     | 
| 
      
 14 
     | 
    
         
            +
                  Gem::Version.create(Sinatra::VERSION)
         
     | 
| 
      
 15 
     | 
    
         
            +
                )
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       6 
17 
     | 
    
         
             
                module Helpers
         
     | 
| 
       7 
18 
     | 
    
         
             
                  def subdomain
         
     | 
| 
       8 
     | 
    
         
            -
                    uri = URI.parse("http://#{request.env[ 
     | 
| 
      
 19 
     | 
    
         
            +
                    uri = URI.parse("http://#{request.env['HTTP_HOST']}")
         
     | 
| 
      
 20 
     | 
    
         
            +
                    return if Sinatra::Subdomain.ip_address?(uri.host)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       9 
22 
     | 
    
         
             
                    parts = uri.host.split(".")
         
     | 
| 
       10 
23 
     | 
    
         
             
                    parts.pop(settings.tld_size + 1)
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    parts.empty? ? nil : parts.join(".")
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                # This is how this works:
         
     | 
| 
      
 30 
     | 
    
         
            +
                #
         
     | 
| 
      
 31 
     | 
    
         
            +
                # 1. Whenever you call `subdomain(&block)`, this is the method that's going
         
     | 
| 
      
 32 
     | 
    
         
            +
                #    to be executed.
         
     | 
| 
      
 33 
     | 
    
         
            +
                # 2. For each `subdomain` block, we set the app and subdomain condition as
         
     | 
| 
      
 34 
     | 
    
         
            +
                #    `Sinatra::Subdomain.app` and `Sinatra::Subdomain.subdomain`.
         
     | 
| 
      
 35 
     | 
    
         
            +
                # 3. Then, we yield the block, which will add the routes as needed.
         
     | 
| 
      
 36 
     | 
    
         
            +
                # 4. After each route is added, Sinatra triggers a hook called
         
     | 
| 
      
 37 
     | 
    
         
            +
                #    `:route_added`, handled by the `routed_added` method below.
         
     | 
| 
      
 38 
     | 
    
         
            +
                # 5. The `routed_added` method will hijack the routes, adding the subdomain
         
     | 
| 
      
 39 
     | 
    
         
            +
                #    condition.
         
     | 
| 
      
 40 
     | 
    
         
            +
                def subdomain(expected_subdomain = true)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  ::Sinatra::Subdomain.tap do |mod|
         
     | 
| 
      
 42 
     | 
    
         
            +
                    mod.app = self
         
     | 
| 
      
 43 
     | 
    
         
            +
                    mod.subdomain = expected_subdomain
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  yield
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  ::Sinatra::Subdomain.tap do |mod|
         
     | 
| 
      
 49 
     | 
    
         
            +
                    mod.app = nil
         
     | 
| 
      
 50 
     | 
    
         
            +
                    mod.subdomain = nil
         
     | 
| 
       12 
51 
     | 
    
         
             
                  end
         
     | 
| 
       13 
52 
     | 
    
         
             
                end
         
     | 
| 
       14 
53 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
                def  
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
                def self.ip_address?(host)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  host =~ Resolv::IPv4::Regex || host =~ Resolv::IPv6::Regex
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                def self.match_subdomain?(expected, actual)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  expected.any? do |expected_subdomain|
         
     | 
| 
      
 60 
     | 
    
         
            +
                    case expected_subdomain
         
     | 
| 
      
 61 
     | 
    
         
            +
                    when true
         
     | 
| 
      
 62 
     | 
    
         
            +
                      !actual.nil?
         
     | 
| 
      
 63 
     | 
    
         
            +
                    when Symbol
         
     | 
| 
      
 64 
     | 
    
         
            +
                      actual.to_s == expected_subdomain.to_s
         
     | 
| 
       21 
65 
     | 
    
         
             
                    else
         
     | 
| 
       22 
     | 
    
         
            -
                       
     | 
| 
      
 66 
     | 
    
         
            +
                      expected_subdomain === actual # rubocop:disable Style/CaseEquality
         
     | 
| 
       23 
67 
     | 
    
         
             
                    end
         
     | 
| 
       24 
68 
     | 
    
         
             
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
       25 
70 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 71 
     | 
    
         
            +
                def self.route_added(verb, _path, _block)
         
     | 
| 
      
 72 
     | 
    
         
            +
                  return unless subdomain && app
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                  routes = app.instance_variable_get("@routes")
         
     | 
| 
      
 75 
     | 
    
         
            +
                  last_route = routes[verb].last
         
     | 
| 
      
 76 
     | 
    
         
            +
                  expected = [subdomain].flatten.compact
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                  condition = app.instance_eval do
         
     | 
| 
      
 79 
     | 
    
         
            +
                    generate_method :subdomain_matcher do
         
     | 
| 
      
 80 
     | 
    
         
            +
                      ::Sinatra::Subdomain.match_subdomain?(expected, subdomain)
         
     | 
| 
      
 81 
     | 
    
         
            +
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                  end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                  add_condition(last_route, condition)
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                if SINATRA_V2
         
     | 
| 
      
 88 
     | 
    
         
            +
                  def self.add_condition(last_route, condition)
         
     | 
| 
      
 89 
     | 
    
         
            +
                    last_route[1] << condition
         
     | 
| 
      
 90 
     | 
    
         
            +
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
                else
         
     | 
| 
      
 92 
     | 
    
         
            +
                  def self.add_condition(last_route, condition)
         
     | 
| 
      
 93 
     | 
    
         
            +
                    last_route[2] << condition
         
     | 
| 
      
 94 
     | 
    
         
            +
                  end
         
     | 
| 
       27 
95 
     | 
    
         
             
                end
         
     | 
| 
       28 
96 
     | 
    
         | 
| 
       29 
97 
     | 
    
         
             
                def self.registered(app)
         
     | 
    
        data/sinatra-subdomain.gemspec
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require "sinatra/subdomain/version"
         
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "./lib/sinatra/subdomain/version"
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       6 
6 
     | 
    
         
             
              s.name        = "sinatra-subdomain"
         
     | 
| 
         @@ -10,15 +10,23 @@ Gem::Specification.new do |s| 
     | 
|
| 
       10 
10 
     | 
    
         
             
              s.email       = ["fnando.vieira@gmail.com"]
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.homepage    = "http://rubygems.org/gems/sinatra-subdomain"
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.summary     = "Separate routes for subdomains on Sinatra"
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.license     = "MIT"
         
     | 
| 
       13 
14 
     | 
    
         
             
              s.description = s.summary
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
       15 
17 
     | 
    
         
             
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
       16 
18 
     | 
    
         
             
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
       17 
     | 
    
         
            -
              s.executables   = `git ls-files -- bin 
     | 
| 
      
 19 
     | 
    
         
            +
              s.executables   = `git ls-files -- bin/*`
         
     | 
| 
      
 20 
     | 
    
         
            +
                                .split("\n")
         
     | 
| 
      
 21 
     | 
    
         
            +
                                .map {|f| File.basename(f) }
         
     | 
| 
       18 
22 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       19 
23 
     | 
    
         | 
| 
       20 
24 
     | 
    
         
             
              s.add_dependency "sinatra"
         
     | 
| 
       21 
     | 
    
         
            -
              s.add_development_dependency " 
     | 
| 
      
 25 
     | 
    
         
            +
              s.add_development_dependency "minitest-utils"
         
     | 
| 
      
 26 
     | 
    
         
            +
              s.add_development_dependency "pry-meta"
         
     | 
| 
       22 
27 
     | 
    
         
             
              s.add_development_dependency "rack-test"
         
     | 
| 
       23 
     | 
    
         
            -
              s.add_development_dependency " 
     | 
| 
      
 28 
     | 
    
         
            +
              s.add_development_dependency "rake"
         
     | 
| 
      
 29 
     | 
    
         
            +
              s.add_development_dependency "rubocop"
         
     | 
| 
      
 30 
     | 
    
         
            +
              s.add_development_dependency "rubocop-fnando"
         
     | 
| 
      
 31 
     | 
    
         
            +
              s.add_development_dependency "simplecov"
         
     | 
| 
       24 
32 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "test_helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class IpAddressTest < Minitest::Test
         
     | 
| 
      
 6 
     | 
    
         
            +
              def app
         
     | 
| 
      
 7 
     | 
    
         
            +
                App
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              test "renders no subdomain root page" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                header "HOST", "127.0.0.1"
         
     | 
| 
      
 12 
     | 
    
         
            +
                get "/"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                assert_equal "root", last_response.body
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              test "renders no subdomain about page" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                header "HOST", "127.0.0.1"
         
     | 
| 
      
 19 
     | 
    
         
            +
                get "/about"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                assert_equal "about", last_response.body
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "test_helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class SubdomainsTest < Minitest::Test
         
     | 
| 
      
 6 
     | 
    
         
            +
              def app
         
     | 
| 
      
 7 
     | 
    
         
            +
                App
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              test "renders listed subdomain (a)" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                header "HOST", "a.example.com"
         
     | 
| 
      
 12 
     | 
    
         
            +
                get "/"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                assert_equal "array: a", last_response.body
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              test "renders listed subdomain (b)" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                header "HOST", "b.example.com"
         
     | 
| 
      
 19 
     | 
    
         
            +
                get "/"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                assert_equal "array: b", last_response.body
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              test "renders matched subdomain (c)" do
         
     | 
| 
      
 25 
     | 
    
         
            +
                header "HOST", "c.example.com"
         
     | 
| 
      
 26 
     | 
    
         
            +
                get "/"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                assert_equal "regex: c", last_response.body
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              test "renders matched subdomain (d)" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                header "HOST", "d.example.com"
         
     | 
| 
      
 33 
     | 
    
         
            +
                get "/"
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                assert_equal "regex: d", last_response.body
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              test "renders matched subdomain (e)" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                header "HOST", "e.example.com"
         
     | 
| 
      
 40 
     | 
    
         
            +
                get "/"
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                assert_equal "proc: e", last_response.body
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
    
        data/test/support/app.rb
    ADDED
    
    | 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class App < Sinatra::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
              register Sinatra::Subdomain
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              subdomain :foo do
         
     | 
| 
      
 7 
     | 
    
         
            +
                get("/") { "set: #{subdomain}" }
         
     | 
| 
      
 8 
     | 
    
         
            +
                get("/about") { "set: about #{subdomain}" }
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              subdomain "foo.bar" do
         
     | 
| 
      
 12 
     | 
    
         
            +
                get("/") { "multiple: #{subdomain}" }
         
     | 
| 
      
 13 
     | 
    
         
            +
                get("/about") { "multiple: about #{subdomain}" }
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              subdomain [:a, :b] do
         
     | 
| 
      
 17 
     | 
    
         
            +
                get("/") { "array: #{subdomain}" }
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              subdomain(/\A(c|d)\z/) do
         
     | 
| 
      
 21 
     | 
    
         
            +
                get("/") { "regex: #{subdomain}" }
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              subdomain(->(actual) { actual == "e" }) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                get("/") { "proc: #{subdomain}" }
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              subdomain do
         
     | 
| 
      
 29 
     | 
    
         
            +
                get("/") { "any: #{subdomain}" }
         
     | 
| 
      
 30 
     | 
    
         
            +
                get("/about") { "any: about #{subdomain}" }
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              get("/") { "root" }
         
     | 
| 
      
 34 
     | 
    
         
            +
              get("/about") { "about" }
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,71 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module SubdomainTests
         
     | 
| 
      
 4 
     | 
    
         
            +
              def app
         
     | 
| 
      
 5 
     | 
    
         
            +
                current_tld = tld
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                Class.new(App) do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  set :tld_size, current_tld.split(".").size - 1
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              def self.included(base)
         
     | 
| 
      
 13 
     | 
    
         
            +
                base.class_eval do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  test "when specific subdomain is required - renders root page" do
         
     | 
| 
      
 15 
     | 
    
         
            +
                    header "HOST", "foo.example#{tld}"
         
     | 
| 
      
 16 
     | 
    
         
            +
                    get "/"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                    assert_equal "set: foo", last_response.body
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  test "when specific subdomain is required - renders about page" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                    header "HOST", "foo.example#{tld}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    get "/about"
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    assert_equal "set: about foo", last_response.body
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  test "when any subdomain is required - renders root page" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                    header "HOST", "mail.example#{tld}"
         
     | 
| 
      
 30 
     | 
    
         
            +
                    get "/"
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    assert_equal "any: mail", last_response.body
         
     | 
| 
      
 33 
     | 
    
         
            +
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  test "when any subdomain is required - renders about page" do
         
     | 
| 
      
 36 
     | 
    
         
            +
                    header "HOST", "mail.example#{tld}"
         
     | 
| 
      
 37 
     | 
    
         
            +
                    get "/about"
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                    assert_equal "any: about mail", last_response.body
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  test "when no subdomain is required - renders root page" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                    header "HOST", "example#{tld}"
         
     | 
| 
      
 44 
     | 
    
         
            +
                    get "/"
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    assert_equal "root", last_response.body
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                  test "when no subdomain is required - renders about page" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                    header "HOST", "example#{tld}"
         
     | 
| 
      
 51 
     | 
    
         
            +
                    get "/about"
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                    assert_equal "about", last_response.body
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                  test "when multi-subdomain is required - renders root page" do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    header "HOST", "foo.bar.example#{tld}"
         
     | 
| 
      
 58 
     | 
    
         
            +
                    get "/"
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    assert_equal "multiple: foo.bar", last_response.body
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  test "when multi-subdomain is required - renders about page" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                    header "HOST", "foo.bar.example#{tld}"
         
     | 
| 
      
 65 
     | 
    
         
            +
                    get "/about"
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                    assert_equal "multiple: about foo.bar", last_response.body
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
            end
         
     | 
    
        data/test/test_helper.rb
    CHANGED
    
    | 
         @@ -1,41 +1,20 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            require "rack/test"
         
     | 
| 
       3 
     | 
    
         
            -
            require "capybara"
         
     | 
| 
       4 
     | 
    
         
            -
            require "capybara/dsl"
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            require "sinatra/subdomain"
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            Capybara.default_driver = :selenium
         
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       9 
2 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            class SampleApp < Sinatra::Base
         
     | 
| 
       15 
     | 
    
         
            -
              register Sinatra::Subdomain
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "simplecov"
         
     | 
| 
      
 4 
     | 
    
         
            +
            SimpleCov.start
         
     | 
| 
       16 
5 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                get("/") { "set: #{subdomain}" }
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "bundler/setup"
         
     | 
| 
       20 
7 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            class MultipleTldsApp < Sinatra::Base
         
     | 
| 
       29 
     | 
    
         
            -
              register Sinatra::Subdomain
         
     | 
| 
       30 
     | 
    
         
            -
              set :tld_size, 2
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "minitest/utils"
         
     | 
| 
      
 9 
     | 
    
         
            +
            require "minitest/autorun"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require "rack/test"
         
     | 
| 
      
 11 
     | 
    
         
            +
            require "sinatra/subdomain"
         
     | 
| 
      
 12 
     | 
    
         
            +
            require "yaml"
         
     | 
| 
       31 
13 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                get("/") { "set: #{subdomain}" }
         
     | 
| 
       34 
     | 
    
         
            -
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            Dir["./test/support/**/*.rb"].sort.each {|file| require file }
         
     | 
| 
       35 
15 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
            module Minitest
         
     | 
| 
      
 17 
     | 
    
         
            +
              class Test
         
     | 
| 
      
 18 
     | 
    
         
            +
                include Rack::Test::Methods
         
     | 
| 
       38 
19 
     | 
    
         
             
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
              get("/") { "root" }
         
     | 
| 
       41 
20 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,60 +1,127 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: sinatra-subdomain
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
       5 
     | 
    
         
            -
              prerelease: 
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       6 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       8 
7 
     | 
    
         
             
            - Nando Vieira
         
     | 
| 
       9 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       10 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-09-24 00:00:00.000000000 Z
         
     | 
| 
       13 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
14 
     | 
    
         
             
              name: sinatra
         
     | 
| 
       16 
     | 
    
         
            -
              requirement:  
     | 
| 
       17 
     | 
    
         
            -
                none: false
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       18 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
       19 
     | 
    
         
            -
                - -  
     | 
| 
      
 17 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       20 
18 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       21 
19 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       22 
20 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       23 
21 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       24 
     | 
    
         
            -
              version_requirements:  
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       25 
27 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       26 
     | 
    
         
            -
              name:  
     | 
| 
       27 
     | 
    
         
            -
              requirement:  
     | 
| 
       28 
     | 
    
         
            -
                 
     | 
| 
      
 28 
     | 
    
         
            +
              name: minitest-utils
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: pry-meta
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       29 
44 
     | 
    
         
             
                requirements:
         
     | 
| 
       30 
     | 
    
         
            -
                - -  
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       31 
46 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       32 
47 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       33 
48 
     | 
    
         
             
              type: :development
         
     | 
| 
       34 
49 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       35 
     | 
    
         
            -
              version_requirements:  
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       36 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       37 
56 
     | 
    
         
             
              name: rack-test
         
     | 
| 
       38 
     | 
    
         
            -
              requirement:  
     | 
| 
       39 
     | 
    
         
            -
                none: false
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       40 
58 
     | 
    
         
             
                requirements:
         
     | 
| 
       41 
     | 
    
         
            -
                - -  
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       42 
60 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       43 
61 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       44 
62 
     | 
    
         
             
              type: :development
         
     | 
| 
       45 
63 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       46 
     | 
    
         
            -
              version_requirements:  
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       47 
69 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       48 
     | 
    
         
            -
              name:  
     | 
| 
       49 
     | 
    
         
            -
              requirement:  
     | 
| 
       50 
     | 
    
         
            -
                none: false
         
     | 
| 
      
 70 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 71 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       51 
72 
     | 
    
         
             
                requirements:
         
     | 
| 
       52 
     | 
    
         
            -
                - -  
     | 
| 
      
 73 
     | 
    
         
            +
                - - ">="
         
     | 
| 
       53 
74 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       54 
75 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       55 
76 
     | 
    
         
             
              type: :development
         
     | 
| 
       56 
77 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       57 
     | 
    
         
            -
              version_requirements:  
     | 
| 
      
 78 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 79 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 80 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 81 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 82 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 83 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 84 
     | 
    
         
            +
              name: rubocop
         
     | 
| 
      
 85 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 86 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 87 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 88 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 89 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 90 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 91 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 92 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 93 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 94 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 95 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 96 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 97 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: rubocop-fnando
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 111 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 112 
     | 
    
         
            +
              name: simplecov
         
     | 
| 
      
 113 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 114 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 115 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 116 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 117 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 118 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 119 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 120 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 121 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 122 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 123 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 124 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       58 
125 
     | 
    
         
             
            description: Separate routes for subdomains on Sinatra
         
     | 
| 
       59 
126 
     | 
    
         
             
            email:
         
     | 
| 
       60 
127 
     | 
    
         
             
            - fnando.vieira@gmail.com
         
     | 
| 
         @@ -62,48 +129,56 @@ executables: [] 
     | 
|
| 
       62 
129 
     | 
    
         
             
            extensions: []
         
     | 
| 
       63 
130 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       64 
131 
     | 
    
         
             
            files:
         
     | 
| 
       65 
     | 
    
         
            -
            - . 
     | 
| 
      
 132 
     | 
    
         
            +
            - ".github/FUNDING.yml"
         
     | 
| 
      
 133 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 134 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
      
 135 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
       66 
136 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       67 
     | 
    
         
            -
            -  
     | 
| 
       68 
     | 
    
         
            -
            - README.rdoc
         
     | 
| 
      
 137 
     | 
    
         
            +
            - README.md
         
     | 
| 
       69 
138 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 139 
     | 
    
         
            +
            - gemfiles/sinatra_1_4.gemfile
         
     | 
| 
      
 140 
     | 
    
         
            +
            - gemfiles/sinatra_2_0.gemfile
         
     | 
| 
      
 141 
     | 
    
         
            +
            - gemfiles/sinatra_2_1.gemfile
         
     | 
| 
       70 
142 
     | 
    
         
             
            - lib/sinatra/subdomain.rb
         
     | 
| 
       71 
143 
     | 
    
         
             
            - lib/sinatra/subdomain/version.rb
         
     | 
| 
       72 
144 
     | 
    
         
             
            - sinatra-subdomain.gemspec
         
     | 
| 
       73 
     | 
    
         
            -
            - test/ 
     | 
| 
       74 
     | 
    
         
            -
            - test/ 
     | 
| 
      
 145 
     | 
    
         
            +
            - test/sinatra-subdomain/ip_address_test.rb
         
     | 
| 
      
 146 
     | 
    
         
            +
            - test/sinatra-subdomain/multiple_subdomain_test.rb
         
     | 
| 
      
 147 
     | 
    
         
            +
            - test/sinatra-subdomain/multiple_tlds_test.rb
         
     | 
| 
      
 148 
     | 
    
         
            +
            - test/sinatra-subdomain/single_tld_test.rb
         
     | 
| 
      
 149 
     | 
    
         
            +
            - test/sinatra-subdomain/subdomains_test.rb
         
     | 
| 
      
 150 
     | 
    
         
            +
            - test/support/app.rb
         
     | 
| 
      
 151 
     | 
    
         
            +
            - test/support/subdomain_tests.rb
         
     | 
| 
       75 
152 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
| 
       76 
153 
     | 
    
         
             
            homepage: http://rubygems.org/gems/sinatra-subdomain
         
     | 
| 
       77 
     | 
    
         
            -
            licenses: 
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
      
 154 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 155 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 156 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 157 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       79 
158 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       80 
159 
     | 
    
         
             
            require_paths:
         
     | 
| 
       81 
160 
     | 
    
         
             
            - lib
         
     | 
| 
       82 
161 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       83 
     | 
    
         
            -
              none: false
         
     | 
| 
       84 
162 
     | 
    
         
             
              requirements:
         
     | 
| 
       85 
     | 
    
         
            -
              - -  
     | 
| 
      
 163 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       86 
164 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       87 
     | 
    
         
            -
                  version:  
     | 
| 
       88 
     | 
    
         
            -
                  segments:
         
     | 
| 
       89 
     | 
    
         
            -
                  - 0
         
     | 
| 
       90 
     | 
    
         
            -
                  hash: -355263696072099514
         
     | 
| 
      
 165 
     | 
    
         
            +
                  version: 2.5.0
         
     | 
| 
       91 
166 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       92 
     | 
    
         
            -
              none: false
         
     | 
| 
       93 
167 
     | 
    
         
             
              requirements:
         
     | 
| 
       94 
     | 
    
         
            -
              - -  
     | 
| 
      
 168 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       95 
169 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       96 
170 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       97 
     | 
    
         
            -
                  segments:
         
     | 
| 
       98 
     | 
    
         
            -
                  - 0
         
     | 
| 
       99 
     | 
    
         
            -
                  hash: -355263696072099514
         
     | 
| 
       100 
171 
     | 
    
         
             
            requirements: []
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
            specification_version: 3
         
     | 
| 
      
 172 
     | 
    
         
            +
            rubygems_version: 3.1.2
         
     | 
| 
      
 173 
     | 
    
         
            +
            signing_key:
         
     | 
| 
      
 174 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
       105 
175 
     | 
    
         
             
            summary: Separate routes for subdomains on Sinatra
         
     | 
| 
       106 
176 
     | 
    
         
             
            test_files:
         
     | 
| 
       107 
     | 
    
         
            -
            - test/ 
     | 
| 
       108 
     | 
    
         
            -
            - test/ 
     | 
| 
      
 177 
     | 
    
         
            +
            - test/sinatra-subdomain/ip_address_test.rb
         
     | 
| 
      
 178 
     | 
    
         
            +
            - test/sinatra-subdomain/multiple_subdomain_test.rb
         
     | 
| 
      
 179 
     | 
    
         
            +
            - test/sinatra-subdomain/multiple_tlds_test.rb
         
     | 
| 
      
 180 
     | 
    
         
            +
            - test/sinatra-subdomain/single_tld_test.rb
         
     | 
| 
      
 181 
     | 
    
         
            +
            - test/sinatra-subdomain/subdomains_test.rb
         
     | 
| 
      
 182 
     | 
    
         
            +
            - test/support/app.rb
         
     | 
| 
      
 183 
     | 
    
         
            +
            - test/support/subdomain_tests.rb
         
     | 
| 
       109 
184 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
    
        data/Gemfile.lock
    DELETED
    
    | 
         @@ -1,49 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            PATH
         
     | 
| 
       2 
     | 
    
         
            -
              remote: .
         
     | 
| 
       3 
     | 
    
         
            -
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                sinatra-subdomain (0.1.1)
         
     | 
| 
       5 
     | 
    
         
            -
                  sinatra
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            GEM
         
     | 
| 
       8 
     | 
    
         
            -
              remote: http://rubygems.org/
         
     | 
| 
       9 
     | 
    
         
            -
              specs:
         
     | 
| 
       10 
     | 
    
         
            -
                capybara (1.1.1)
         
     | 
| 
       11 
     | 
    
         
            -
                  mime-types (>= 1.16)
         
     | 
| 
       12 
     | 
    
         
            -
                  nokogiri (>= 1.3.3)
         
     | 
| 
       13 
     | 
    
         
            -
                  rack (>= 1.0.0)
         
     | 
| 
       14 
     | 
    
         
            -
                  rack-test (>= 0.5.4)
         
     | 
| 
       15 
     | 
    
         
            -
                  selenium-webdriver (~> 2.0)
         
     | 
| 
       16 
     | 
    
         
            -
                  xpath (~> 0.1.4)
         
     | 
| 
       17 
     | 
    
         
            -
                childprocess (0.2.2)
         
     | 
| 
       18 
     | 
    
         
            -
                  ffi (~> 1.0.6)
         
     | 
| 
       19 
     | 
    
         
            -
                ffi (1.0.9)
         
     | 
| 
       20 
     | 
    
         
            -
                json_pure (1.5.4)
         
     | 
| 
       21 
     | 
    
         
            -
                  spruz (~> 0.2.8)
         
     | 
| 
       22 
     | 
    
         
            -
                mime-types (1.16)
         
     | 
| 
       23 
     | 
    
         
            -
                nokogiri (1.5.0)
         
     | 
| 
       24 
     | 
    
         
            -
                rack (1.3.2)
         
     | 
| 
       25 
     | 
    
         
            -
                rack-test (0.6.1)
         
     | 
| 
       26 
     | 
    
         
            -
                  rack (>= 1.0)
         
     | 
| 
       27 
     | 
    
         
            -
                rake (0.9.2)
         
     | 
| 
       28 
     | 
    
         
            -
                rubyzip (0.9.4)
         
     | 
| 
       29 
     | 
    
         
            -
                selenium-webdriver (2.5.0)
         
     | 
| 
       30 
     | 
    
         
            -
                  childprocess (>= 0.2.1)
         
     | 
| 
       31 
     | 
    
         
            -
                  ffi (>= 1.0.7)
         
     | 
| 
       32 
     | 
    
         
            -
                  json_pure
         
     | 
| 
       33 
     | 
    
         
            -
                  rubyzip
         
     | 
| 
       34 
     | 
    
         
            -
                sinatra (1.2.6)
         
     | 
| 
       35 
     | 
    
         
            -
                  rack (~> 1.1)
         
     | 
| 
       36 
     | 
    
         
            -
                  tilt (>= 1.2.2, < 2.0)
         
     | 
| 
       37 
     | 
    
         
            -
                spruz (0.2.13)
         
     | 
| 
       38 
     | 
    
         
            -
                tilt (1.3.3)
         
     | 
| 
       39 
     | 
    
         
            -
                xpath (0.1.4)
         
     | 
| 
       40 
     | 
    
         
            -
                  nokogiri (~> 1.3)
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
            PLATFORMS
         
     | 
| 
       43 
     | 
    
         
            -
              ruby
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
            DEPENDENCIES
         
     | 
| 
       46 
     | 
    
         
            -
              capybara
         
     | 
| 
       47 
     | 
    
         
            -
              rack-test
         
     | 
| 
       48 
     | 
    
         
            -
              rake
         
     | 
| 
       49 
     | 
    
         
            -
              sinatra-subdomain!
         
     | 
    
        data/README.rdoc
    DELETED
    
    | 
         @@ -1,48 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            = Sinatra Subdomain
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            == Installation
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              sudo gem install sinatra-subdomain
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            == Usage
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              require "sinatra"
         
     | 
| 
       10 
     | 
    
         
            -
              require "sinatra/subdomain"
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              # Specify which subdomain you want
         
     | 
| 
       13 
     | 
    
         
            -
              subdomain :foo do
         
     | 
| 
       14 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       15 
     | 
    
         
            -
                  "render page for FOO"
         
     | 
| 
       16 
     | 
    
         
            -
                end
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              # If any subdomain is set
         
     | 
| 
       20 
     | 
    
         
            -
              subdomain do
         
     | 
| 
       21 
     | 
    
         
            -
                get '/' do
         
     | 
| 
       22 
     | 
    
         
            -
                  "render page for #{subdomain} subdomain"
         
     | 
| 
       23 
     | 
    
         
            -
                end
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            By default, sinatra-subdomain will consider 1 TLD as in <tt>example.com</tt>.
         
     | 
| 
       27 
     | 
    
         
            -
            You can specify your TLD size for domains like <tt>example.com.br</tt> or <tt>example.co.uk</tt>.
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
              require "sinatra"
         
     | 
| 
       30 
     | 
    
         
            -
              require "sinatra/subdomain"
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              set :tld_size, 2
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            This extension was based on http://github.com/akahn/sinatra-subdomain/
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            = License
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
            (The MIT License)
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
            Copyright © 2010:
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
            * Nando Vieira (http://simplesideias.com.br)
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
            Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
            The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
            THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/test/multiple_tlds_test.rb
    DELETED
    
    | 
         @@ -1,25 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "test_helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class MultipleTldsTest < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
              def setup
         
     | 
| 
       5 
     | 
    
         
            -
                Capybara.app = MultipleTldsApp
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              def test_specified_subdomain
         
     | 
| 
       9 
     | 
    
         
            -
                visit "http://foo.smackaho.smackaho.st:9887/"
         
     | 
| 
       10 
     | 
    
         
            -
                assert page.has_content? "set: foo"
         
     | 
| 
       11 
     | 
    
         
            -
              end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
              def test_any_subdomain
         
     | 
| 
       14 
     | 
    
         
            -
                visit "http://status.smackaho.smackaho.st:9887/"
         
     | 
| 
       15 
     | 
    
         
            -
                assert page.has_content? "any: status"
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                visit "http://mail.smackaho.smackaho.st:9887/"
         
     | 
| 
       18 
     | 
    
         
            -
                assert page.has_content? "any: mail"
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              def test_root
         
     | 
| 
       22 
     | 
    
         
            -
                visit "http://smackaho.smackaho.st:9887/"
         
     | 
| 
       23 
     | 
    
         
            -
                assert page.has_content? "root"
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
            end
         
     | 
    
        data/test/subdomain_test.rb
    DELETED
    
    | 
         @@ -1,25 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require "test_helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class SubdomainTest < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
              def setup
         
     | 
| 
       5 
     | 
    
         
            -
                Capybara.app = SampleApp
         
     | 
| 
       6 
     | 
    
         
            -
              end
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              def test_specified_subdomain
         
     | 
| 
       9 
     | 
    
         
            -
                visit "http://foo.smackaho.st:9887/"
         
     | 
| 
       10 
     | 
    
         
            -
                assert page.has_content? "set: foo"
         
     | 
| 
       11 
     | 
    
         
            -
              end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
              def test_any_subdomain
         
     | 
| 
       14 
     | 
    
         
            -
                visit "http://status.smackaho.st:9887/"
         
     | 
| 
       15 
     | 
    
         
            -
                assert page.has_content? "any: status"
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                visit "http://mail.smackaho.st:9887/"
         
     | 
| 
       18 
     | 
    
         
            -
                assert page.has_content? "any: mail"
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              def test_root
         
     | 
| 
       22 
     | 
    
         
            -
                visit "http://smackaho.st:9887/"
         
     | 
| 
       23 
     | 
    
         
            -
                assert page.has_content? "root"
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
            end
         
     |