cool.io 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,10 +4,10 @@
4
4
  # See file LICENSE for details
5
5
  #++
6
6
 
7
- require 'iobuffer'
8
-
9
7
  require "cool.io/version"
10
- require "cool.io_ext"
8
+ require "cool.io/custom_require"
9
+ cool_require "iobuffer_ext"
10
+ cool_require "cool.io_ext"
11
11
 
12
12
  require "cool.io/loop"
13
13
  require "cool.io/meta"
@@ -29,4 +29,4 @@ end
29
29
  module Cool
30
30
  # Allow Coolio module to be referenced as Cool.io
31
31
  def self.io; Coolio; end
32
- end
32
+ end
@@ -0,0 +1,9 @@
1
+ def cool_require(gem)
2
+ begin
3
+ m = /(\d+.\d+)/.match(RUBY_VERSION)
4
+ ver = m[1]
5
+ require "#{ver}/#{gem}.so"
6
+ rescue LoadError
7
+ require gem
8
+ end
9
+ end
@@ -32,15 +32,17 @@ module Coolio
32
32
  class DNSResolver < IOWatcher
33
33
  #--
34
34
  # TODO check if it's caching right
35
- RESOLV_CONF = '/etc/resolv.conf'
36
- HOSTS = '/etc/hosts'
35
+ if RUBY_PLATFORM =~ /mingw|win32/
36
+ HOSTS = 'c:\WINDOWS\system32\drivers\etc\hosts'
37
+ else
38
+ HOSTS = '/etc/hosts'
39
+ end
37
40
  DNS_PORT = 53
38
41
  DATAGRAM_SIZE = 512
39
42
  TIMEOUT = 3 # Retry timeout for each datagram sent
40
43
  RETRIES = 4 # Number of retries to attempt
41
44
  # so currently total is 12s before it will err due to timeouts
42
45
  # if it errs due to inability to reach the DNS server [Errno::EHOSTUNREACH], same
43
-
44
46
  # Query /etc/hosts (or the specified hostfile) for the given host
45
47
  def self.hosts(host, hostfile = HOSTS)
46
48
  hosts = {}
@@ -61,8 +63,9 @@ module Coolio
61
63
  # use nameservers listed in /etc/resolv.conf
62
64
  def initialize(hostname, *nameservers)
63
65
  if nameservers.empty?
64
- nameservers = File.read(RESOLV_CONF).scan(/^\s*nameserver\s+([0-9.:]+)/).flatten # TODO could optimize this to just read once
65
- raise RuntimeError, "no nameservers found in #{RESOLV_CONF}" if nameservers.empty? # TODO just call resolve_failed, not raise [also handle Errno::ENOENT)]
66
+ require 'resolv'
67
+ nameservers = Resolv::DNS::Config.default_config_hash[:nameserver]
68
+ raise RuntimeError, "no nameservers found" if nameservers.empty? # TODO just call resolve_failed, not raise [also handle Errno::ENOENT)]
66
69
  end
67
70
 
68
71
  @nameservers = nameservers
@@ -5,7 +5,8 @@
5
5
  # See file LICENSE for details
6
6
  #++
7
7
 
8
- require 'http11_client'
8
+ require "cool.io/custom_require"
9
+ cool_require 'http11_client'
9
10
 
10
11
  module Coolio
11
12
  # A simple hash is returned for each request made by HttpClient with
@@ -118,8 +119,8 @@ module Coolio
118
119
  # == Example
119
120
  #
120
121
  # loop = Coolio::Loop.default
121
- # client = Coolio::HttpClient.connect("www.google.com").attach
122
- # client.get('/search', query: {q: 'foobar'})
122
+ # client = Coolio::HttpClient.connect("www.google.com").attach(loop)
123
+ # client.request('GET', '/search', query: {q: 'foobar'})
123
124
  # loop.run
124
125
  #
125
126
  class HttpClient < TCPSocket
@@ -21,10 +21,6 @@ module Coolio
21
21
  @listen_socket.fileno
22
22
  end
23
23
 
24
- def listen(backlog)
25
- @listen_socket.listen(backlog)
26
- end
27
-
28
24
  # Close the listener
29
25
  def close
30
26
  detach if attached?
@@ -57,9 +53,9 @@ module Coolio
57
53
  end
58
54
  end
59
55
 
60
- DEFAULT_BACKLOG = 1024
61
-
62
56
  class TCPListener < Listener
57
+ DEFAULT_BACKLOG = 1024
58
+
63
59
  # Create a new Coolio::TCPListener on the specified address and port.
64
60
  # Accepts the following options:
65
61
  #
@@ -91,9 +87,7 @@ module Coolio
91
87
  # Optionally, it can also take anyn existing UNIXServer object
92
88
  # and create a Coolio::UNIXListener out of it.
93
89
  def initialize(*args)
94
- s = ::UNIXServer === args.first ? args.first : ::UNIXServer.new(*args)
95
- s.instance_eval { listen(DEFAULT_BACKLOG) }
96
- super(s)
90
+ super(::UNIXServer === args.first ? args.first : ::UNIXServer.new(*args))
97
91
  end
98
92
  end
99
93
  end
@@ -56,7 +56,7 @@ module Coolio
56
56
  raise ArgumentError, "port must be an integer" if nil == port
57
57
  ::TCPServer.new(host, port)
58
58
  end
59
- listen_socket.instance_eval { listen(DEFAULT_BACKLOG) } # Change listen backlog to 1024
59
+ listen_socket.instance_eval { listen(1024) } # Change listen backlog to 1024
60
60
  super(listen_socket, klass, *args, &block)
61
61
  end
62
62
  end
@@ -68,7 +68,6 @@ module Coolio
68
68
  class UNIXServer < Server
69
69
  def initialize(path, klass = UNIXSocket, *args, &block)
70
70
  s = ::UNIXServer === path ? path : ::UNIXServer.new(path)
71
- s.instance_eval { listen(DEFAULT_BACKLOG) }
72
71
  super(s, klass, *args, &block)
73
72
  end
74
73
  end
@@ -1,5 +1,5 @@
1
1
  module Coolio
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
 
4
4
  def self.version; VERSION; end
5
5
  end
@@ -2,7 +2,7 @@ require File.expand_path('../spec_helper', __FILE__)
2
2
  require 'tempfile'
3
3
  require 'fcntl'
4
4
 
5
- describe Cool.io::AsyncWatcher do
5
+ describe Cool.io::AsyncWatcher, :env => :win do
6
6
 
7
7
  it "does not signal on spurious wakeups" do
8
8
  aw = Cool.io::AsyncWatcher.new
@@ -2,4 +2,11 @@ $LOAD_PATH.unshift File.dirname(__FILE__)
2
2
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
 
4
4
  require 'rspec'
5
- require 'cool.io'
5
+ require 'cool.io'
6
+
7
+ RSpec.configure do |c|
8
+ if RUBY_PLATFORM =~ /mingw|win32/
9
+ $stderr.puts "Skip some specs on Windows"
10
+ c.filter_run_excluding :env => :win
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../spec_helper', __FILE__)
2
2
  require 'tempfile'
3
3
 
4
- describe Cool.io::UNIXListener do
4
+ describe Cool.io::UNIXListener, :env => :win do
5
5
 
6
6
  before :each do
7
7
  @tmp = Tempfile.new('coolio_unix_listener_spec')
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../spec_helper', __FILE__)
2
2
  require 'tempfile'
3
3
 
4
- describe Cool.io::UNIXServer do
4
+ describe Cool.io::UNIXServer, :env => :win do
5
5
 
6
6
  before :each do
7
7
  @tmp = Tempfile.new('coolio_unix_server_spec')
@@ -11,15 +11,13 @@ describe Cool.io::UNIXServer do
11
11
 
12
12
  it "creates a new Cool.io::UNIXServer" do
13
13
  listener = Cool.io::UNIXListener.new(@tmp.path)
14
- listener.listen(24)
15
14
  File.socket?(@tmp.path).should == true
16
15
  end
17
16
 
18
17
  it "builds off an existing ::UNIXServer" do
19
18
  unix_server = ::UNIXServer.new(@tmp.path)
20
19
  File.socket?(@tmp.path).should == true
21
- listener = Cool.io::UNIXServer.new(unix_server, Coolio::UNIXSocket)
22
- listener.listen(24)
20
+ listener = Cool.io::UNIXServer.new(unix_server)
23
21
  File.socket?(@tmp.path).should == true
24
22
  listener.fileno.should == unix_server.fileno
25
23
  end
metadata CHANGED
@@ -1,79 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cool.io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Tony Arcieri
9
+ - Masahiro Nakagawa
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2013-07-30 00:00:00.000000000 Z
13
+ date: 2013-05-27 00:00:00.000000000 Z
12
14
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: iobuffer
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: 1.0.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: 1.0.0
27
15
  - !ruby/object:Gem::Dependency
28
16
  name: rake-compiler
29
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
30
19
  requirements:
31
20
  - - ~>
32
21
  - !ruby/object:Gem::Version
33
- version: 0.7.9
22
+ version: 0.8.3
34
23
  type: :development
35
24
  prerelease: false
36
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
37
27
  requirements:
38
28
  - - ~>
39
29
  - !ruby/object:Gem::Version
40
- version: 0.7.9
30
+ version: 0.8.3
41
31
  - !ruby/object:Gem::Dependency
42
32
  name: rspec
43
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
44
35
  requirements:
45
- - - '>='
36
+ - - ! '>='
46
37
  - !ruby/object:Gem::Version
47
- version: 2.6.0
38
+ version: 2.13.0
48
39
  type: :development
49
40
  prerelease: false
50
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
51
43
  requirements:
52
- - - '>='
44
+ - - ! '>='
53
45
  - !ruby/object:Gem::Version
54
- version: 2.6.0
46
+ version: 2.13.0
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: rdoc
57
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
58
51
  requirements:
59
- - - '>='
52
+ - - ! '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 3.6.0
62
55
  type: :development
63
56
  prerelease: false
64
57
  version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
65
59
  requirements:
66
- - - '>='
60
+ - - ! '>='
67
61
  - !ruby/object:Gem::Version
68
62
  version: 3.6.0
69
63
  description: Cool.io provides a high performance event framework for Ruby which uses
70
64
  the libev C library
71
65
  email:
72
66
  - tony.arcieri@gmail.com
67
+ - repeatedly@gmail.com
73
68
  executables: []
74
69
  extensions:
75
70
  - ext/cool.io/extconf.rb
76
71
  - ext/http11_client/extconf.rb
72
+ - ext/iobuffer/extconf.rb
77
73
  extra_rdoc_files: []
78
74
  files:
79
75
  - .gitignore
@@ -112,6 +108,8 @@ files:
112
108
  - ext/http11_client/http11_parser.c
113
109
  - ext/http11_client/http11_parser.h
114
110
  - ext/http11_client/http11_parser.rl
111
+ - ext/iobuffer/extconf.rb
112
+ - ext/iobuffer/iobuffer.c
115
113
  - ext/libev/Changes
116
114
  - ext/libev/LICENSE
117
115
  - ext/libev/README
@@ -130,6 +128,7 @@ files:
130
128
  - lib/.gitignore
131
129
  - lib/cool.io.rb
132
130
  - lib/cool.io/async_watcher.rb
131
+ - lib/cool.io/custom_require.rb
133
132
  - lib/cool.io/dns_resolver.rb
134
133
  - lib/cool.io/dsl.rb
135
134
  - lib/cool.io/eventmachine.rb
@@ -153,26 +152,33 @@ files:
153
152
  - spec/unix_server_spec.rb
154
153
  homepage: http://coolio.github.com
155
154
  licenses: []
156
- metadata: {}
157
155
  post_install_message:
158
156
  rdoc_options: []
159
157
  require_paths:
160
158
  - lib
161
159
  required_ruby_version: !ruby/object:Gem::Requirement
160
+ none: false
162
161
  requirements:
163
- - - '>='
162
+ - - ! '>='
164
163
  - !ruby/object:Gem::Version
165
164
  version: '0'
165
+ segments:
166
+ - 0
167
+ hash: 3111666693494633054
166
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
+ none: false
167
170
  requirements:
168
- - - '>='
171
+ - - ! '>='
169
172
  - !ruby/object:Gem::Version
170
173
  version: '0'
174
+ segments:
175
+ - 0
176
+ hash: 3111666693494633054
171
177
  requirements: []
172
178
  rubyforge_project:
173
- rubygems_version: 2.0.2
179
+ rubygems_version: 1.8.23
174
180
  signing_key:
175
- specification_version: 4
181
+ specification_version: 3
176
182
  summary: A cool framework for doing high performance I/O in Ruby
177
183
  test_files:
178
184
  - spec/async_watcher_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 574129faba4be1f5f42244622d7c1ecc94349bd9
4
- data.tar.gz: cf189c4d87b89133afd04a29c4a5e078244d648b
5
- SHA512:
6
- metadata.gz: 037beb60fd9b659e1986885947cc74a77e57004d788dcfd6ac07df4a6196dcd9f784c9a2031759f2bd9b23a667a9f56e4f564b1572b52a9a0549973ecc7df778
7
- data.tar.gz: a07fd3da19d0c7fddad53c93c8f4942e5562f1562c5a8a0c323c078dc493004db7bb38f131fe9ca0d70c6d1eee7dd873111088eeaa4e41bbe3701fde780f2090