nondeterminism 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +28 -0
- data/License.txt +17 -0
- data/Manifest.txt +37 -0
- data/README.txt +1 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +71 -0
- data/config/requirements.rb +17 -0
- data/lib/nondeterminism.rb +22 -14
- data/lib/nondeterminism/array.rb +10 -0
- data/lib/nondeterminism/probability/event.rb +29 -0
- data/lib/nondeterminism/probability/event_chain.rb +42 -0
- data/lib/nondeterminism/probability/helper_methods.rb +17 -0
- data/lib/nondeterminism/probability/kernel.rb +10 -0
- data/lib/nondeterminism/probability/numeric.rb +8 -0
- data/lib/nondeterminism/range.rb +10 -0
- data/lib/nondeterminism/version.rb +9 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/{array_test.rb → test_array.rb} +1 -2
- data/test/test_helper.rb +2 -1
- data/test/{integer_generator_test.rb → test_integer_generator.rb} +10 -3
- data/test/{percent_probability_test.rb → test_percent_probability.rb} +1 -2
- data/test/{probability_event_chain_test.rb → test_probability_event_chain.rb} +1 -3
- data/test/{probability_generator_test.rb → test_probability_generator.rb} +1 -2
- data/test/{range_test.rb → test_range.rb} +1 -2
- data/test/{ratio_probability_test.rb → test_ratio_probability.rb} +1 -2
- data/website/index.html +181 -0
- data/website/index.txt +111 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +60 -21
- data/README +0 -86
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nondeterminism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
5
|
-
platform:
|
4
|
+
version: 0.2.1
|
5
|
+
platform: ""
|
6
6
|
authors:
|
7
7
|
- James Rosen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
@@ -13,30 +13,62 @@ date: 2008-01-30 00:00:00 -05:00
|
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
17
|
-
email: james @nospam@
|
16
|
+
description: probabilistic blocks, random elements
|
17
|
+
email: james @nospam@ u-presence.com
|
18
18
|
executables: []
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
23
|
-
-
|
23
|
+
- History.txt
|
24
|
+
- License.txt
|
25
|
+
- Manifest.txt
|
26
|
+
- README.txt
|
27
|
+
- website/index.txt
|
24
28
|
files:
|
29
|
+
- History.txt
|
30
|
+
- License.txt
|
31
|
+
- Manifest.txt
|
32
|
+
- README.txt
|
33
|
+
- Rakefile
|
34
|
+
- config/hoe.rb
|
35
|
+
- config/requirements.rb
|
25
36
|
- lib/nondeterminism.rb
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
37
|
+
- lib/nondeterminism/array.rb
|
38
|
+
- lib/nondeterminism/probability/event.rb
|
39
|
+
- lib/nondeterminism/probability/event_chain.rb
|
40
|
+
- lib/nondeterminism/probability/helper_methods.rb
|
41
|
+
- lib/nondeterminism/probability/kernel.rb
|
42
|
+
- lib/nondeterminism/probability/numeric.rb
|
43
|
+
- lib/nondeterminism/range.rb
|
44
|
+
- lib/nondeterminism/version.rb
|
45
|
+
- log/debug.log
|
46
|
+
- script/destroy
|
47
|
+
- script/generate
|
48
|
+
- script/txt2html
|
49
|
+
- setup.rb
|
50
|
+
- tasks/deployment.rake
|
51
|
+
- tasks/environment.rake
|
52
|
+
- tasks/website.rake
|
53
|
+
- test/test_array.rb
|
33
54
|
- test/test_helper.rb
|
34
|
-
-
|
55
|
+
- test/test_integer_generator.rb
|
56
|
+
- test/test_percent_probability.rb
|
57
|
+
- test/test_probability_event_chain.rb
|
58
|
+
- test/test_probability_generator.rb
|
59
|
+
- test/test_range.rb
|
60
|
+
- test/test_ratio_probability.rb
|
61
|
+
- website/index.html
|
62
|
+
- website/index.txt
|
63
|
+
- website/javascripts/rounded_corners_lite.inc.js
|
64
|
+
- website/stylesheets/screen.css
|
65
|
+
- website/template.rhtml
|
35
66
|
has_rdoc: true
|
36
|
-
homepage:
|
67
|
+
homepage: http://nondeterminism.rubyforge.org
|
37
68
|
post_install_message:
|
38
|
-
rdoc_options:
|
39
|
-
|
69
|
+
rdoc_options:
|
70
|
+
- --main
|
71
|
+
- README.txt
|
40
72
|
require_paths:
|
41
73
|
- lib
|
42
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -53,10 +85,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
85
|
version:
|
54
86
|
requirements: []
|
55
87
|
|
56
|
-
rubyforge_project:
|
88
|
+
rubyforge_project: nondeterminism
|
57
89
|
rubygems_version: 0.9.5
|
58
90
|
signing_key:
|
59
91
|
specification_version: 2
|
60
|
-
summary:
|
61
|
-
test_files:
|
62
|
-
|
92
|
+
summary: probabilistic blocks, random elements
|
93
|
+
test_files:
|
94
|
+
- test/test_array.rb
|
95
|
+
- test/test_helper.rb
|
96
|
+
- test/test_integer_generator.rb
|
97
|
+
- test/test_percent_probability.rb
|
98
|
+
- test/test_probability_event_chain.rb
|
99
|
+
- test/test_probability_generator.rb
|
100
|
+
- test/test_range.rb
|
101
|
+
- test/test_ratio_probability.rb
|
data/README
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
Copyright 2008 James Rosen
|
2
|
-
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
you may not use this file except in compliance with the License.
|
5
|
-
You may obtain a copy of the License at
|
6
|
-
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
See the License for the specific language governing permissions and
|
13
|
-
limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Some example use cases:
|
19
|
-
|
20
|
-
|
21
|
-
# accept only half of emails
|
22
|
-
50.percent_of_the_time do
|
23
|
-
email.accept!
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
# accept only half of emails and send nasty
|
28
|
-
# responses to the rest
|
29
|
-
50.percent_of_the_time do
|
30
|
-
email.accept!
|
31
|
-
end.else do
|
32
|
-
email.send_nasty_response!
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
# name should be
|
37
|
-
# 'jerome' 30% of the time
|
38
|
-
# 'kevin' 40% of the time
|
39
|
-
# 'leslie' the rest of the time
|
40
|
-
|
41
|
-
with_probability(0.30) do
|
42
|
-
name = 'jerome'
|
43
|
-
end.else_with_probability(0.40) do
|
44
|
-
name = 'kevin'
|
45
|
-
end.else
|
46
|
-
name = 'leslie'
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
# select a random friend from an Array:
|
51
|
-
friend = person.friends.random_element
|
52
|
-
|
53
|
-
|
54
|
-
# call foo between 5 and 8 times (inclusive):
|
55
|
-
(5..8).times do
|
56
|
-
foo
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
Using a custom random probability generator:
|
62
|
-
if you want to change the random-probability-generation mechanism, do
|
63
|
-
something like:
|
64
|
-
|
65
|
-
Nondeterminism::probability_generator = Proc.new { ... }
|
66
|
-
|
67
|
-
or
|
68
|
-
|
69
|
-
Nondeterminism::probability_generator = my_obj
|
70
|
-
|
71
|
-
just make sure my_obj responds to #call or #to_proc and only returns
|
72
|
-
numbers in [0.0, 1.0]
|
73
|
-
|
74
|
-
|
75
|
-
Using a custom random integer generator:
|
76
|
-
if you want to change the random-integer-generation mechanism, do
|
77
|
-
something like:
|
78
|
-
|
79
|
-
Nondeterminism::integer_generator = Proc.new { |low, high| ... }
|
80
|
-
|
81
|
-
or
|
82
|
-
|
83
|
-
Nondeterminism::integer_generator = Proc.new { |low, high| ... }
|
84
|
-
|
85
|
-
just make sure my_obj responds to #to_proc, the proc has #arity = 2
|
86
|
-
(or < -2), and only returns numbers in [low, high]
|