camping-abingo 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/README +3 -0
  2. data/doc/classes/ABingoCampingPlugin.html +188 -0
  3. data/doc/classes/ABingoCampingPlugin.src/M000016.html +18 -0
  4. data/doc/classes/ABingoCampingPlugin.src/M000017.html +18 -0
  5. data/doc/classes/ABingoCampingPlugin.src/M000018.html +19 -0
  6. data/doc/classes/ABingoCampingPlugin.src/M000034.html +18 -0
  7. data/doc/classes/ABingoCampingPlugin.src/M000035.html +18 -0
  8. data/doc/classes/ABingoCampingPlugin.src/M000036.html +19 -0
  9. data/doc/classes/ABingoCampingPlugin/ABingo.html +121 -0
  10. data/doc/classes/ABingoCampingPlugin/Controllers.html +191 -0
  11. data/doc/classes/ABingoCampingPlugin/Controllers.src/M000022.html +18 -0
  12. data/doc/classes/ABingoCampingPlugin/Controllers.src/M000023.html +26 -0
  13. data/doc/classes/ABingoCampingPlugin/Controllers.src/M000040.html +18 -0
  14. data/doc/classes/ABingoCampingPlugin/Controllers.src/M000041.html +26 -0
  15. data/doc/classes/ABingoCampingPlugin/Filters.html +158 -0
  16. data/doc/classes/ABingoCampingPlugin/Filters.src/M000037.html +26 -0
  17. data/doc/classes/ABingoCampingPlugin/Filters.src/M000055.html +26 -0
  18. data/doc/classes/ABingoCampingPlugin/Helpers.html +372 -0
  19. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000024.html +18 -0
  20. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000025.html +19 -0
  21. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000026.html +18 -0
  22. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000027.html +18 -0
  23. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000028.html +36 -0
  24. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000029.html +28 -0
  25. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000030.html +18 -0
  26. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000031.html +48 -0
  27. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000032.html +32 -0
  28. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000033.html +18 -0
  29. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000034.html +26 -0
  30. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000035.html +20 -0
  31. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000036.html +18 -0
  32. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000042.html +18 -0
  33. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000043.html +19 -0
  34. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000044.html +18 -0
  35. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000045.html +18 -0
  36. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000046.html +36 -0
  37. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000047.html +28 -0
  38. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000048.html +18 -0
  39. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000049.html +48 -0
  40. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000050.html +32 -0
  41. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000051.html +18 -0
  42. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000052.html +26 -0
  43. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000053.html +20 -0
  44. data/doc/classes/ABingoCampingPlugin/Helpers.src/M000054.html +18 -0
  45. data/doc/classes/ABingoCampingPlugin/Models.html +208 -0
  46. data/doc/classes/ABingoCampingPlugin/Models.src/M000038.html +22 -0
  47. data/doc/classes/ABingoCampingPlugin/Models.src/M000039.html +39 -0
  48. data/doc/classes/ABingoCampingPlugin/Models.src/M000040.html +21 -0
  49. data/doc/classes/ABingoCampingPlugin/Models.src/M000056.html +22 -0
  50. data/doc/classes/ABingoCampingPlugin/Models.src/M000057.html +39 -0
  51. data/doc/classes/ABingoCampingPlugin/Models.src/M000058.html +21 -0
  52. data/doc/classes/ABingoCampingPlugin/Models/Alternative.html +181 -0
  53. data/doc/classes/ABingoCampingPlugin/Models/Alternative.src/M000041.html +20 -0
  54. data/doc/classes/ABingoCampingPlugin/Models/Alternative.src/M000042.html +21 -0
  55. data/doc/classes/ABingoCampingPlugin/Models/Alternative.src/M000043.html +21 -0
  56. data/doc/classes/ABingoCampingPlugin/Models/Alternative.src/M000059.html +20 -0
  57. data/doc/classes/ABingoCampingPlugin/Models/Alternative.src/M000060.html +21 -0
  58. data/doc/classes/ABingoCampingPlugin/Models/Alternative.src/M000061.html +21 -0
  59. data/doc/classes/ABingoCampingPlugin/Models/Experiment.html +273 -0
  60. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000044.html +21 -0
  61. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000045.html +21 -0
  62. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000046.html +18 -0
  63. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000047.html +18 -0
  64. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000048.html +20 -0
  65. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000049.html +23 -0
  66. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000050.html +29 -0
  67. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000051.html +50 -0
  68. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000052.html +28 -0
  69. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000062.html +21 -0
  70. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000063.html +21 -0
  71. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000064.html +18 -0
  72. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000065.html +18 -0
  73. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000066.html +20 -0
  74. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000067.html +23 -0
  75. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000068.html +29 -0
  76. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000069.html +50 -0
  77. data/doc/classes/ABingoCampingPlugin/Models/Experiment.src/M000070.html +28 -0
  78. data/doc/classes/ABingoCampingPlugin/Views.html +196 -0
  79. data/doc/classes/ABingoCampingPlugin/Views.src/M000019.html +18 -0
  80. data/doc/classes/ABingoCampingPlugin/Views.src/M000020.html +18 -0
  81. data/doc/classes/ABingoCampingPlugin/Views.src/M000021.html +30 -0
  82. data/doc/classes/ABingoCampingPlugin/Views.src/M000037.html +18 -0
  83. data/doc/classes/ABingoCampingPlugin/Views.src/M000038.html +18 -0
  84. data/doc/classes/ABingoCampingPlugin/Views.src/M000039.html +30 -0
  85. data/doc/classes/Abingo.html +429 -0
  86. data/doc/classes/Abingo.src/M000001.html +18 -0
  87. data/doc/classes/Abingo.src/M000002.html +18 -0
  88. data/doc/classes/Abingo.src/M000003.html +18 -0
  89. data/doc/classes/Abingo.src/M000004.html +22 -0
  90. data/doc/classes/Abingo.src/M000005.html +69 -0
  91. data/doc/classes/Abingo.src/M000006.html +47 -0
  92. data/doc/classes/Abingo.src/M000007.html +31 -0
  93. data/doc/classes/Abingo.src/M000008.html +36 -0
  94. data/doc/classes/Abingo.src/M000009.html +18 -0
  95. data/doc/classes/Abingo.src/M000010.html +36 -0
  96. data/doc/classes/Abingo.src/M000011.html +22 -0
  97. data/doc/classes/Abingo.src/M000012.html +21 -0
  98. data/doc/classes/Abingo.src/M000013.html +18 -0
  99. data/doc/classes/Abingo.src/M000014.html +39 -0
  100. data/doc/classes/Abingo.src/M000015.html +25 -0
  101. data/doc/classes/ActiveSupport.html +107 -0
  102. data/doc/classes/ActiveSupport/Cache.html +111 -0
  103. data/doc/classes/ActiveSupport/Cache/MemoryStore.html +137 -0
  104. data/doc/classes/ActiveSupport/Cache/MemoryStore.src/M000016.html +18 -0
  105. data/doc/classes/CampingABingoTest.html +149 -0
  106. data/doc/classes/CampingABingoTest.src/M000017.html +24 -0
  107. data/doc/classes/CampingABingoTest/Controllers.html +116 -0
  108. data/doc/classes/CampingABingoTest/Controllers/Index.html +137 -0
  109. data/doc/classes/CampingABingoTest/Controllers/Index.src/M000024.html +18 -0
  110. data/doc/classes/CampingABingoTest/Controllers/Landing.html +137 -0
  111. data/doc/classes/CampingABingoTest/Controllers/Landing.src/M000026.html +18 -0
  112. data/doc/classes/CampingABingoTest/Controllers/SignIn.html +152 -0
  113. data/doc/classes/CampingABingoTest/Controllers/SignIn.src/M000030.html +18 -0
  114. data/doc/classes/CampingABingoTest/Controllers/SignIn.src/M000031.html +34 -0
  115. data/doc/classes/CampingABingoTest/Controllers/SignOut.html +137 -0
  116. data/doc/classes/CampingABingoTest/Controllers/SignOut.src/M000029.html +21 -0
  117. data/doc/classes/CampingABingoTest/Controllers/SignUp.html +152 -0
  118. data/doc/classes/CampingABingoTest/Controllers/SignUp.src/M000027.html +23 -0
  119. data/doc/classes/CampingABingoTest/Controllers/SignUp.src/M000028.html +33 -0
  120. data/doc/classes/CampingABingoTest/Controllers/Welcome.html +137 -0
  121. data/doc/classes/CampingABingoTest/Controllers/Welcome.src/M000025.html +18 -0
  122. data/doc/classes/CampingABingoTest/Helpers.html +112 -0
  123. data/doc/classes/CampingABingoTest/Models.html +119 -0
  124. data/doc/classes/CampingABingoTest/Models/CreateUserSchema.html +152 -0
  125. data/doc/classes/CampingABingoTest/Models/CreateUserSchema.src/M000032.html +26 -0
  126. data/doc/classes/CampingABingoTest/Models/CreateUserSchema.src/M000033.html +19 -0
  127. data/doc/classes/CampingABingoTest/Models/User.html +111 -0
  128. data/doc/classes/CampingABingoTest/Views.html +206 -0
  129. data/doc/classes/CampingABingoTest/Views.src/M000018.html +70 -0
  130. data/doc/classes/CampingABingoTest/Views.src/M000019.html +22 -0
  131. data/doc/classes/CampingABingoTest/Views.src/M000020.html +51 -0
  132. data/doc/classes/CampingABingoTest/Views.src/M000021.html +31 -0
  133. data/doc/classes/CampingABingoTest/Views.src/M000022.html +31 -0
  134. data/doc/classes/CampingABingoTest/Views.src/M000023.html +20 -0
  135. data/doc/created.rid +1 -0
  136. data/doc/files/examples/camping-abingo-test/camping-abingo-test_rb.html +101 -0
  137. data/doc/files/lib/camping-abingo_rb.html +457 -0
  138. data/doc/fr_class_index.html +52 -0
  139. data/doc/fr_file_index.html +28 -0
  140. data/doc/fr_method_index.html +96 -0
  141. data/doc/index.html +24 -0
  142. data/lib/camping-abingo.rb +1233 -0
  143. metadata +279 -0
@@ -0,0 +1,18 @@
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>
7
+ <head>
8
+ <title>cache (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 262</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache</span>
15
+ <span class="ruby-ivar">@@cache</span> <span class="ruby-operator">||</span> <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Cache</span>.<span class="ruby-identifier">lookup_store</span>(<span class="ruby-identifier">:memory_store</span>) <span class="ruby-comment cmt"># Camping-specific change to explicitly request a cache store</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
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>
7
+ <head>
8
+ <title>identity= (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 273</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">identity=</span>(<span class="ruby-identifier">new_identity</span>)
15
+ <span class="ruby-ivar">@@identity</span> = <span class="ruby-identifier">new_identity</span>.<span class="ruby-identifier">to_s</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,18 @@
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>
7
+ <head>
8
+ <title>identity (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 277</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">identity</span>
15
+ <span class="ruby-ivar">@@identity</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">rand</span>(<span class="ruby-value">10</span> <span class="ruby-operator">**</span> <span class="ruby-value">10</span>).<span class="ruby-identifier">to_i</span>.<span class="ruby-identifier">to_s</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,22 @@
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>
7
+ <head>
8
+ <title>flip (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 283</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">flip</span>(<span class="ruby-identifier">test_name</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
16
+ <span class="ruby-keyword kw">yield</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">test</span>(<span class="ruby-identifier">test_name</span>, [<span class="ruby-keyword kw">true</span>, <span class="ruby-keyword kw">false</span>]))
17
+ <span class="ruby-keyword kw">else</span>
18
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">test</span>(<span class="ruby-identifier">test_name</span>, [<span class="ruby-keyword kw">true</span>, <span class="ruby-keyword kw">false</span>])
19
+ <span class="ruby-keyword kw">end</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,69 @@
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>
7
+ <head>
8
+ <title>test (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 295</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">test</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">alternatives</span>, <span class="ruby-identifier">options</span> = {})
15
+ <span class="ruby-constant">ABingoCampingPlugin</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;test #{test_name} alternatives: #{alternatives.inspect} options:#{options.inspect} for #{Abingo.identity}&quot;</span>
16
+ <span class="ruby-identifier">short_circuit</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::Experiment::short_circuit(#{test_name})&quot;</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot; &quot;</span>, <span class="ruby-value str">&quot;_&quot;</span>))
17
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">short_circuit</span>.<span class="ruby-identifier">nil?</span>
18
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">short_circuit</span> <span class="ruby-comment cmt">#Test has been stopped, pick canonical alternative.</span>
19
+ <span class="ruby-keyword kw">end</span>
20
+
21
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">ABingoCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Models</span><span class="ruby-operator">::</span><span class="ruby-constant">Experiment</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">test_name</span>) <span class="ruby-comment cmt"># Camping-specific</span>
22
+ <span class="ruby-identifier">lock_key</span> = <span class="ruby-node">&quot;Abingo::lock_for_creation(#{test_name.gsub(&quot; &quot;, &quot;_&quot;)})&quot;</span>
23
+ <span class="ruby-identifier">creation_required</span> = <span class="ruby-keyword kw">true</span>
24
+
25
+ <span class="ruby-comment cmt">#this prevents (most) repeated creations of experiments in high concurrency environments.</span>
26
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">lock_key</span>)
27
+ <span class="ruby-identifier">creation_required</span> = <span class="ruby-keyword kw">false</span>
28
+ <span class="ruby-keyword kw">while</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">lock_key</span>)
29
+ <span class="ruby-identifier">sleep</span>(<span class="ruby-value">0</span><span class="ruby-value">.1</span>)
30
+ <span class="ruby-keyword kw">end</span>
31
+ <span class="ruby-identifier">creation_required</span> = <span class="ruby-constant">ABingoCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Models</span><span class="ruby-operator">::</span><span class="ruby-constant">Experiment</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">test_name</span>) <span class="ruby-comment cmt"># Camping-specific</span>
32
+ <span class="ruby-keyword kw">end</span>
33
+
34
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">creation_required</span>
35
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">lock_key</span>, <span class="ruby-value">1</span>, <span class="ruby-identifier">:expires_in</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">5</span>.<span class="ruby-identifier">seconds</span>)
36
+ <span class="ruby-identifier">conversion_name</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:conversion</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:conversion_name</span>]
37
+ <span class="ruby-constant">ABingoCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Models</span><span class="ruby-operator">::</span><span class="ruby-constant">Experiment</span>.<span class="ruby-identifier">start_experiment!</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_alternatives</span>(<span class="ruby-identifier">alternatives</span>), <span class="ruby-identifier">conversion_name</span>) <span class="ruby-comment cmt"># Camping-specific</span>
38
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">lock_key</span>)
39
+ <span class="ruby-keyword kw">end</span>
40
+ <span class="ruby-keyword kw">end</span>
41
+
42
+ <span class="ruby-identifier">choice</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">find_alternative_for_user</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">alternatives</span>)
43
+ <span class="ruby-identifier">participating_tests</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{Abingo.identity}&quot;</span>) <span class="ruby-operator">||</span> []
44
+
45
+ <span class="ruby-comment cmt">#Set this user to participate in this experiment, and increment participants count.</span>
46
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:multiple_participation</span>] <span class="ruby-operator">||</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">participating_tests</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">test_name</span>))
47
+ <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">participating_tests</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">test_name</span>)
48
+ <span class="ruby-identifier">participating_tests</span> = <span class="ruby-identifier">participating_tests</span> <span class="ruby-operator">+</span> [<span class="ruby-identifier">test_name</span>]
49
+ <span class="ruby-identifier">expires_in</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">expires_in</span>
50
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">expires_in</span>
51
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{Abingo.identity}&quot;</span>, <span class="ruby-identifier">participating_tests</span>, {<span class="ruby-identifier">:expires_in</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">expires_in</span>})
52
+ <span class="ruby-keyword kw">else</span>
53
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{Abingo.identity}&quot;</span>, <span class="ruby-identifier">participating_tests</span>)
54
+ <span class="ruby-keyword kw">end</span>
55
+ <span class="ruby-keyword kw">end</span>
56
+ <span class="ruby-comment cmt">#If we're only counting known humans, then postpone scoring participation until after we know the user is human.</span>
57
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-operator">!</span><span class="ruby-ivar">@@options</span>[<span class="ruby-identifier">:count_humans_only</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">is_human?</span>)
58
+ <span class="ruby-constant">ABingoCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Models</span><span class="ruby-operator">::</span><span class="ruby-constant">Alternative</span>.<span class="ruby-identifier">score_participation</span>(<span class="ruby-identifier">test_name</span>) <span class="ruby-comment cmt"># Camping-specific</span>
59
+ <span class="ruby-keyword kw">end</span>
60
+ <span class="ruby-keyword kw">end</span>
61
+
62
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
63
+ <span class="ruby-keyword kw">yield</span>(<span class="ruby-identifier">choice</span>)
64
+ <span class="ruby-keyword kw">else</span>
65
+ <span class="ruby-identifier">choice</span>
66
+ <span class="ruby-keyword kw">end</span>
67
+ <span class="ruby-keyword kw">end</span></pre>
68
+ </body>
69
+ </html>
@@ -0,0 +1,47 @@
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>
7
+ <head>
8
+ <title>bingo! (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 361</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">bingo!</span>(<span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">options</span> = {})
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Array</span>
16
+ <span class="ruby-identifier">name</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">single_test</span><span class="ruby-operator">|</span>
17
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bingo!</span>(<span class="ruby-identifier">single_test</span>, <span class="ruby-identifier">options</span>)
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-keyword kw">else</span>
20
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">nil?</span>
21
+ <span class="ruby-comment cmt">#Score all participating tests</span>
22
+ <span class="ruby-identifier">participating_tests</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{Abingo.identity}&quot;</span>) <span class="ruby-operator">||</span> []
23
+ <span class="ruby-identifier">participating_tests</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">participating_test</span><span class="ruby-operator">|</span>
24
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">bingo!</span>(<span class="ruby-identifier">participating_test</span>, <span class="ruby-identifier">options</span>)
25
+ <span class="ruby-keyword kw">end</span>
26
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">#Could be a test name or conversion name.</span>
27
+ <span class="ruby-identifier">conversion_name</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot; &quot;</span>, <span class="ruby-value str">&quot;_&quot;</span>)
28
+ <span class="ruby-identifier">tests_listening_to_conversion</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::tests_listening_to_conversion#{conversion_name}&quot;</span>)
29
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tests_listening_to_conversion</span>
30
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">tests_listening_to_conversion</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
31
+ <span class="ruby-identifier">tests_listening_to_conversion</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">individual_test</span><span class="ruby-operator">|</span>
32
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">score_conversion!</span>(<span class="ruby-identifier">individual_test</span>.<span class="ruby-identifier">to_s</span>)
33
+ <span class="ruby-keyword kw">end</span>
34
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">tests_listening_to_conversion</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
35
+ <span class="ruby-identifier">test_name_str</span> = <span class="ruby-identifier">tests_listening_to_conversion</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">to_s</span>
36
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">score_conversion!</span>(<span class="ruby-identifier">test_name_str</span>)
37
+ <span class="ruby-keyword kw">end</span>
38
+ <span class="ruby-keyword kw">else</span>
39
+ <span class="ruby-comment cmt">#No tests listening for this conversion. Assume it is just a test name.</span>
40
+ <span class="ruby-identifier">test_name_str</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>
41
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">score_conversion!</span>(<span class="ruby-identifier">test_name_str</span>)
42
+ <span class="ruby-keyword kw">end</span>
43
+ <span class="ruby-keyword kw">end</span>
44
+ <span class="ruby-keyword kw">end</span>
45
+ <span class="ruby-keyword kw">end</span></pre>
46
+ </body>
47
+ </html>
@@ -0,0 +1,31 @@
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>
7
+ <head>
8
+ <title>participating_tests (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 394</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">participating_tests</span>(<span class="ruby-identifier">only_current</span> = <span class="ruby-keyword kw">true</span>)
15
+ <span class="ruby-identifier">identity</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">identity</span>
16
+ <span class="ruby-identifier">participating_tests</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{identity}&quot;</span>) <span class="ruby-operator">||</span> []
17
+ <span class="ruby-identifier">tests_and_alternatives</span> = <span class="ruby-identifier">participating_tests</span>.<span class="ruby-identifier">inject</span>({}) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">acc</span>, <span class="ruby-identifier">test_name</span><span class="ruby-operator">|</span>
18
+ <span class="ruby-identifier">alternatives_key</span> = <span class="ruby-node">&quot;Abingo::Experiment::#{test_name}::alternatives&quot;</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot; &quot;</span>,<span class="ruby-value str">&quot;_&quot;</span>)
19
+ <span class="ruby-identifier">alternatives</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">alternatives_key</span>)
20
+ <span class="ruby-identifier">acc</span>[<span class="ruby-identifier">test_name</span>] = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">find_alternative_for_user</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">alternatives</span>)
21
+ <span class="ruby-identifier">acc</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">only_current</span>)
24
+ <span class="ruby-identifier">tests_and_alternatives</span>.<span class="ruby-identifier">reject!</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
25
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::Experiment::short_circuit(#{key})&quot;</span>)
26
+ <span class="ruby-keyword kw">end</span>
27
+ <span class="ruby-keyword kw">end</span>
28
+ <span class="ruby-identifier">tests_and_alternatives</span>
29
+ <span class="ruby-keyword kw">end</span></pre>
30
+ </body>
31
+ </html>
@@ -0,0 +1,36 @@
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>
7
+ <head>
8
+ <title>human! (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 412</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">human!</span>
15
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-node">&quot;Abingo::is_human(#{Abingo.identity})&quot;</span>, {<span class="ruby-identifier">:expires_in</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">expires_in</span>(<span class="ruby-keyword kw">true</span>)}) <span class="ruby-keyword kw">do</span>
16
+ <span class="ruby-comment cmt">#Now that we know the user is human, score participation for all their tests. (Further participation will *not* be lazy evaluated.)</span>
17
+
18
+ <span class="ruby-comment cmt">#Score all tests which have been deferred.</span>
19
+ <span class="ruby-identifier">participating_tests</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{Abingo.identity}&quot;</span>) <span class="ruby-operator">||</span> []
20
+
21
+ <span class="ruby-comment cmt">#Refresh cache expiry for this user to match that of known humans.</span>
22
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-ivar">@@options</span>[<span class="ruby-identifier">:expires_in_for_bots</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">participating_tests</span>.<span class="ruby-identifier">blank?</span>)
23
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">write</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{Abingo.identity}&quot;</span>, <span class="ruby-identifier">participating_tests</span>, {<span class="ruby-identifier">:expires_in</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">expires_in</span>(<span class="ruby-keyword kw">true</span>)})
24
+ <span class="ruby-keyword kw">end</span>
25
+
26
+ <span class="ruby-identifier">participating_tests</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">test_name</span><span class="ruby-operator">|</span>
27
+ <span class="ruby-constant">Alternative</span>.<span class="ruby-identifier">score_participation</span>(<span class="ruby-identifier">test_name</span>)
28
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">conversions</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::conversions(#{Abingo.identity},#{test_name}&quot;</span>)
29
+ <span class="ruby-identifier">conversions</span>.<span class="ruby-identifier">times</span> { <span class="ruby-constant">Alternative</span>.<span class="ruby-identifier">score_conversion</span>(<span class="ruby-identifier">test_name</span>) }
30
+ <span class="ruby-keyword kw">end</span>
31
+ <span class="ruby-keyword kw">end</span>
32
+ <span class="ruby-keyword kw">true</span> <span class="ruby-comment cmt">#Marks this user as human in the cache.</span>
33
+ <span class="ruby-keyword kw">end</span>
34
+ <span class="ruby-keyword kw">end</span></pre>
35
+ </body>
36
+ </html>
@@ -0,0 +1,18 @@
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>
7
+ <head>
8
+ <title>is_human? (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 436</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_human?</span>
15
+ <span class="ruby-operator">!</span><span class="ruby-operator">!</span><span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::is_human(#{Abingo.identity})&quot;</span>)
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,36 @@
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>
7
+ <head>
8
+ <title>parse_alternatives (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 452</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_alternatives</span>(<span class="ruby-identifier">alternatives</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">alternatives</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Array</span>
16
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">alternatives</span>
17
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">alternatives</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>
18
+ <span class="ruby-keyword kw">return</span> (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">alternatives</span>).<span class="ruby-identifier">to_a</span>
19
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">alternatives</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Range</span>
20
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">alternatives</span>.<span class="ruby-identifier">to_a</span>
21
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">alternatives</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Hash</span>
22
+ <span class="ruby-identifier">alternatives_array</span> = []
23
+ <span class="ruby-identifier">alternatives</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
24
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Integer</span>
25
+ <span class="ruby-identifier">alternatives_array</span> <span class="ruby-operator">+=</span> [<span class="ruby-identifier">key</span>] <span class="ruby-operator">*</span> <span class="ruby-identifier">value</span>
26
+ <span class="ruby-keyword kw">else</span>
27
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;You gave a hash with #{key} =&gt; #{value} as an element. The value must be an integral weight.&quot;</span>
28
+ <span class="ruby-keyword kw">end</span>
29
+ <span class="ruby-keyword kw">end</span>
30
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">alternatives_array</span>
31
+ <span class="ruby-keyword kw">else</span>
32
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;I don't know how to turn [#{alternatives}] into an array of alternatives.&quot;</span>
33
+ <span class="ruby-keyword kw">end</span>
34
+ <span class="ruby-keyword kw">end</span></pre>
35
+ </body>
36
+ </html>
@@ -0,0 +1,22 @@
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>
7
+ <head>
8
+ <title>retrieve_alternatives (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 474</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">retrieve_alternatives</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">alternatives</span>)
15
+ <span class="ruby-identifier">cache_key</span> = <span class="ruby-node">&quot;Abingo::Experiment::#{test_name}::alternatives&quot;</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">&quot; &quot;</span>,<span class="ruby-value str">&quot;_&quot;</span>)
16
+ <span class="ruby-identifier">alternative_array</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">cache_key</span>) <span class="ruby-keyword kw">do</span>
17
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">parse_alternatives</span>(<span class="ruby-identifier">alternatives</span>)
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-identifier">alternative_array</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,21 @@
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>
7
+ <head>
8
+ <title>find_alternative_for_user (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 482</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">find_alternative_for_user</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">alternatives</span>)
15
+ <span class="ruby-identifier">alternatives_array</span> = <span class="ruby-identifier">retrieve_alternatives</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">alternatives</span>)
16
+ <span class="ruby-identifier">selected_alternative</span> = <span class="ruby-identifier">alternatives_array</span>[<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">modulo_choice</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">alternatives_array</span>.<span class="ruby-identifier">size</span>)]
17
+ <span class="ruby-constant">ABingoCampingPlugin</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;find_alternative_for_user(#{test_name}, #{alternatives}, #{self.identity}) &gt; #{selected_alternative}&quot;</span>
18
+ <span class="ruby-identifier">selected_alternative</span>
19
+ <span class="ruby-keyword kw">end</span></pre>
20
+ </body>
21
+ </html>
@@ -0,0 +1,18 @@
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>
7
+ <head>
8
+ <title>modulo_choice (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 492</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">modulo_choice</span>(<span class="ruby-identifier">test_name</span>, <span class="ruby-identifier">choices_count</span>)
15
+ <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">MD5</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">salt</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">test_name</span> <span class="ruby-operator">+</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">identity</span>.<span class="ruby-identifier">to_s</span>).<span class="ruby-identifier">to_i</span>(<span class="ruby-value">16</span>) <span class="ruby-operator">%</span> <span class="ruby-identifier">choices_count</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,39 @@
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>
7
+ <head>
8
+ <title>score_conversion! (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 496</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">score_conversion!</span>(<span class="ruby-identifier">test_name</span>)
15
+ <span class="ruby-identifier">test_name</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">&quot; &quot;</span>, <span class="ruby-value str">&quot;_&quot;</span>)
16
+ <span class="ruby-identifier">participating_tests</span> = <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-node">&quot;Abingo::participating_tests::#{Abingo.identity}&quot;</span>) <span class="ruby-operator">||</span> []
17
+ <span class="ruby-constant">ABingoCampingPlugin</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;score_conversion (#{test_name}) participating_tests=#{participating_tests.inspect} flag=#{participating_tests.include?(test_name)} options=#{options.inspect}&quot;</span>
18
+
19
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:assume_participation</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">participating_tests</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">test_name</span>)
20
+ <span class="ruby-identifier">cache_key</span> = <span class="ruby-node">&quot;Abingo::conversions(#{Abingo.identity},#{test_name}&quot;</span>
21
+ <span class="ruby-constant">ABingoCampingPlugin</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;score_conversion cache_key=#{cache_key}&quot;</span>
22
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:multiple_conversions</span>] <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">cache_key</span>)
23
+ <span class="ruby-constant">ABingoCampingPlugin</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;score_conversion is human=#{!options[:count_humans_only] || Abingo.is_human?}&quot;</span>
24
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:count_humans_only</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">is_human?</span>
25
+ <span class="ruby-constant">ABingoCampingPlugin</span><span class="ruby-operator">::</span><span class="ruby-constant">Models</span><span class="ruby-operator">::</span><span class="ruby-constant">Alternative</span>.<span class="ruby-identifier">score_conversion</span>(<span class="ruby-identifier">test_name</span>) <span class="ruby-comment cmt"># Camping-specific</span>
26
+ <span class="ruby-keyword kw">end</span>
27
+
28
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">cache_key</span>)
29
+ <span class="ruby-constant">ABingoCampingPlugin</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;score_conversion increment #{cache_key}&quot;</span>
30
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">increment</span>(<span class="ruby-identifier">cache_key</span>)
31
+ <span class="ruby-keyword kw">else</span>
32
+ <span class="ruby-constant">ABingoCampingPlugin</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">&quot;score_conversion write #{cache_key}&quot;</span>
33
+ <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">cache</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">cache_key</span>, <span class="ruby-value">1</span>)
34
+ <span class="ruby-keyword kw">end</span>
35
+ <span class="ruby-keyword kw">end</span>
36
+ <span class="ruby-keyword kw">end</span>
37
+ <span class="ruby-keyword kw">end</span></pre>
38
+ </body>
39
+ </html>
@@ -0,0 +1,25 @@
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>
7
+ <head>
8
+ <title>expires_in (Abingo)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/camping-abingo.rb, line 521</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">expires_in</span>(<span class="ruby-identifier">known_human</span> = <span class="ruby-keyword kw">false</span>)
15
+ <span class="ruby-identifier">expires_in</span> = <span class="ruby-keyword kw">nil</span>
16
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-ivar">@@options</span>[<span class="ruby-identifier">:expires_in</span>])
17
+ <span class="ruby-identifier">expires_in</span> = <span class="ruby-ivar">@@options</span>[<span class="ruby-identifier">:expires_in</span>]
18
+ <span class="ruby-keyword kw">end</span>
19
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-ivar">@@options</span>[<span class="ruby-identifier">:count_humans_only</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@@options</span>[<span class="ruby-identifier">:expires_in_for_bots</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">known_human</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Abingo</span>.<span class="ruby-identifier">is_human?</span>))
20
+ <span class="ruby-identifier">expires_in</span> = <span class="ruby-ivar">@@options</span>[<span class="ruby-identifier">:expires_in_for_bots</span>]
21
+ <span class="ruby-keyword kw">end</span>
22
+ <span class="ruby-identifier">expires_in</span>
23
+ <span class="ruby-keyword kw">end</span></pre>
24
+ </body>
25
+ </html>