unicorn_use_special_port 0.0.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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +59 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +7 -0
- data/lib/unicorn_use_special_port.rb +6 -0
- data/lib/unicorn_use_special_port/action_dispatch_http_url.rb +26 -0
- data/lib/unicorn_use_special_port/base_config.rb +14 -0
- data/lib/unicorn_use_special_port/version.rb +3 -0
- data/spec/base_spec.rb +21 -0
- data/spec/spec_helper.rb +15 -0
- data/unicorn_use_special_port.gemspec +25 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3176e6260bed48382f6810331416bb00961c3a16
|
4
|
+
data.tar.gz: 850f5a19266bceced754e1a1fedc8bdc46b0d005
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1aff7ce9346038935ec18699f53a215aef730715ef35fd47979bcbe937ce955d1d56bce471209fe9e389de5d91a478a3a9313487ac69adc7bbf53fc2cf37e5a0
|
7
|
+
data.tar.gz: 2609fd68fa135ed5b33a18807431595788b16211c6f369047beea4f4abc45fcd2de8ea3a2ff5432abdbc5d885f903879798f7006270435d08fd867eb383351c9
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
coverage
|
8
|
+
doc
|
9
|
+
pkg
|
10
|
+
*.swp
|
11
|
+
*.patch
|
12
|
+
*.gem
|
13
|
+
*.sh
|
14
|
+
.DS_Store
|
15
|
+
.bundle/*
|
16
|
+
#Gemfile.lock
|
17
|
+
tmp/*
|
18
|
+
log/*
|
19
|
+
public/uploads/*
|
20
|
+
public/work_room/*
|
21
|
+
db/*.sqlite3
|
22
|
+
db/schema.rb
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://ruby.taobao.org/
|
3
|
+
specs:
|
4
|
+
actionpack (3.2.13)
|
5
|
+
activemodel (= 3.2.13)
|
6
|
+
activesupport (= 3.2.13)
|
7
|
+
builder (~> 3.0.0)
|
8
|
+
erubis (~> 2.7.0)
|
9
|
+
journey (~> 1.0.4)
|
10
|
+
rack (~> 1.4.5)
|
11
|
+
rack-cache (~> 1.2)
|
12
|
+
rack-test (~> 0.6.1)
|
13
|
+
sprockets (~> 2.2.1)
|
14
|
+
activemodel (3.2.13)
|
15
|
+
activesupport (= 3.2.13)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
activesupport (3.2.13)
|
18
|
+
i18n (= 0.6.1)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
builder (3.0.4)
|
21
|
+
diff-lcs (1.1.3)
|
22
|
+
erubis (2.7.0)
|
23
|
+
hike (1.2.3)
|
24
|
+
i18n (0.6.1)
|
25
|
+
journey (1.0.4)
|
26
|
+
metaclass (0.0.1)
|
27
|
+
mocha (0.10.0)
|
28
|
+
metaclass (~> 0.0.1)
|
29
|
+
multi_json (1.7.7)
|
30
|
+
rack (1.4.5)
|
31
|
+
rack-cache (1.2)
|
32
|
+
rack (>= 0.4)
|
33
|
+
rack-test (0.6.2)
|
34
|
+
rack (>= 1.0)
|
35
|
+
rake (10.1.0)
|
36
|
+
rspec (2.6.0)
|
37
|
+
rspec-core (~> 2.6.0)
|
38
|
+
rspec-expectations (~> 2.6.0)
|
39
|
+
rspec-mocks (~> 2.6.0)
|
40
|
+
rspec-core (2.6.4)
|
41
|
+
rspec-expectations (2.6.0)
|
42
|
+
diff-lcs (~> 1.1.2)
|
43
|
+
rspec-mocks (2.6.0)
|
44
|
+
sprockets (2.2.2)
|
45
|
+
hike (~> 1.2)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
rack (~> 1.0)
|
48
|
+
tilt (~> 1.1, != 1.3.0)
|
49
|
+
tilt (1.4.1)
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
ruby
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
actionpack (~> 3.2)
|
56
|
+
activesupport (~> 3.2)
|
57
|
+
mocha (= 0.10.0)
|
58
|
+
rake
|
59
|
+
rspec (~> 2.6.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Robot Jiang
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
## Description
|
2
|
+
|
3
|
+
If your rails app running on a special port(non-80 port) under Nginx + Unicorn.
|
4
|
+
then all redirect action in your rails app will be leaded to http 80 port, this may be not you want.
|
5
|
+
|
6
|
+
Or when you deploy rails use Nginx + Unicorn, but you want to use a special non-80 port (e.g. 8080, 3000, and so on).
|
7
|
+
|
8
|
+
To use this gem, to config a special port in your production.rb file, above all problems will be resolved.
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
group :production do
|
12
|
+
gem 'unicorn_use_special_port'
|
13
|
+
end
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install unicorn_use_special_port
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Add this lines to your config/environments/production.rb
|
26
|
+
|
27
|
+
UnicornUseSpecialPort::BaseConfig.setup do |config|
|
28
|
+
config[:port]= xxxx #use your custom port, e.g. : 8080
|
29
|
+
end
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
2
|
+
require 'active_support/core_ext/hash/slice'
|
3
|
+
|
4
|
+
module ActionDispatch
|
5
|
+
module Http
|
6
|
+
module URL
|
7
|
+
def port
|
8
|
+
@port ||= begin
|
9
|
+
if raw_host_with_port =~ /:(\d+)$/
|
10
|
+
$1.to_i
|
11
|
+
else
|
12
|
+
standard_port
|
13
|
+
end
|
14
|
+
end
|
15
|
+
if @port==80
|
16
|
+
special_config=UnicornUseSpecialPort::BaseConfig.config
|
17
|
+
if !special_config.empty? and (special_config[:port] or special_config['port'])
|
18
|
+
@port= (special_config[:port] || special_config['port']).to_i
|
19
|
+
end
|
20
|
+
end
|
21
|
+
@port
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe UnicornUseSpecialPort do
|
4
|
+
let(:env) do
|
5
|
+
env={}
|
6
|
+
env
|
7
|
+
end
|
8
|
+
before do
|
9
|
+
UnicornUseSpecialPort::BaseConfig.setup do |config|
|
10
|
+
config[:port]=8080
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
it "dose can return a special port when calling request port" do
|
15
|
+
request=ActionDispatch::Request.new(env)
|
16
|
+
request.port().should == 8080
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
|
6
|
+
require 'active_support'
|
7
|
+
require 'action_dispatch'
|
8
|
+
require "mocha"
|
9
|
+
require "unicorn_use_special_port"
|
10
|
+
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.mock_with :mocha
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'unicorn_use_special_port/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "unicorn_use_special_port"
|
8
|
+
spec.version = UnicornUseSpecialPort::VERSION
|
9
|
+
spec.authors = ["Robot Jiang"]
|
10
|
+
spec.email = ["robot.z.jiang@gmail.com"]
|
11
|
+
spec.description = %q{Let unicorn use a special port on production.}
|
12
|
+
spec.summary = %q{To use a special port when you deploy rails under Nginx+Unicorn.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.homepage =
|
21
|
+
'http://rubygems.org/gems/unicorn_use_special_port'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: unicorn_use_special_port
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robot Jiang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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
|
+
description: Let unicorn use a special port on production.
|
42
|
+
email:
|
43
|
+
- robot.z.jiang@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/unicorn_use_special_port.rb
|
55
|
+
- lib/unicorn_use_special_port/action_dispatch_http_url.rb
|
56
|
+
- lib/unicorn_use_special_port/base_config.rb
|
57
|
+
- lib/unicorn_use_special_port/version.rb
|
58
|
+
- spec/base_spec.rb
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
- unicorn_use_special_port.gemspec
|
61
|
+
homepage: http://rubygems.org/gems/unicorn_use_special_port
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.0
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: To use a special port when you deploy rails under Nginx+Unicorn.
|
85
|
+
test_files:
|
86
|
+
- spec/base_spec.rb
|
87
|
+
- spec/spec_helper.rb
|