trenza 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Trenza
1
+ # Trenza [![Build Status](https://secure.travis-ci.org/porras/trenza.png?branch=master)](http://travis-ci.org/porras/trenza)
2
2
 
3
3
  Trenza is the spanish word for *braid* or *plait*.
4
4
 
@@ -6,13 +6,13 @@ Trenza is the spanish word for *braid* or *plait*.
6
6
 
7
7
  ![Trenza](http://dl.dropbox.com/u/521377/trenza_cinco.jpg)
8
8
 
9
- Trenza is also an experiment in dynamic programming inspired by the reading of Paolo Perrotta's *“Metaprogramming Ruby”* (an awesome book, by the way), and in evaluation models and strategies, inspired in my late adventures with Erlang and Haskell.
9
+ Trenza is also an experiment in dynamic programming inspired by the reading of [Paolo Perrotta](http://twitter.com/nusco)'s [*“Metaprogramming Ruby”*](http://pragprog.com/book/ppmetr/metaprogramming-ruby) (an awesome book, by the way), and in evaluation models and strategies, inspired in my late adventures with [Erlang](http://www.erlang.org/) and [Haskell](http://haskell.org/).
10
10
 
11
11
  Trenza provides two methods to every Ruby object: `lazy` and `parallel`. Those two methods return an object that behaves exactly the same way the old one, except that, instead or evaluating its methods right away when they're called, they do it in a *lazy* or *parallel* way.
12
12
 
13
13
  ## *Lazy* objects
14
14
 
15
- *Lazy* objects defer the actual evaluation of its methods until the moment its really needed:
15
+ *Lazy* objects defer the actual evaluation of its methods until the moment it's really needed:
16
16
 
17
17
  class Wadus
18
18
  def calculate
@@ -28,11 +28,11 @@ Trenza provides two methods to every Ruby object: `lazy` and `parallel`. Those t
28
28
  # no calculation is actually done
29
29
 
30
30
  puts x # now wadus1.calculate is run in order to print it
31
- # wadus2.calculate never gets run since its not needed
31
+ # wadus2.calculate never gets run since it's not needed
32
32
 
33
33
  ## *Parallel* objects
34
34
 
35
- *Parallel* objects are similar to *lazy* objects, but instead of deferring the whole evaluation of the method, they start it in the background and follow with your program. Whenever the actual return value is needed, then and only then will your program for the calculation to end (in case it hadn't ended already). This way your programs can become massively parallel without changing your programming style at all:
35
+ *Parallel* objects are similar to *lazy* objects, but instead of deferring the whole evaluation of the method, they start it in the background and follow with your program. Whenever the actual return value is needed, then and only then will your program wait for the calculation to end (in case it hadn't ended already). This way your programs can become massively parallel without changing your programming style at all:
36
36
 
37
37
  class Wadus
38
38
  def calculate
@@ -49,7 +49,7 @@ Trenza provides two methods to every Ruby object: `lazy` and `parallel`. Those t
49
49
  ...
50
50
 
51
51
  puts x + y # in case they hadn't finished already, now your program will wait for the
52
- # calculations to finished, since the return values are needed
52
+ # calculations to finish, since the return values are needed
53
53
 
54
54
  Please note that Trenza uses the underlying Ruby's `Thread` class implementation, so the actual kind of parallelism achieved depends greatly on the Ruby implementation you're using. Check Ruby 1.8, Ruby 1.9 and JRuby documentation for further details.
55
55
 
@@ -57,7 +57,7 @@ Please note that Trenza uses the underlying Ruby's `Thread` class implementation
57
57
 
58
58
  Trenza is an experiment and might not have any practical uses apart from that. But if you find one, let me know!
59
59
 
60
- As for me, scripts with lots of I/O waiting (such as scripts that download files) seem a natural fit for `parallel` (see `examples/download.rb` for an example).
60
+ As for me, scripts with lots of I/O waiting (such as scripts that download files) seem a natural fit for `parallel` (see [`examples/downloads.rb`](https://github.com/porras/trenza/blob/master/examples/downloads.rb) for an example).
61
61
 
62
62
  ## Usage
63
63
 
data/lib/trenza/lazy.rb CHANGED
@@ -24,7 +24,7 @@ module Trenza
24
24
  end
25
25
 
26
26
  def value
27
- @value ||= @block.call
27
+ @value ||= @block.call.lazy
28
28
  end
29
29
  end
30
30
  end
@@ -20,7 +20,7 @@ module Trenza
20
20
  end
21
21
 
22
22
  def method_missing(meth, *args, &blk)
23
- @thread.value.send(meth, *args, &blk)
23
+ @thread.value.send(meth, *args, &blk).parallel
24
24
  end
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,22 +1,32 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: trenza
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Sergio Gil
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-03-09 00:00:00.000000000 Z
17
+
18
+ date: 2012-03-12 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description:
15
22
  email: sgilperez@gmail.com
16
23
  executables: []
24
+
17
25
  extensions: []
26
+
18
27
  extra_rdoc_files: []
19
- files:
28
+
29
+ files:
20
30
  - README.md
21
31
  - lib/trenza/blank_slate.rb
22
32
  - lib/trenza/lazy.rb
@@ -27,26 +37,37 @@ files:
27
37
  - examples/slow_calculator.rb
28
38
  homepage: http://github.com/porras/trenza
29
39
  licenses: []
40
+
30
41
  post_install_message:
31
42
  rdoc_options: []
32
- require_paths:
43
+
44
+ require_paths:
33
45
  - lib
34
- required_ruby_version: !ruby/object:Gem::Requirement
46
+ required_ruby_version: !ruby/object:Gem::Requirement
35
47
  none: false
36
- requirements:
37
- - - ! '>='
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
56
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
46
64
  requirements: []
65
+
47
66
  rubyforge_project:
48
67
  rubygems_version: 1.8.10
49
68
  signing_key:
50
69
  specification_version: 3
51
- summary: Adds parallelism to any object in a transparent way
70
+ summary: Adds laziness & parallelism to any Ruby object in a transparent way
52
71
  test_files: []
72
+
73
+ has_rdoc: