contrails 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -38,7 +38,7 @@ spec = Gem::Specification.new do |s|
38
38
 
39
39
  # Change these as appropriate
40
40
  s.name = "contrails"
41
- s.version = "0.1.0"
41
+ s.version = "0.2.0"
42
42
  s.summary = "Declarative concurrency for EventMachine"
43
43
  s.author = "Tim Cowlishaw"
44
44
  s.email = "tim@timcowlishaw.co.uk"
@@ -1,16 +1,32 @@
1
+ require 'em/deferrable'
2
+ autoload "Parallel", 'contrails/parallel'
3
+ autoload "Process", 'contrails/process'
1
4
  module Contrails
2
5
  module Chainable
3
6
 
7
+ module ClassMethods
8
+ def return(&b)
9
+ self.new(&b)
10
+ end
11
+ end
12
+
13
+ def self.included(base)
14
+ base.extend(ClassMethods)
15
+ base.send(:include, EventMachine::Deferrable)
16
+ end
17
+
4
18
  def bind(other)
5
- raise NotImplementedError
19
+ p = Process.new(&self)
20
+ p.callback(&other)
21
+ return p
6
22
  end
7
23
 
8
24
  def distribute(other)
9
- raise NotImplementedError
25
+ Parallel.new(self, other)
10
26
  end
11
27
 
12
28
  def call(*a)
13
- raise NotImplementedError
29
+ self.succeed(*run(*a))
14
30
  end
15
31
 
16
32
  def to_proc
@@ -24,7 +40,7 @@ module Contrails
24
40
  def *(other)
25
41
  self.distribute(other)
26
42
  end
27
-
43
+
28
44
  end
29
45
  end
30
46
 
@@ -1,9 +1,8 @@
1
- require 'em/deferrable'
2
- require 'contrails/chainable'
3
1
  require 'contrails/semaphore'
2
+ autoload "Chainable", 'contrails/chainable'
4
3
  module Contrails
5
4
  class Parallel
6
- include EventMachine::Deferrable
5
+
7
6
  include Contrails::Chainable
8
7
  def initialize(*procs)
9
8
  results = []
@@ -1,32 +1,14 @@
1
- require 'em/deferrable'
2
- require 'contrails/parallel'
1
+ autoload "Chainable", "contrails/chainable"
3
2
  module Contrails
4
- class Process
5
- include EventMachine::Deferrable
6
- include Contrails::Chainable
7
-
8
- class << self
9
- def return(&b)
10
- self.new(&b)
11
- end
12
- end
3
+ class Process
4
+ include Chainable
13
5
 
14
6
  def initialize(&l)
15
7
  @lambda = l
16
8
  end
17
9
 
18
- def bind(other)
19
- p = Contrails::Process.new(&self)
20
- p.callback(&other)
21
- return p
22
- end
23
-
24
- def distribute(other)
25
- Contrails::Parallel.new(self, other)
26
- end
27
-
28
- def call(*a)
29
- self.succeed(*@lambda.call(*a))
10
+ def run(*a)
11
+ @lambda.call(*a)
30
12
  end
31
13
  end
32
14
  end
data/lib/contrails.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  $: << File.join(File.dirname(__FILE__))
2
2
  module Contrails
3
3
  end
4
+ require "contrails/chainable"
5
+ require 'ruby-debug'
4
6
  require "contrails/process"
7
+ require "contrails/parallel"
5
8
  require "contrails/utils"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: contrails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Cowlishaw
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-19 00:00:00 +01:00
13
+ date: 2011-08-22 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- hash: -1260005474418307725
76
+ hash: -1600641507598680959
77
77
  segments:
78
78
  - 0
79
79
  version: "0"