sinatra-subdomain 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +11 -4
- data/Gemfile +2 -1
- data/README.md +12 -8
- data/gemfiles/sinatra_1.gemfile +5 -0
- data/gemfiles/sinatra_2.gemfile +5 -0
- data/lib/sinatra/subdomain.rb +14 -4
- data/lib/sinatra/subdomain/version.rb +1 -1
- data/test/test_helper.rb +2 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8842478e8af1a0b347a8f1af15e48bfabed5610
|
4
|
+
data.tar.gz: 3264574516fbd993d2d768463c198e88b18c0771
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c6c4b4520b1cea1dc1f0b1d03ad3fd941d9c563f9ebf03212f7624779117625b231409e2afc1fa8449f5f5bb770a339ef56dd6bf1c043a0191c2ca917ff9af7
|
7
|
+
data.tar.gz: a5d04262a271551df22ac3e3b84b9669e6db3c238e400312132b28fcc55a4d939fe2c805e6b4f691f56a0152558af3d9c6d4d24e44263f2b8dfec86b316f88e5
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
sudo: false
|
4
|
-
|
4
|
+
|
5
|
+
notifications:
|
5
6
|
email: false
|
7
|
+
|
6
8
|
rvm:
|
7
|
-
- 2.
|
8
|
-
-
|
9
|
-
-
|
9
|
+
- 2.2.6
|
10
|
+
- 2.3.3
|
11
|
+
- 2.4.0
|
12
|
+
|
13
|
+
gemfile:
|
14
|
+
- gemfiles/sinatra_2.gemfile
|
15
|
+
- gemfiles/sinatra_1.gemfile
|
16
|
+
|
10
17
|
env:
|
11
18
|
global:
|
12
19
|
secure: Zq3YrKeSaVI0U5bcYDDnCOxbQDHPpPmTrNGe0M2qtVwN1tibpULIdZVMGOjJ4C4Ulk8OXqpI63aLkWm7fKIT0bQXvGK+w3bksUIHk2jODHfKb/ZDDfAoKhfU1APXnxcGbw06/FDyihWJFYdxrLZBilnvDmcqVz47DvmFBAlPuQ4=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -40,16 +40,20 @@ require "sinatra"
|
|
40
40
|
require "sinatra/subdomain"
|
41
41
|
|
42
42
|
# Specify which subdomain you want
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
class MyApp < Sinatra::Base
|
44
|
+
register Sinatra::Subdomain
|
45
|
+
|
46
|
+
subdomain :foo do
|
47
|
+
get '/' do
|
48
|
+
"render page for FOO"
|
49
|
+
end
|
46
50
|
end
|
47
|
-
end
|
48
51
|
|
49
|
-
# If any subdomain is set
|
50
|
-
subdomain do
|
51
|
-
|
52
|
-
|
52
|
+
# If any subdomain is set
|
53
|
+
subdomain do
|
54
|
+
get '/' do
|
55
|
+
"render page for #{subdomain} subdomain"
|
56
|
+
end
|
53
57
|
end
|
54
58
|
end
|
55
59
|
```
|
data/lib/sinatra/subdomain.rb
CHANGED
@@ -19,7 +19,7 @@ module Sinatra
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def subdomain(expected_subdomain = true
|
22
|
+
def subdomain(expected_subdomain = true)
|
23
23
|
::Sinatra::Subdomain.tap do |mod|
|
24
24
|
mod.app = self
|
25
25
|
mod.subdomain = expected_subdomain
|
@@ -37,7 +37,7 @@ module Sinatra
|
|
37
37
|
host =~ Resolv::IPv4::Regex || host =~ Resolv::IPv6::Regex
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.route_added(verb,
|
40
|
+
def self.route_added(verb, _path, _block)
|
41
41
|
return unless subdomain && app
|
42
42
|
|
43
43
|
routes = app.instance_variable_get("@routes")
|
@@ -47,14 +47,24 @@ module Sinatra
|
|
47
47
|
condition = app.instance_eval do
|
48
48
|
generate_method :subdomain do
|
49
49
|
if expected == true
|
50
|
-
subdomain
|
50
|
+
!subdomain.nil?
|
51
51
|
else
|
52
52
|
subdomain.to_s == expected.to_s
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
last_route
|
57
|
+
add_condition(last_route, condition)
|
58
|
+
end
|
59
|
+
|
60
|
+
if Gem::Requirement.create(["~>2.0"]).satisfied_by?(Gem::Version.create(Sinatra::VERSION))
|
61
|
+
def self.add_condition(last_route, condition)
|
62
|
+
last_route[1] << condition
|
63
|
+
end
|
64
|
+
else
|
65
|
+
def self.add_condition(last_route, condition)
|
66
|
+
last_route[2] << condition
|
67
|
+
end
|
58
68
|
end
|
59
69
|
|
60
70
|
def self.registered(app)
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-subdomain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -106,6 +106,8 @@ files:
|
|
106
106
|
- Gemfile
|
107
107
|
- README.md
|
108
108
|
- Rakefile
|
109
|
+
- gemfiles/sinatra_1.gemfile
|
110
|
+
- gemfiles/sinatra_2.gemfile
|
109
111
|
- lib/sinatra/subdomain.rb
|
110
112
|
- lib/sinatra/subdomain/version.rb
|
111
113
|
- sinatra-subdomain.gemspec
|
@@ -136,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
138
|
version: '0'
|
137
139
|
requirements: []
|
138
140
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.6.11
|
140
142
|
signing_key:
|
141
143
|
specification_version: 4
|
142
144
|
summary: Separate routes for subdomains on Sinatra
|