mojombo-proxymachine 0.1.3 → 0.2.0

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.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 1
4
- :patch: 3
3
+ :minor: 2
4
+ :patch: 0
data/examples/git.rb CHANGED
@@ -19,8 +19,8 @@ end
19
19
  proxy do |data|
20
20
  if data =~ %r{^....git-upload-pack /([\w\.\-]+)/[\w\.\-]+\000host=(.+)\000}
21
21
  name, host = $1, $2
22
- GitRouter.lookup(name)
22
+ { :remote => GitRouter.lookup(name) }
23
23
  else
24
- :noop
24
+ { :noop => true }
25
25
  end
26
26
  end
@@ -1,4 +1,4 @@
1
1
  proxy do |data|
2
2
  # p data
3
- "localhost:80"
3
+ { :remote => "google.com:80" }
4
4
  end
@@ -28,16 +28,24 @@ module EventMachine
28
28
  def ensure_server_side_connection
29
29
  @timer.cancel if @timer
30
30
  unless @server_side
31
- op = ProxyMachine.router.call(@buffer.join)
32
- if op.instance_of?(String)
33
- m, host, port = *op.match(/^(.+):(.+)$/)
31
+ commands = ProxyMachine.router.call(@buffer.join)
32
+ close_connection unless commands.instance_of?(Hash)
33
+ if remote = commands[:remote]
34
+ m, host, port = *remote.match(/^(.+):(.+)$/)
34
35
  if try_server_connect(host, port.to_i)
36
+ if data = commands[:data]
37
+ @buffer = [data]
38
+ end
35
39
  send_and_clear_buffer
36
40
  end
37
- elsif op.instance_of?(Hash) && op[:close]
38
- send_data(op[:close])
39
- close_connection_after_writing
40
- elsif op == :noop
41
+ elsif close = commands[:close]
42
+ if close == true
43
+ close_connection
44
+ else
45
+ send_data(close)
46
+ close_connection_after_writing
47
+ end
48
+ elsif commands[:noop]
41
49
  # do nothing
42
50
  else
43
51
  close_connection
@@ -68,7 +76,6 @@ module EventMachine
68
76
  def send_and_clear_buffer
69
77
  if !@buffer.empty?
70
78
  @buffer.each do |x|
71
- # p x
72
79
  @server_side.send_data(x)
73
80
  end
74
81
  @buffer = []
data/proxymachine.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{proxymachine}
5
- s.version = "0.1.3"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Tom Preston-Werner"]
9
- s.date = %q{2009-05-27}
9
+ s.date = %q{2009-07-15}
10
10
  s.default_executable = %q{proxymachine}
11
11
  s.email = %q{tom@mojombo.com}
12
12
  s.executables = ["proxymachine"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mojombo-proxymachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-27 00:00:00 -07:00
12
+ date: 2009-07-15 00:00:00 -07:00
13
13
  default_executable: proxymachine
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency