SuburiMongrel 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 834f1c38a3f6b86f18a06f9a993fae2f4fbeee6e
4
+ data.tar.gz: 45d2855e1d357718327431cd75d332a413abe2cb
5
+ SHA512:
6
+ metadata.gz: ba58bb3c82ac7cd120995b3111ce42665e510f9b2895a3f1e366e86138b446f67aa170e12f973038930aee7b5aec0ff33f14d7f6e76401e3299016298fb1637f
7
+ data.tar.gz: fcc7f5c2f5a811540ee3254ff0634aa4e4f89025bad0f26c9b157049c54f4bfa7914cd4a6c20ae97aca703370586cd0f2fca92cc05c631ea2ddda524a54d5bb3
@@ -0,0 +1,42 @@
1
+ # This handler must be deploy (copy the .rb file) in Rack gem handlers directory (lib\rack\handler).
2
+ # For example, with Ruby + gem => Ruby\lib\ruby\gems\1.9.1\gems\rack-1.4.1\lib\rack\handler
3
+ module Rack
4
+ module Handler
5
+ class SuburiMongrel < Handler::Mongrel
6
+ def self.run(app, options={})
7
+ server = ::Mongrel::HttpServer.new(
8
+ options[:Host] || '0.0.0.0',
9
+ options[:Port] || 8080,
10
+ options[:num_processors] || 950,
11
+ options[:throttle] || 0,
12
+ options[:timeout] || 60)
13
+ # Acts like Rack::URLMap, utilizing Mongrel's own path finding methods.
14
+ # Use is similar to #run, replacing the app argument with a hash of
15
+ # { path=>app, ... } or an instance of Rack::URLMap.
16
+ if options[:map]
17
+ if app.is_a? Hash
18
+ app.each do |path, appl|
19
+ path = '/'+path unless path[0] == ?/
20
+ server.register(path, Rack::Handler::Mongrel.new(appl))
21
+ end
22
+ elsif app.is_a? URLMap
23
+ app.instance_variable_get(:@mapping).each do |(host, path, appl)|
24
+ next if !host.nil? && !options[:Host].nil? && options[:Host] != host
25
+ path = '/'+path unless path[0] == ?/
26
+ server.register(path, Rack::Handler::Mongrel.new(appl))
27
+ end
28
+ else
29
+ raise ArgumentError, "first argument should be a Hash or URLMap"
30
+ end
31
+ else
32
+ # TODO: what happens when ENV is not set properly? FAILS
33
+ path = '/'
34
+ path = ENV['RAILS_RELATIVE_URL_ROOT'] if ENV['RAILS_RELATIVE_URL_ROOT']
35
+ server.register(path, Rack::Handler::Mongrel.new(app))
36
+ end
37
+ yield server if block_given?
38
+ server.run.join
39
+ end
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: SuburiMongrel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dawuid
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ description: A simple rack handler to allow to use suburis without using --prefix
28
+ email:
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/rack/handler/suburi_mongrel.rb
34
+ homepage: http://github.com/Dawuid/SuburiMongrel-rack-handler
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.0.7
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Rack Handler to allow suburis in Mongrel
58
+ test_files: []
59
+ has_rdoc: