promise 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +10 -1
  2. data/VERSION +1 -1
  3. data/lib/future.rb +4 -4
  4. data/lib/promise.rb +3 -4
  5. metadata +30 -13
data/README CHANGED
@@ -4,7 +4,7 @@ A glimpse of a promising future in which ruby supports delayed execution
4
4
  ## Overview
5
5
 
6
6
  require 'promise'
7
- require 'future' # can just require future if using both
7
+ require 'future' # you can just require future if using both
8
8
 
9
9
  x = promise { 1 + 2 }
10
10
  y = future { sleep 10; 5 + 5 }
@@ -19,11 +19,20 @@ Futures run the evaluation of the block optimistically in another thread.
19
19
  Note that this is pretty useless in irb, which will evaluate everything
20
20
  as part of its read-eval-print loop.
21
21
 
22
+ Yardocs are available at <http://promise.rubyforge.org/>. Tested under MRI
23
+ 1.8 and JRuby.
24
+
22
25
  ## Classes
23
26
 
24
27
  * {Promise}
25
28
  * {Future}
26
29
 
30
+ ## Installation
31
+
32
+ Promising future is distributed via gemcutter under the name 'promise'.
33
+
34
+ gem install promise
35
+
27
36
  ## Source
28
37
  The source is available at <http://github.com/bhuga/promising-future>
29
38
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/future.rb CHANGED
@@ -7,16 +7,16 @@ require 'promise'
7
7
  # # do stuff...
8
8
  # y = x * 2 # => 6. blocks unless 5 seconds has passed.
9
9
  #
10
- class Future
11
-
12
- instance_methods.each { |m| undef_method m unless m =~ /__/ }
10
+ class Future < defined?(BasicObject) ? BasicObject : Object
13
11
 
12
+ instance_methods.each { |m| undef_method m unless m =~ /__|object_id/ } unless defined?(BasicObject)
13
+
14
14
  ##
15
15
  # @param [Proc] block
16
16
  # @return [Future]
17
17
  def initialize(block)
18
18
  @promise = promise &block
19
- @thread = Thread.new do
19
+ @thread = ::Thread.new do
20
20
  @promise.force
21
21
  end
22
22
  end
data/lib/promise.rb CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  ##
3
2
  # A delayed-execution promise. Promises are only executed once.
4
3
  # @example
@@ -12,9 +11,9 @@
12
11
  # x = promise { y = y + 5 }
13
12
  # x + 5 # => 15
14
13
  # x + 5 # => 15
15
- class Promise
14
+ class Promise < defined?(BasicObject) ? BasicObject : Object
16
15
 
17
- instance_methods.each { |m| undef_method m unless m =~ /__/ }
16
+ instance_methods.each { |m| undef_method m unless m =~ /__|object_id/ } unless defined?(BasicObject)
18
17
 
19
18
  # Returns a new promise
20
19
  # @param [Proc] block
@@ -24,7 +23,7 @@ class Promise
24
23
  raise ArgumentError, "Cannot store a promise that requires an argument"
25
24
  end
26
25
  @block = block
27
- @mutex = Mutex.new
26
+ @mutex = ::Mutex.new
28
27
  end
29
28
 
30
29
  # Force the evaluation of this promise immediately
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Ben Lavender
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-01-11 00:00:00 +01:00
17
+ date: 2010-06-04 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
23
31
  version: 1.2.9
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: yard
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 5
44
+ - 2
33
45
  version: 0.5.2
34
- version:
46
+ type: :development
47
+ version_requirements: *id002
35
48
  description: " A glimpse into a promising future, in which ruby supports delayed execution.\n Provides 'promise' and 'future' functions.\n"
36
49
  email: blavender@gmail.com
37
50
  executables: []
@@ -60,18 +73,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
73
  requirements:
61
74
  - - ">="
62
75
  - !ruby/object:Gem::Version
76
+ segments:
77
+ - 1
78
+ - 8
79
+ - 2
63
80
  version: 1.8.2
64
- version:
65
81
  required_rubygems_version: !ruby/object:Gem::Requirement
66
82
  requirements:
67
83
  - - ">="
68
84
  - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
69
87
  version: "0"
70
- version:
71
88
  requirements: []
72
89
 
73
90
  rubyforge_project: promising-future
74
- rubygems_version: 1.3.5
91
+ rubygems_version: 1.3.6
75
92
  signing_key:
76
93
  specification_version: 3
77
94
  summary: Promises and futures for Ruby