local-subdomain 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 637b348da01a0eb3479c53f691fb09b3f784d34d
4
- data.tar.gz: d323c0cc013e1e78b15392ca9fdce0fde6da1749
3
+ metadata.gz: f021832fedc09fd39c6daadd01556d3c21bda3fc
4
+ data.tar.gz: 041905f84ab2ad5a16fc447727cd72cfef2969cb
5
5
  SHA512:
6
- metadata.gz: 190e2b4d886db70c1828db6cc7ae4ebe88bd32ed28d620b1d5057840ae2f9680aa4d8a0c14b31637a5bb5e239bef72e91be4fa89c0e72120caa885e7eaf55da4
7
- data.tar.gz: 35c1ad006d4fc3c59619395ada5e2387f3093000042c2d7c7abeba1572ad94fe99e3a3fac9caac98ea22b6041f46035f6314a014585b3397363d2ed4336e7e37
6
+ metadata.gz: ee6611329de0bd06e9ac8cf39e87b0e4cb86da11702aff2ff26e97c2279f49468bf164c3470bb16337dc6e58cbe25860611d5b58edf1c2068db8c91d4cd8065f
7
+ data.tar.gz: 2cdab44ec04e7ae5fd335cd2235d691e27e2ed92e4c977bb1cd385f74d04f448fd93cc734b5a859eae32c3e86763aba4604b5e5cef24533635cd3a6247af6eda
data/README.md CHANGED
@@ -28,16 +28,25 @@ The gem itself contains guards to only perform changes when the environment is `
28
28
  - [rack/handler.rb](/lib/local-subdomain/rack/handler.rb#L18)
29
29
  - [filters/local_subdomain.rb](/lib/local-subdomain/filters/local_subdomain.rb#L9)
30
30
 
31
+ ## Configuration (optional)
32
+
33
+ By default the gem uses the domain `lvh.me` with the port used, when running the rails server, but it is also possible to provide a custom redirect domain and port using the following `ENV` variables:
34
+
35
+ | ENV | Notes |EXAMPLE |
36
+ | :------------------------| :--------------------------------|-------------- |
37
+ | `SERVER_REDIRECT_PORT` | The port number to redirect to | 5000 |
38
+ | `SERVER_REDIRECT_DOMAIN` | The domain to redirect to | my.domain.tld |
39
+
31
40
  ## What it does
32
41
 
33
42
  Basically it does two things:
34
43
 
35
44
  1. Extends the `Rack::Handler` to make sure we bind to `0.0.0.0` instead of `localhost`
36
- 2. Adds the `LocalSubdomain` module which executes a `before_filter` to redirect to `http://lvh.me:<port>`
45
+ 2. Adds the `LocalSubdomain` module which executes a `before_filter` to redirect to `http://lvh.me:<port>` (or the configured redirect domain and port)
37
46
 
38
47
  ### Rack::Handler
39
48
 
40
- This gem uses the domain [http://lvh.me](http://lvh.me) to handle our requests for our subdomain(s). Request to the domain redirects all to `127.0.0.1`.
49
+ By default, this gem uses the domain [http://lvh.me](http://lvh.me) to handle our requests for our subdomain(s). Request to the domain `lvh.me` redirects all requests to `127.0.0.1`.
41
50
  This give's us the ability to browse to [http://subsub.lvh.me:3000](http://subsublvh.me:3000) and be handle `request.subdomain` from our controllers.
42
51
 
43
52
  Because we're going to use the external domain [http://lvh.me](http://lvh.me) which redirects to `127.0.0.1` we have to make our server not to bind to `localhost` only.
@@ -7,12 +7,15 @@ module LocalSubdomain
7
7
 
8
8
  def redirect_to_lvh_me
9
9
  return unless Rails.env.development?
10
- served_by_lvh_me = !request.env['SERVER_NAME'][/lvh.me$/].nil?
10
+
11
+ redirect_domain = ENV['SERVER_REDIRECT_DOMAIN'] || 'lvh.me'
12
+
13
+ served_by_lvh_me = !request.env['SERVER_NAME'][/#{redirect_domain}$/].nil?
11
14
  return if served_by_lvh_me
12
15
 
13
16
  http = request.env['rack.url_scheme']
14
- port = request.env['SERVER_PORT']
17
+ port = ENV['SERVER_REDIRECT_PORT'] || request.env['SERVER_PORT']
15
18
  path = request.env['ORIGINAL_FULLPATH']
16
- redirect_to "#{http}://lvh.me:#{port}#{path}"
19
+ redirect_to "#{http}://#{redirect_domain}#{port == '80' ? '' : ':' + port}#{path}"
17
20
  end
18
21
  end
@@ -1,3 +1,3 @@
1
1
  module LocalSubdomain
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local-subdomain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel van Rijn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.4.5
80
+ rubygems_version: 2.5.1
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: subdomain support in your development environment