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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08247d5419cc684ee82146875f924297a68f89d6
4
- data.tar.gz: 0f38bbcf7aec377e4f3f6c10bd414e0545f1bfb4
3
+ metadata.gz: e8842478e8af1a0b347a8f1af15e48bfabed5610
4
+ data.tar.gz: 3264574516fbd993d2d768463c198e88b18c0771
5
5
  SHA512:
6
- metadata.gz: ccad68580ee9adc7b692dfc9ab9234c1d9398225419cc20b211c396ca1a089721df9c8e1fab00950ed54eedcc98df7468ade3053316867f3a93f23e3bd37cc6a
7
- data.tar.gz: 5f39b2df84cd7fd9a962ed3ad25de5587d1e63f5ff0ed0ce731d8e293d5f5d12b169152f64df87a586a0431cff6c91fcc594200407fdee6832eb3a2a5898ad39
6
+ metadata.gz: 1c6c4b4520b1cea1dc1f0b1d03ad3fd941d9c563f9ebf03212f7624779117625b231409e2afc1fa8449f5f5bb770a339ef56dd6bf1c043a0191c2ca917ff9af7
7
+ data.tar.gz: a5d04262a271551df22ac3e3b84b9669e6db3c238e400312132b28fcc55a4d939fe2c805e6b4f691f56a0152558af3d9c6d4d24e44263f2b8dfec86b316f88e5
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  pkg
2
2
  *.lock
3
+ coverage
data/.travis.yml CHANGED
@@ -1,12 +1,19 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  sudo: false
4
- notifictions:
4
+
5
+ notifications:
5
6
  email: false
7
+
6
8
  rvm:
7
- - 2.3.0
8
- - '2.2'
9
- - '2.1'
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
@@ -1,2 +1,3 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
+
2
3
  gemspec
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
- subdomain :foo do
44
- get '/' do
45
- "render page for FOO"
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
- get '/' do
52
- "render page for #{subdomain} subdomain"
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
  ```
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem 'sinatra', '~> 1.4', '>= 1.4.7'
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem 'sinatra', '~> 2.0.0.beta2'
@@ -19,7 +19,7 @@ module Sinatra
19
19
  end
20
20
  end
21
21
 
22
- def subdomain(expected_subdomain = true, &block)
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, path, block)
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 != nil
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[2] << condition
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)
@@ -3,7 +3,7 @@ module Sinatra
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- PATCH = 0
6
+ PATCH = 1
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
8
  end
9
9
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
1
+ require 'simplecov'
2
+ SimpleCov.start
3
3
 
4
4
  require "bundler/setup"
5
5
 
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.0
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: 2016-04-16 00:00:00.000000000 Z
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.5.1
141
+ rubygems_version: 2.6.11
140
142
  signing_key:
141
143
  specification_version: 4
142
144
  summary: Separate routes for subdomains on Sinatra