eventmachine-win32 0.7.0 → 0.7.2

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.
@@ -1,34 +1,23 @@
1
- # $Id: eventmachine_version.rb 221 2006-08-07 13:17:51Z blackhedd $
1
+ # $Id: eventmachine_version.rb 324 2007-05-22 22:43:35Z blackhedd $
2
2
  #
3
- # Author:: blackhedd (gmail address: garbagecat10).
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
4
5
  # Date:: 8 Apr 2006
5
6
  #
6
- # Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
7
- #
8
- # This program is made available under the terms of the GPL version 2.
9
- #
10
7
  # See EventMachine and EventMachine::Connection for documentation and
11
8
  # usage examples.
12
9
  #
13
10
  #----------------------------------------------------------------------------
14
11
  #
15
- # Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
16
- #
17
- # Gmail: garbagecat10
18
- #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
19
15
  # This program is free software; you can redistribute it and/or modify
20
- # it under the terms of the GNU General Public License as published by
21
- # the Free Software Foundation; either version 2 of the License, or
22
- # (at your option) any later version.
23
- #
24
- # This program is distributed in the hope that it will be useful,
25
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- # GNU General Public License for more details.
28
- #
29
- # You should have received a copy of the GNU General Public License
30
- # along with this program; if not, write to the Free Software
31
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
32
21
  #
33
22
  #---------------------------------------------------------------------------
34
23
  #
@@ -36,7 +25,7 @@
36
25
 
37
26
  module EventMachine
38
27
 
39
- VERSION = "0.7.0"
28
+ VERSION = "0.7.2"
40
29
 
41
30
  end
42
31
 
@@ -1,27 +1,24 @@
1
- # $Id: evma.rb 88 2006-05-19 03:42:54Z blackhedd $
1
+ # $Id: evma.rb 319 2007-05-22 22:11:18Z blackhedd $
2
2
  #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
3
4
  # Homepage:: http://rubyeventmachine.com
4
- # Copyright:: (C) 2006 by Francis Cianfrocca. All Rights Reserved.
5
- # Email:: gmail address: garbagecat10
5
+ # Date:: 8 Apr 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
6
9
  #
7
- # Available under the GNU Lesser General Public License.
8
- # See the file COPYING in the distribution for full licensing information.
9
- #-------------------------------------------------------------------
10
- # This file is part of Ruby/EventMachine.
10
+ #----------------------------------------------------------------------------
11
11
  #
12
- # Ruby/EventMachine is free software; you can redistribute it and/or modify
13
- # it under the terms of the GNU Lesser General Public License as published by
14
- # the Free Software Foundation; either version 2.1 of the License, or
15
- # (at your option) any later version.
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
16
14
  #
17
- # Ruby/EventMachine is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- # GNU Lesser General Public License for more details.
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
21
19
  #
22
- # You should have received a copy of the GNU Lesser General Public License
23
- # along with Ruby/EventMachine; if not, write to the Free Software
24
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
+ # See the file COPYING for complete licensing information.
21
+ #
25
22
  #-------------------------------------------------------------------
26
23
  #
27
24
 
@@ -1,28 +1,25 @@
1
- # $Id: callback.rb 88 2006-05-19 03:42:54Z blackhedd $
1
+ # $Id: callback.rb 321 2007-05-22 22:15:04Z blackhedd $
2
2
  #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
3
4
  # Homepage:: http://rubyeventmachine.com
4
- # Copyright:: (C) 2006 by Francis Cianfrocca. All Rights Reserved.
5
- # Email:: gmail address: garbagecat10
5
+ # Date:: 19 May 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
6
9
  #
7
- # Available under the GNU Lesser General Public License.
8
- # See the file COPYING in the distribution for full licensing information.
9
- #-------------------------------------------------------------------
10
- # This file is part of Ruby/EventMachine.
10
+ #----------------------------------------------------------------------------
11
11
  #
12
- # Ruby/EventMachine is free software; you can redistribute it and/or modify
13
- # it under the terms of the GNU Lesser General Public License as published by
14
- # the Free Software Foundation; either version 2.1 of the License, or
15
- # (at your option) any later version.
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
16
14
  #
17
- # Ruby/EventMachine is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- # GNU Lesser General Public License for more details.
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
21
19
  #
22
- # You should have received a copy of the GNU Lesser General Public License
23
- # along with Ruby/EventMachine; if not, write to the Free Software
24
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
- #-------------------------------------------------------------------
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
26
23
  #
27
24
 
28
25
 
@@ -1,31 +1,29 @@
1
- # $Id: container.rb 90 2006-05-19 04:58:15Z blackhedd $
1
+ # $Id: container.rb 321 2007-05-22 22:15:04Z blackhedd $
2
2
  #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
3
4
  # Homepage:: http://rubyeventmachine.com
4
- # Copyright:: (C) 2006 by Francis Cianfrocca. All Rights Reserved.
5
- # Email:: gmail address: garbagecat10
5
+ # Date:: 19 May 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
6
9
  #
7
- # Available under the GNU Lesser General Public License.
8
- # See the file COPYING in the distribution for full licensing information.
9
- #-------------------------------------------------------------------
10
- # This file is part of Ruby/EventMachine.
10
+ #----------------------------------------------------------------------------
11
11
  #
12
- # Ruby/EventMachine is free software; you can redistribute it and/or modify
13
- # it under the terms of the GNU Lesser General Public License as published by
14
- # the Free Software Foundation; either version 2.1 of the License, or
15
- # (at your option) any later version.
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
16
14
  #
17
- # Ruby/EventMachine is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- # GNU Lesser General Public License for more details.
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
21
19
  #
22
- # You should have received a copy of the GNU Lesser General Public License
23
- # along with Ruby/EventMachine; if not, write to the Free Software
24
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
- #-------------------------------------------------------------------
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
26
23
  #
27
24
 
28
25
 
26
+
29
27
  require 'singleton'
30
28
 
31
29
  module Evma
@@ -1,28 +1,25 @@
1
- # $Id: factory.rb 90 2006-05-19 04:58:15Z blackhedd $
1
+ # $Id: factory.rb 321 2007-05-22 22:15:04Z blackhedd $
2
2
  #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
3
4
  # Homepage:: http://rubyeventmachine.com
4
- # Copyright:: (C) 2006 by Francis Cianfrocca. All Rights Reserved.
5
- # Email:: gmail address: garbagecat10
5
+ # Date:: 19 May 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
6
9
  #
7
- # Available under the GNU Lesser General Public License.
8
- # See the file COPYING in the distribution for full licensing information.
9
- #-------------------------------------------------------------------
10
- # This file is part of Ruby/EventMachine.
10
+ #----------------------------------------------------------------------------
11
11
  #
12
- # Ruby/EventMachine is free software; you can redistribute it and/or modify
13
- # it under the terms of the GNU Lesser General Public License as published by
14
- # the Free Software Foundation; either version 2.1 of the License, or
15
- # (at your option) any later version.
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
16
14
  #
17
- # Ruby/EventMachine is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- # GNU Lesser General Public License for more details.
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
21
19
  #
22
- # You should have received a copy of the GNU Lesser General Public License
23
- # along with Ruby/EventMachine; if not, write to the Free Software
24
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
- #-------------------------------------------------------------------
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
26
23
  #
27
24
 
28
25
 
@@ -1,30 +1,28 @@
1
- # $Id: protocol.rb 90 2006-05-19 04:58:15Z blackhedd $
1
+ # $Id: protocol.rb 321 2007-05-22 22:15:04Z blackhedd $
2
2
  #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
3
4
  # Homepage:: http://rubyeventmachine.com
4
- # Copyright:: (C) 2006 by Francis Cianfrocca. All Rights Reserved.
5
- # Email:: gmail address: garbagecat10
5
+ # Date:: 19 May 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
6
9
  #
7
- # Available under the GNU Lesser General Public License.
8
- # See the file COPYING in the distribution for full licensing information.
9
- #-------------------------------------------------------------------
10
- # This file is part of Ruby/EventMachine.
10
+ #----------------------------------------------------------------------------
11
11
  #
12
- # Ruby/EventMachine is free software; you can redistribute it and/or modify
13
- # it under the terms of the GNU Lesser General Public License as published by
14
- # the Free Software Foundation; either version 2.1 of the License, or
15
- # (at your option) any later version.
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
16
14
  #
17
- # Ruby/EventMachine is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- # GNU Lesser General Public License for more details.
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
21
19
  #
22
- # You should have received a copy of the GNU Lesser General Public License
23
- # along with Ruby/EventMachine; if not, write to the Free Software
24
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
- #-------------------------------------------------------------------
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
26
23
  #
27
24
 
25
+
28
26
  module Evma
29
27
  class Protocol
30
28
 
@@ -1,31 +1,29 @@
1
- # $Id: reactor.rb 83 2006-05-18 21:36:31Z blackhedd $
1
+ # $Id: reactor.rb 321 2007-05-22 22:15:04Z blackhedd $
2
2
  #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
3
4
  # Homepage:: http://rubyeventmachine.com
4
- # Copyright:: (C) 2006 by Francis Cianfrocca. All Rights Reserved.
5
- # Email:: gmail address: garbagecat10
5
+ # Date:: 18 May 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
6
9
  #
7
- # Available under the GNU Lesser General Public License.
8
- # See the file COPYING in the distribution for full licensing information.
9
- #-------------------------------------------------------------------
10
- # This file is part of Ruby/EventMachine.
10
+ #----------------------------------------------------------------------------
11
11
  #
12
- # Ruby/EventMachine is free software; you can redistribute it and/or modify
13
- # it under the terms of the GNU Lesser General Public License as published by
14
- # the Free Software Foundation; either version 2.1 of the License, or
15
- # (at your option) any later version.
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
16
14
  #
17
- # Ruby/EventMachine is distributed in the hope that it will be useful,
18
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- # GNU Lesser General Public License for more details.
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
21
19
  #
22
- # You should have received a copy of the GNU Lesser General Public License
23
- # along with Ruby/EventMachine; if not, write to the Free Software
24
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
- #-------------------------------------------------------------------
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
26
23
  #
27
24
 
28
25
 
26
+
29
27
  require 'singleton'
30
28
 
31
29
  module Evma
@@ -1,36 +1,25 @@
1
- # $Id: pr_eventmachine.rb 264 2006-10-05 16:33:22Z blackhedd $
1
+ # $Id: pr_eventmachine.rb 319 2007-05-22 22:11:18Z blackhedd $
2
2
  #
3
- # Author:: blackhedd (gmail address: garbagecat10).
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
4
5
  # Date:: 8 Apr 2006
5
6
  #
6
- # Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
7
- #
8
- # This program is made available under the terms of the GPL version 2.
9
- #
10
7
  # See EventMachine and EventMachine::Connection for documentation and
11
8
  # usage examples.
12
9
  #
13
10
  #----------------------------------------------------------------------------
14
11
  #
15
- # Copyright (C) 2006 by Francis Cianfrocca. All Rights Reserved.
16
- #
17
- # Gmail: garbagecat10
18
- #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
19
15
  # This program is free software; you can redistribute it and/or modify
20
- # it under the terms of the GNU General Public License as published by
21
- # the Free Software Foundation; either version 2 of the License, or
22
- # (at your option) any later version.
23
- #
24
- # This program is distributed in the hope that it will be useful,
25
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- # GNU General Public License for more details.
28
- #
29
- # You should have received a copy of the GNU General Public License
30
- # along with this program; if not, write to the Free Software
31
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
32
21
  #
33
- #---------------------------------------------------------------------------
22
+ #-------------------------------------------------------------------
34
23
  #
35
24
  #
36
25
 
@@ -0,0 +1,121 @@
1
+ # BufferedTokenizer - Statefully split input data by a specifiable token
2
+ #
3
+ # Authors:: Tony Arcieri, Martin Emde
4
+ #
5
+ #----------------------------------------------------------------------------
6
+ #
7
+ # Copyright (C) 2006-07 by Tony Arcieri and Martin Emde
8
+ #
9
+ # Distributed under the Ruby license (http://www.ruby-lang.org/en/LICENSE.txt)
10
+ #
11
+ #---------------------------------------------------------------------------
12
+ #
13
+
14
+ # (C)2006 Tony Arcieri, Martin Emde
15
+ # Distributed under the Ruby license (http://www.ruby-lang.org/en/LICENSE.txt)
16
+
17
+ # BufferedTokenizer takes a delimiter upon instantiation, or acts line-based
18
+ # by default. It allows input to be spoon-fed from some outside source which
19
+ # receives arbitrary length datagrams which may-or-may-not contain the token
20
+ # by which entities are delimited.
21
+
22
+ class BufferedTokenizer
23
+ # New BufferedTokenizers will operate on lines delimited by "\n" by default
24
+ # or allow you to specify any delimiter token you so choose, which will then
25
+ # be used by String#split to tokenize the input data
26
+ def initialize(delimiter = "\n", size_limit = nil)
27
+ # Store the specified delimiter
28
+ @delimiter = delimiter
29
+
30
+ # Store the specified size limitation
31
+ @size_limit = size_limit
32
+
33
+ # The input buffer is stored as an array. This is by far the most efficient
34
+ # approach given language constraints (in C a linked list would be a more
35
+ # appropriate data structure). Segments of input data are stored in a list
36
+ # which is only joined when a token is reached, substantially reducing the
37
+ # number of objects required for the operation.
38
+ @input = []
39
+
40
+ # Size of the input buffer
41
+ @input_size = 0
42
+ end
43
+
44
+ # Extract takes an arbitrary string of input data and returns an array of
45
+ # tokenized entities, provided there were any available to extract. This
46
+ # makes for easy processing of datagrams using a pattern like:
47
+ #
48
+ # tokenizer.extract(data).map { |entity| Decode(entity) }.each do ...
49
+ def extract(data)
50
+ # Extract token-delimited entities from the input string with the split command.
51
+ # There's a bit of craftiness here with the -1 parameter. Normally split would
52
+ # behave no differently regardless of if the token lies at the very end of the
53
+ # input buffer or not (i.e. a literal edge case) Specifying -1 forces split to
54
+ # return "" in this case, meaning that the last entry in the list represents a
55
+ # new segment of data where the token has not been encountered
56
+ entities = data.split @delimiter, -1
57
+
58
+ # Check to see if the buffer has exceeded capacity, if we're imposing a limit
59
+ if @size_limit
60
+ raise 'input buffer full' if @input_size + entities.first.size > @size_limit
61
+ @input_size += entities.first.size
62
+ end
63
+
64
+ # Move the first entry in the resulting array into the input buffer. It represents
65
+ # the last segment of a token-delimited entity unless it's the only entry in the list.
66
+ @input << entities.shift
67
+
68
+ # If the resulting array from the split is empty, the token was not encountered
69
+ # (not even at the end of the buffer). Since we've encountered no token-delimited
70
+ # entities this go-around, return an empty array.
71
+ return [] if entities.empty?
72
+
73
+ # At this point, we've hit a token, or potentially multiple tokens. Now we can bring
74
+ # together all the data we've buffered from earlier calls without hitting a token,
75
+ # and add it to our list of discovered entities.
76
+ entities.unshift @input.join
77
+
78
+ # Multi-character token support.
79
+ # Split any tokens that were incomplete on the last iteration buf complete now.
80
+ entities.map! do |e|
81
+ e.split @delimiter, -1
82
+ end
83
+ # Flatten the resulting array. This has the side effect of removing the empty
84
+ # entry at the end that was produced by passing -1 to split. Add it again if
85
+ # necessary.
86
+ if (entities[-1] == [])
87
+ entities.flatten! << []
88
+ else
89
+ entities.flatten!
90
+ end
91
+
92
+ # Now that we've hit a token, joined the input buffer and added it to the entities
93
+ # list, we can go ahead and clear the input buffer. All of the segments that were
94
+ # stored before the join can now be garbage collected.
95
+ @input.clear
96
+
97
+ # The last entity in the list is not token delimited, however, thanks to the -1
98
+ # passed to split. It represents the beginning of a new list of as-yet-untokenized
99
+ # data, so we add it to the start of the list.
100
+ @input << entities.pop
101
+
102
+ # Set the new input buffer size, provided we're keeping track
103
+ @input_size = @input.first.size if @size_limit
104
+
105
+ # Now we're left with the list of extracted token-delimited entities we wanted
106
+ # in the first place. Hooray!
107
+ entities
108
+ end
109
+
110
+ # Flush the contents of the input buffer, i.e. return the input buffer even though
111
+ # a token has not yet been encountered
112
+ def flush
113
+ buffer = @input.join
114
+ @input.clear
115
+ buffer
116
+ end
117
+
118
+ def empty?
119
+ @input.empty?
120
+ end
121
+ end