Skip to content

Commit d7b41a9

Browse files
committed
Structrue files under m2r namespace.
Bring some sanity to LOAD_PATH. Alias M2R to Mongrel2 namespace for compatibility.
1 parent 6ad6b21 commit d7b41a9

File tree

7 files changed

+23
-26
lines changed

7 files changed

+23
-26
lines changed

lib/m2r.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
require 'connection'
2-
require 'request'
3-
require 'handler'
1+
require 'rubygems'
42

5-
module Mongrel2
3+
module M2R
64
end
5+
6+
Mongrel2 = M2R

lib/connection.rb renamed to lib/m2r/connection.rb

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
# On OSX:
2-
# sudo port install zmq
3-
# sudo gem install zmq
4-
# RUBY_ENGINE = 'ruby'
5-
require 'rubygems'
6-
gem 'ffi-rzmq'
7-
gem 'json'
1+
require 'm2r/request'
82
require 'ffi-rzmq'
93
require 'json'
104

11-
$: << File.dirname(__FILE__)
12-
require 'request'
13-
145
CTX = ZMQ::Context.new(1)
156

16-
module Mongrel2
7+
module M2R
178
# A Connection object manages the connection between your handler
189
# and a Mongrel2 server (or servers). It can receive raw requests
1910
# or JSON encoded requests whether from HTTP or MSG request types,
@@ -156,5 +147,5 @@ def http_response(body, code, headers)
156147
504 => 'Gateway Timeout',
157148
505 => 'HTTP Version Not Supported'
158149
}
159-
end # class Connection
160-
end # mod Mongrel2
150+
end
151+
end

lib/fiber_handler.rb renamed to lib/m2r/fiber_handler.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module Mongrel2
1+
require 'm2r/handler'
2+
3+
module M2R
24
class FiberHandler < Handler
35
def initialize(*args)
46
raise "This handler is just around for testing. don't use it, it'll suck."

lib/handler.rb renamed to lib/m2r/handler.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
module Mongrel2
1+
require 'm2r/connection'
2+
3+
module M2R
24
class Handler
35
attr_accessor :connection
46
def initialize(sender_uuid, subscribe_address, publish_address)
5-
@connection = Mongrel2::Connection.new(sender_uuid,
6-
subscribe_address, publish_address)
7+
@connection = M2R::Connection.new(sender_uuid,
8+
subscribe_address, publish_address)
79
end
810

911
# Callback for when the handler is waiting for a request

lib/request.rb renamed to lib/m2r/request.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
module Mongrel2
1+
require 'm2r'
2+
3+
module M2R
24
class Request
35
attr_reader :sender, :conn_id, :path, :headers, :body
46
def initialize(sender, conn_id, path, headers, body)
@@ -39,6 +41,6 @@ def disconnect?
3941
end
4042
alias :is_disconnect :disconnect?
4143

42-
end # class Request
43-
end # mod Mongrel2
44+
end
45+
end
4446

lib/m2r/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module Mongrel2
1+
module M2R
22
VERSION = '0.0.3'
33
end

m2r.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
1616
gem.name = "m2r"
1717
gem.date = "2010-10-23"
1818
gem.require_path = "lib"
19-
gem.version = Mongrel2::VERSION
19+
gem.version = M2R::VERSION
2020

2121
gem.add_dependency "ffi-rzmq", "~> 0.9.3"
2222
gem.add_dependency "ffi", ">= 1.0.0"

0 commit comments

Comments
 (0)