ione 1.0.0.pre0 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d01e0e0185b664af4fe4770c988a2560388ab05b
4
- data.tar.gz: ce1e35186cc20d8732d0cecb1698720d2f3fb73b
3
+ metadata.gz: 5daae8dfb48089c7dbff04dfc53bb454b5153e5d
4
+ data.tar.gz: 770290ce9dd80b0633d21a5674ae6e497a6e5e9c
5
5
  SHA512:
6
- metadata.gz: 2a147567529615c86aefe2e2e6cfb5e0e0c57d99efef0bfedd02b4b91dd7acc611d98c98dd694a8ce2c6d657431134b14b7125b1a17bac97598aa560dda8026a
7
- data.tar.gz: 92bf693d6bba06dd05e6434484f50802a780819db5b3f1a23c5ed02a30bc183362e1fbe7aeda581adc1223e32084fba11a24a9e7a2decb547e9122e441bd0e2d
6
+ metadata.gz: 7dce6e221b06510f9551a00df5461bd179500f51c3332b55fb6530f7385ca87fe9f8db2fdaeea516b1534400aa1f5701435abc20aa34ca46287476beb9dbb8c9
7
+ data.tar.gz: e341558ccaf6cbafc59846793d542eb162726927f3499acd6ad950fbd4a40d3e99a69455d501cbae07997b18ed474913f7612dda6e70bdfdcb145244ecfc72bd
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Ione
2
+
3
+ [![Build Status](https://travis-ci.org/iconara/ione.png?branch=master)](https://travis-ci.org/iconara/ione)
4
+ [![Blog](http://b.repl.ca/v1/blog-ione-ff69b4.png)](http://architecturalatrocities.com/tagged/ione)
5
+
6
+ _If you're reading this on GitHub, please note that this is the readme for the development version and that some features described here might not yet have been released. You can find the readme for a specific version either through [rubydoc.info](http://rubydoc.info/find/gems?q=ione) or via the release tags ([here is an example](https://github.com/iconara/ione/tree/v1.0.0.pre0))._
7
+
8
+ Ione is a framework for reactive programming in Ruby. It is based on the reactive core of [cql-rb](http://github.com/iconara/cql-rb), the Ruby driver for Cassandra.
9
+
10
+ # How to contribute
11
+
12
+ [See CONTRIBUTING.md](CONTRIBUTING.md)
13
+
14
+ # Copyright
15
+
16
+ Copyright 2013–2014 Theo Hultberg/Iconara and contributors.
17
+
18
+ _Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License You may obtain a copy of the License at_
19
+
20
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
21
+
22
+ _Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License._
@@ -158,13 +158,16 @@ module Ione
158
158
  # @param port [Integer] the port to connect to
159
159
  # @param timeout [Numeric] the number of seconds to wait for a connection
160
160
  # before failing
161
- # @return [Ione::Future] a future that will resolve to the connection when
162
- # when it has finished connecting.
163
- def connect(host, port, timeout)
161
+ # @yieldparam [Ione::Io::Connection] connection the newly opened connection
162
+ # @return [Ione::Future] a future that will resolve when the connection is
163
+ # open. The value will be the connection, or when a block is given to
164
+ # what the block returns
165
+ def connect(host, port, timeout, &block)
164
166
  connection = Connection.new(host, port, timeout, @unblocker, @clock)
165
167
  f = connection.connect
166
168
  @io_loop.add_socket(connection)
167
169
  @unblocker.unblock!
170
+ f = f.map(&block) if block_given?
168
171
  f
169
172
  end
170
173
 
data/lib/ione/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Ione
4
- VERSION = '1.0.0.pre0'.freeze
4
+ VERSION = '1.0.0.pre1'.freeze
5
5
  end
@@ -146,7 +146,19 @@ module Ione
146
146
  describe '#connect' do
147
147
  include_context 'running_reactor'
148
148
 
149
- it 'returns the connected connection when no block is given' do
149
+ it 'calls the given block with the connection and the reactor itself and returns what it returns' do
150
+ connection = nil
151
+ reactor.start.value
152
+ reactor.connect('example.com', 9999, 5) { |c| connection = c }.value
153
+ connection.should be_a(Connection)
154
+ end
155
+
156
+ it 'returns a future that resolves to what the given block returns' do
157
+ reactor.start.value
158
+ reactor.connect('example.com', 9999, 5) { :foo }.value.should == :foo
159
+ end
160
+
161
+ it 'returns the connection when no block is given' do
150
162
  reactor.start.value
151
163
  reactor.connect('example.com', 9999, 5).value.should be_a(Connection)
152
164
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ione
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre0
4
+ version: 1.0.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo Hultberg
@@ -19,6 +19,7 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - .yardopts
22
+ - README.md
22
23
  - lib/ione.rb
23
24
  - lib/ione/byte_buffer.rb
24
25
  - lib/ione/future.rb