frequency-dsl 0.0.7 → 0.2.0

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.
@@ -1,61 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{frequency-dsl}
8
- s.version = "0.0.7"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tiago Peczenyj"]
12
- s.date = %q{2010-05-19}
13
- s.description = %q{A small dsl written in ruby to work with frequency events (never, sometimes, always..)}
14
- s.email = %q{tiago.peczenyj@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- "LICENSE",
21
- "README.rdoc",
22
- "Rakefile",
23
- "VERSION",
24
- "frequency-dsl.gemspec",
25
- "lib/frequency.rb",
26
- "rdoc/classes/Frequency.html",
27
- "rdoc/created.rid",
28
- "rdoc/files/README_rdoc.html",
29
- "rdoc/files/lib/frequency_rb.html",
30
- "rdoc/fr_class_index.html",
31
- "rdoc/fr_file_index.html",
32
- "rdoc/fr_method_index.html",
33
- "rdoc/index.html",
34
- "rdoc/rdoc-style.css",
35
- "spec/frequency_spec.rb",
36
- "spec/spec_helper.rb"
37
- ]
38
- s.homepage = %q{http://github.com/peczenyj/Frequency}
39
- s.rdoc_options = ["--charset=UTF-8"]
40
- s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.3.7}
42
- s.summary = %q{A small dsl written in ruby to work with frequency events}
43
- s.test_files = [
44
- "spec/frequency_spec.rb",
45
- "spec/spec_helper.rb"
46
- ]
47
-
48
- if s.respond_to? :specification_version then
49
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
- s.specification_version = 3
51
-
52
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_development_dependency(%q<rspec>, [">= 0"])
54
- else
55
- s.add_dependency(%q<rspec>, [">= 0"])
56
- end
57
- else
58
- s.add_dependency(%q<rspec>, [">= 0"])
59
- end
60
- end
61
-
@@ -1,316 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Module: Frequency</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Module</strong></td>
53
- <td class="class-name-in-header">Frequency</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/frequency_rb.html">
59
- lib/frequency.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- </table>
66
- </div>
67
- <!-- banner header -->
68
-
69
- <div id="bodyContent">
70
-
71
-
72
-
73
- <div id="contextContent">
74
-
75
- <div id="description">
76
- <p>
77
- Module <a href="Frequency.html">Frequency</a> A small dsl written in ruby
78
- to work with frequency events (<a href="Frequency.html#M000005">never</a>,
79
- <a href="Frequency.html#M000003">sometimes</a>, <a
80
- href="Frequency.html#M000001">always</a>..)
81
- </p>
82
-
83
- </div>
84
-
85
-
86
- </div>
87
-
88
- <div id="method-list">
89
- <h3 class="section-bar">Methods</h3>
90
-
91
- <div class="name-list">
92
- <a href="#M000001">always</a>&nbsp;&nbsp;
93
- <a href="#M000005">never</a>&nbsp;&nbsp;
94
- <a href="#M000002">normally</a>&nbsp;&nbsp;
95
- <a href="#M000004">rarely</a>&nbsp;&nbsp;
96
- <a href="#M000003">sometimes</a>&nbsp;&nbsp;
97
- </div>
98
- </div>
99
-
100
- </div>
101
-
102
-
103
- <!-- if includes -->
104
-
105
- <div id="section">
106
-
107
-
108
- <div id="constants-list">
109
- <h3 class="section-bar">Constants</h3>
110
-
111
- <div class="name-list">
112
- <table summary="Constants">
113
- <tr class="top-aligned-row context-row">
114
- <td class="context-item-name">NORMALLY</td>
115
- <td>=</td>
116
- <td class="context-item-value">0.75</td>
117
- </tr>
118
- <tr class="top-aligned-row context-row">
119
- <td class="context-item-name">SOMETIMES</td>
120
- <td>=</td>
121
- <td class="context-item-value">0.50</td>
122
- </tr>
123
- <tr class="top-aligned-row context-row">
124
- <td class="context-item-name">RARELY</td>
125
- <td>=</td>
126
- <td class="context-item-value">0.25</td>
127
- </tr>
128
- </table>
129
- </div>
130
- </div>
131
-
132
-
133
-
134
-
135
-
136
-
137
- <!-- if method_list -->
138
- <div id="methods">
139
- <h3 class="section-bar">Public Instance methods</h3>
140
-
141
- <div id="method-M000001" class="method-detail">
142
- <a name="M000001"></a>
143
-
144
- <div class="method-heading">
145
- <a href="#M000001" class="method-signature">
146
- <span class="method-name">always</span><span class="method-args">(cond={}) {|if block_given?| ...}</span>
147
- </a>
148
- </div>
149
-
150
- <div class="method-description">
151
- <p>
152
- <a href="Frequency.html#M000001">always</a> do something example:
153
- </p>
154
- <pre>
155
- always { puts &quot;ok&quot;}
156
- </pre>
157
- <p><a class="source-toggle" href="#"
158
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
159
- <div class="method-source-code" id="M000001-source">
160
- <pre>
161
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 12</span>
162
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">always</span>(<span class="ruby-identifier">cond</span>={})
163
- <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
164
- <span class="ruby-keyword kw">end</span>
165
- </pre>
166
- </div>
167
- </div>
168
- </div>
169
-
170
- <div id="method-M000005" class="method-detail">
171
- <a name="M000005"></a>
172
-
173
- <div class="method-heading">
174
- <a href="#M000005" class="method-signature">
175
- <span class="method-name">never</span><span class="method-args">(cond={})</span>
176
- </a>
177
- </div>
178
-
179
- <div class="method-description">
180
- <p>
181
- <a href="Frequency.html#M000005">never</a> do something example:
182
- </p>
183
- <pre>
184
- never { puts &quot;ok&quot;}
185
- </pre>
186
- <p><a class="source-toggle" href="#"
187
- onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
188
- <div class="method-source-code" id="M000005-source">
189
- <pre>
190
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 50</span>
191
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">never</span>(<span class="ruby-identifier">cond</span>={})
192
- <span class="ruby-keyword kw">nil</span>
193
- <span class="ruby-keyword kw">end</span>
194
- </pre>
195
- </div>
196
- </div>
197
- </div>
198
-
199
- <div id="method-M000002" class="method-detail">
200
- <a name="M000002"></a>
201
-
202
- <div class="method-heading">
203
- <a href="#M000002" class="method-signature">
204
- <span class="method-name">normally</span><span class="method-args">(cond={}) {|| ...}</span>
205
- </a>
206
- </div>
207
-
208
- <div class="method-description">
209
- <p>
210
- <a href="Frequency.html#M000002">normally</a> (75%) do something, see <a
211
- href="Frequency.html#M000003">sometimes</a> method example:
212
- </p>
213
- <pre>
214
- normally { puts &quot;ok&quot;}
215
- </pre>
216
- <p><a class="source-toggle" href="#"
217
- onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
218
- <div class="method-source-code" id="M000002-source">
219
- <pre>
220
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 20</span>
221
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">normally</span>(<span class="ruby-identifier">cond</span>={})
222
- <span class="ruby-identifier">execute_with_probability</span>(<span class="ruby-identifier">cond</span>,<span class="ruby-constant">NORMALLY</span> ) { <span class="ruby-keyword kw">yield</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
223
- <span class="ruby-keyword kw">end</span>
224
- </pre>
225
- </div>
226
- </div>
227
- </div>
228
-
229
- <div id="method-M000004" class="method-detail">
230
- <a name="M000004"></a>
231
-
232
- <div class="method-heading">
233
- <a href="#M000004" class="method-signature">
234
- <span class="method-name">rarely</span><span class="method-args">(cond={}) {|| ...}</span>
235
- </a>
236
- </div>
237
-
238
- <div class="method-description">
239
- <p>
240
- <a href="Frequency.html#M000004">rarely</a> (25%) do something, see <a
241
- href="Frequency.html#M000003">sometimes</a> method example:
242
- </p>
243
- <pre>
244
- rarely { puts &quot;ok&quot;}
245
- </pre>
246
- <p><a class="source-toggle" href="#"
247
- onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
248
- <div class="method-source-code" id="M000004-source">
249
- <pre>
250
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 43</span>
251
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rarely</span>(<span class="ruby-identifier">cond</span>={})
252
- <span class="ruby-identifier">execute_with_probability</span>(<span class="ruby-identifier">cond</span>,<span class="ruby-constant">RARELY</span> ) { <span class="ruby-keyword kw">yield</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
253
- <span class="ruby-keyword kw">end</span>
254
- </pre>
255
- </div>
256
- </div>
257
- </div>
258
-
259
- <div id="method-M000003" class="method-detail">
260
- <a name="M000003"></a>
261
-
262
- <div class="method-heading">
263
- <a href="#M000003" class="method-signature">
264
- <span class="method-name">sometimes</span><span class="method-args">(cond={}) {|| ...}</span>
265
- </a>
266
- </div>
267
-
268
- <div class="method-description">
269
- <p>
270
- <a href="Frequency.html#M000003">sometimes</a> (50%) do something example:
271
- </p>
272
- <pre>
273
- sometimes do
274
- # some code
275
- end
276
- </pre>
277
- <p>
278
- or adjusting the probability
279
- </p>
280
- <pre>
281
- sometimes :with_probability =&gt; 0.12 do
282
- # some code
283
- end
284
- </pre>
285
- <p>
286
- you can use &quot;12%&quot; instead 0.12
287
- </p>
288
- <pre>
289
- sometimes(:with_probability =&gt; '13.6%') { ... }
290
- </pre>
291
- <p><a class="source-toggle" href="#"
292
- onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
293
- <div class="method-source-code" id="M000003-source">
294
- <pre>
295
- <span class="ruby-comment cmt"># File lib/frequency.rb, line 35</span>
296
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sometimes</span>(<span class="ruby-identifier">cond</span>={})
297
- <span class="ruby-identifier">execute_with_probability</span>(<span class="ruby-identifier">cond</span>,<span class="ruby-constant">SOMETIMES</span>) { <span class="ruby-keyword kw">yield</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
298
- <span class="ruby-keyword kw">end</span>
299
- </pre>
300
- </div>
301
- </div>
302
- </div>
303
-
304
-
305
- </div>
306
-
307
-
308
- </div>
309
-
310
-
311
- <div id="validator-badges">
312
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
313
- </div>
314
-
315
- </body>
316
- </html>
data/rdoc/created.rid DELETED
@@ -1 +0,0 @@
1
- Wed, 19 May 2010 22:05:20 -0300
@@ -1,150 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: README.rdoc</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>README.rdoc</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>README.rdoc
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed May 19 21:29:12 -0300 2010</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h1><a href="../classes/Frequency.html">Frequency</a></h1>
73
- <p>
74
- <a href="../classes/Frequency.html">Frequency</a> is a small dsl written in
75
- ruby to work with frequency events (never, sometimes, always..)
76
- </p>
77
- <h2>Examples</h2>
78
- <p>
79
- <a href="../classes/Frequency.html">Frequency</a> is easy&#8230;
80
- </p>
81
- <pre>
82
- require 'rubygems'
83
- require 'frequency'
84
-
85
- include Frequency
86
-
87
- sometimes do
88
- puts &quot;sometimes you can see this times, sometimes not&quot;
89
- end
90
-
91
- never do
92
- puts &quot;this line never will be print&quot;
93
- end
94
-
95
- rarely :with_probability =&gt; 0.01 do
96
- puts &quot;ok, its very rare...&quot;
97
- end
98
-
99
- normally :with_probability =&gt; '24%' do
100
- puts &quot;you can use strings instead float numbers&quot;
101
- end
102
-
103
- always do
104
- puts &quot;bye&quot;
105
- end
106
- </pre>
107
- <p>
108
- the option with_probability does not work with never and always.
109
- </p>
110
- <h2>Install</h2>
111
- <pre>
112
- [sudo] gem install frequency-dsl
113
- </pre>
114
- <h2>Copyright</h2>
115
- <p>
116
- Copyright (c) 2010 Tiago Peczenyj. See LICENSE for details.
117
- </p>
118
-
119
- </div>
120
-
121
-
122
- </div>
123
-
124
-
125
- </div>
126
-
127
-
128
- <!-- if includes -->
129
-
130
- <div id="section">
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
- <!-- if method_list -->
140
-
141
-
142
- </div>
143
-
144
-
145
- <div id="validator-badges">
146
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
147
- </div>
148
-
149
- </body>
150
- </html>
@@ -1,108 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: frequency.rb</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>frequency.rb</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>lib/frequency.rb
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Wed May 19 22:02:24 -0300 2010</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <p>
73
- Module <a href="../../classes/Frequency.html">Frequency</a> A small dsl
74
- written in ruby to work with frequency events (never, sometimes, always..)
75
- </p>
76
-
77
- </div>
78
-
79
-
80
- </div>
81
-
82
-
83
- </div>
84
-
85
-
86
- <!-- if includes -->
87
-
88
- <div id="section">
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
- <!-- if method_list -->
98
-
99
-
100
- </div>
101
-
102
-
103
- <div id="validator-badges">
104
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
105
- </div>
106
-
107
- </body>
108
- </html>
@@ -1,27 +0,0 @@
1
-
2
- <?xml version="1.0" encoding="iso-8859-1"?>
3
- <!DOCTYPE html
4
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
-
7
- <!--
8
-
9
- Classes
10
-
11
- -->
12
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
- <head>
14
- <title>Classes</title>
15
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
- <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
- <base target="docwin" />
18
- </head>
19
- <body>
20
- <div id="index">
21
- <h1 class="section-bar">Classes</h1>
22
- <div id="index-entries">
23
- <a href="classes/Frequency.html">Frequency</a><br />
24
- </div>
25
- </div>
26
- </body>
27
- </html>
@@ -1,28 +0,0 @@
1
-
2
- <?xml version="1.0" encoding="iso-8859-1"?>
3
- <!DOCTYPE html
4
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
-
7
- <!--
8
-
9
- Files
10
-
11
- -->
12
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
- <head>
14
- <title>Files</title>
15
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
- <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
- <base target="docwin" />
18
- </head>
19
- <body>
20
- <div id="index">
21
- <h1 class="section-bar">Files</h1>
22
- <div id="index-entries">
23
- <a href="files/README_rdoc.html">README.rdoc</a><br />
24
- <a href="files/lib/frequency_rb.html">lib/frequency.rb</a><br />
25
- </div>
26
- </div>
27
- </body>
28
- </html>