simple-service 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.rubocop.yml +10 -2
  4. data/Gemfile +3 -1
  5. data/Makefile +7 -11
  6. data/README.md +67 -2
  7. data/TODO.txt +3 -0
  8. data/VERSION +1 -1
  9. data/doc/Simple/Service/Action/Comment/Extractor.html +347 -0
  10. data/doc/Simple/Service/Action/Comment.html +451 -0
  11. data/doc/Simple/Service/Action/MethodReflection.html +285 -0
  12. data/doc/Simple/Service/Action/Parameter.html +816 -0
  13. data/doc/Simple/Service/Action.html +923 -0
  14. data/doc/Simple/Service/ArgumentError.html +128 -0
  15. data/doc/Simple/Service/ClassMethods.html +187 -0
  16. data/doc/Simple/Service/Context.html +379 -0
  17. data/doc/Simple/Service/ContextMissingError.html +124 -0
  18. data/doc/Simple/Service/ContextReadOnlyError.html +206 -0
  19. data/doc/Simple/Service/ExtraArguments.html +428 -0
  20. data/doc/Simple/Service/GemHelper.html +190 -0
  21. data/doc/Simple/Service/MissingArguments.html +426 -0
  22. data/doc/Simple/Service/NoSuchAction.html +433 -0
  23. data/doc/Simple/Service.html +865 -0
  24. data/doc/Simple.html +117 -0
  25. data/doc/_index.html +274 -0
  26. data/doc/class_list.html +51 -0
  27. data/doc/css/common.css +1 -0
  28. data/doc/css/full_list.css +58 -0
  29. data/doc/css/style.css +496 -0
  30. data/doc/file.README.html +146 -0
  31. data/doc/file.TODO.html +70 -0
  32. data/doc/file_list.html +61 -0
  33. data/doc/frames.html +17 -0
  34. data/doc/index.html +146 -0
  35. data/doc/js/app.js +303 -0
  36. data/doc/js/full_list.js +216 -0
  37. data/doc/js/jquery.js +4 -0
  38. data/doc/method_list.html +483 -0
  39. data/doc/top-level-namespace.html +110 -0
  40. data/lib/simple/service/action/comment.rb +2 -2
  41. data/lib/simple/service/action/method_reflection.rb +1 -1
  42. data/lib/simple/service/action/parameter.rb +1 -1
  43. data/lib/simple/service/action.rb +34 -46
  44. data/lib/simple/service/errors.rb +4 -3
  45. data/lib/simple/service/version.rb +2 -2
  46. data/lib/simple/service.rb +109 -34
  47. data/lib/simple/workflow/context.rb +105 -0
  48. data/lib/simple/workflow/current_context.rb +33 -0
  49. data/lib/simple/workflow/reloader.rb +84 -0
  50. data/lib/simple/workflow/rspec_helper.rb +15 -0
  51. data/lib/simple/workflow.rb +96 -0
  52. data/lib/simple-workflow.rb +3 -0
  53. data/scripts/test +2 -0
  54. data/simple-service.gemspec +1 -0
  55. data/spec/simple/service/action_invoke3_spec.rb +258 -0
  56. data/spec/simple/service/action_invoke_spec.rb +49 -87
  57. data/spec/simple/service/service_spec.rb +40 -32
  58. data/spec/simple/workflow/context_spec.rb +90 -0
  59. data/spec/simple/workflow/current_context_spec.rb +41 -0
  60. data/spec/simple/workflow/reloader_spec/example1.rb +10 -0
  61. data/spec/simple/workflow/reloader_spec/example2.rb +7 -0
  62. data/spec/simple/workflow/reloader_spec.rb +48 -0
  63. data/spec/spec_helper.rb +2 -1
  64. data/spec/support/spec_services.rb +8 -2
  65. metadata +74 -9
  66. data/lib/simple/service/action/indie_hash.rb +0 -37
  67. data/lib/simple/service/context.rb +0 -94
  68. data/spec/simple/service/action_invoke2_spec.rb +0 -166
  69. data/spec/simple/service/context_spec.rb +0 -69
@@ -0,0 +1,285 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: Simple::Service::Action::MethodReflection
8
+
9
+ &mdash; Documentation by YARD 0.9.20
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "Simple::Service::Action::MethodReflection";
19
+ relpath = '../../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../../_index.html">Index (M)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../Simple.html" title="Simple (module)">Simple</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Service.html" title="Simple::Service (module)">Service</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Action.html" title="Simple::Service::Action (class)">Action</a></span></span>
41
+ &raquo;
42
+ <span class="title">MethodReflection</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: Simple::Service::Action::MethodReflection
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+ <dl>
73
+ <dt>Extended by:</dt>
74
+ <dd><span class='object_link'><a href="" title="Simple::Service::Action::MethodReflection (module)">MethodReflection</a></span></dd>
75
+ </dl>
76
+
77
+
78
+
79
+
80
+
81
+
82
+ <dl>
83
+ <dt>Included in:</dt>
84
+ <dd><span class='object_link'><a href="" title="Simple::Service::Action::MethodReflection (module)">MethodReflection</a></span></dd>
85
+ </dl>
86
+
87
+
88
+
89
+ <dl>
90
+ <dt>Defined in:</dt>
91
+ <dd>lib/simple/service/action/method_reflection.rb</dd>
92
+ </dl>
93
+
94
+ </div>
95
+
96
+ <h2>Overview</h2><div class="docstring">
97
+ <div class="discussion">
98
+
99
+ <p>rubocop:disable Metrics/AbcSize</p>
100
+
101
+
102
+ </div>
103
+ </div>
104
+ <div class="tags">
105
+
106
+
107
+ </div>
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ <h2>
116
+ Instance Method Summary
117
+ <small><a href="#" class="summary_toggle">collapse</a></small>
118
+ </h2>
119
+
120
+ <ul class="summary">
121
+
122
+ <li class="public ">
123
+ <span class="summary_signature">
124
+
125
+ <a href="#parameters-instance_method" title="#parameters (instance method)">#<strong>parameters</strong>(service, method_id) &#x21d2; Object </a>
126
+
127
+
128
+
129
+ </span>
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+ <span class="summary_desc"><div class='inline'>
140
+ <p>returns an array with entries like the following:.</p>
141
+ </div></span>
142
+
143
+ </li>
144
+
145
+
146
+ </ul>
147
+
148
+
149
+
150
+
151
+ <div id="instance_method_details" class="method_details_list">
152
+ <h2>Instance Method Details</h2>
153
+
154
+
155
+ <div class="method_details first">
156
+ <h3 class="signature first" id="parameters-instance_method">
157
+
158
+ #<strong>parameters</strong>(service, method_id) &#x21d2; <tt>Object</tt>
159
+
160
+
161
+
162
+
163
+
164
+ </h3><div class="docstring">
165
+ <div class="discussion">
166
+
167
+ <p>returns an array with entries like the following:</p>
168
+
169
+ <pre class="code ruby"><code class="ruby">[ :key, name, default_value ]
170
+ [ :keyreq, name [, nil ] ]
171
+ [ :req, name [, nil ] ]
172
+ [ :opt, name [, nil ] ]
173
+ [ :rest, name [, nil ] ]
174
+ </code></pre>
175
+
176
+
177
+ </div>
178
+ </div>
179
+ <div class="tags">
180
+
181
+
182
+ </div><table class="source_code">
183
+ <tr>
184
+ <td>
185
+ <pre class="lines">
186
+
187
+
188
+ 15
189
+ 16
190
+ 17
191
+ 18
192
+ 19
193
+ 20
194
+ 21
195
+ 22
196
+ 23
197
+ 24
198
+ 25
199
+ 26
200
+ 27
201
+ 28
202
+ 29
203
+ 30
204
+ 31
205
+ 32
206
+ 33
207
+ 34
208
+ 35
209
+ 36
210
+ 37
211
+ 38
212
+ 39
213
+ 40
214
+ 41
215
+ 42
216
+ 43
217
+ 44
218
+ 45
219
+ 46
220
+ 47
221
+ 48
222
+ 49
223
+ 50
224
+ 51
225
+ 52</pre>
226
+ </td>
227
+ <td>
228
+ <pre class="code"><span class="info file"># File 'lib/simple/service/action/method_reflection.rb', line 15</span>
229
+
230
+ <span class='kw'>def</span> <span class='id identifier rubyid_parameters'>parameters</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='comma'>,</span> <span class='id identifier rubyid_method_id'>method_id</span><span class='rparen'>)</span>
231
+ <span class='id identifier rubyid_method'>method</span> <span class='op'>=</span> <span class='id identifier rubyid_service'>service</span><span class='period'>.</span><span class='id identifier rubyid_instance_method'>instance_method</span><span class='lparen'>(</span><span class='id identifier rubyid_method_id'>method_id</span><span class='rparen'>)</span>
232
+ <span class='id identifier rubyid_parameters'>parameters</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span><span class='period'>.</span><span class='id identifier rubyid_parameters'>parameters</span>
233
+
234
+ <span class='comment'># method parameters with a :key mode are optional named arguments. We only
235
+ </span> <span class='comment'># support defaults for those - if there are none we abort here already.
236
+ </span> <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_parameters'>parameters</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='op'>|</span> <span class='id identifier rubyid_name'>name</span> <span class='kw'>if</span> <span class='id identifier rubyid_mode'>mode</span> <span class='op'>==</span> <span class='symbol'>:key</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
237
+ <span class='kw'>return</span> <span class='id identifier rubyid_parameters'>parameters</span> <span class='kw'>if</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
238
+
239
+ <span class='comment'># We are now doing a fake call to the method, with a minimal viable set of
240
+ </span> <span class='comment'># arguments, to let the ruby runtime fill in default values for arguments.
241
+ </span> <span class='comment'># We do not, however, let the call complete. Instead we use a TracePoint to
242
+ </span> <span class='comment'># abort as soon as the method is called, and use the its binding to determine
243
+ </span> <span class='comment'># the default values.
244
+ </span>
245
+ <span class='id identifier rubyid_fake_recipient'>fake_recipient</span> <span class='op'>=</span> <span class='const'>Object</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
246
+ <span class='id identifier rubyid_fake_call_args'>fake_call_args</span> <span class='op'>=</span> <span class='id identifier rubyid_minimal_arguments'>minimal_arguments</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
247
+
248
+ <span class='id identifier rubyid_trace_point'>trace_point</span> <span class='op'>=</span> <span class='const'>TracePoint</span><span class='period'>.</span><span class='id identifier rubyid_trace'>trace</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_tp'>tp</span><span class='op'>|</span>
249
+ <span class='id identifier rubyid_throw'>throw</span> <span class='symbol'>:received_fake_call</span><span class='comma'>,</span> <span class='id identifier rubyid_tp'>tp</span><span class='period'>.</span><span class='id identifier rubyid_binding'>binding</span> <span class='kw'>if</span> <span class='id identifier rubyid_tp'>tp</span><span class='period'>.</span><span class='id identifier rubyid_defined_class'>defined_class</span> <span class='op'>==</span> <span class='id identifier rubyid_service'>service</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_tp'>tp</span><span class='period'>.</span><span class='id identifier rubyid_method_id'>method_id</span> <span class='op'>==</span> <span class='id identifier rubyid_method_id'>method_id</span>
250
+ <span class='kw'>end</span>
251
+
252
+ <span class='id identifier rubyid_bnd'>bnd</span> <span class='op'>=</span> <span class='id identifier rubyid_catch'>catch</span><span class='lparen'>(</span><span class='symbol'>:received_fake_call</span><span class='rparen'>)</span> <span class='kw'>do</span>
253
+ <span class='id identifier rubyid_fake_recipient'>fake_recipient</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method_id'>method_id</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_fake_call_args'>fake_call_args</span><span class='rparen'>)</span>
254
+ <span class='kw'>end</span>
255
+
256
+ <span class='id identifier rubyid_trace_point'>trace_point</span><span class='period'>.</span><span class='id identifier rubyid_disable'>disable</span>
257
+
258
+ <span class='comment'># extract default values from the received binding, and merge with the
259
+ </span> <span class='comment'># parameters array.
260
+ </span> <span class='id identifier rubyid_default_values'>default_values</span> <span class='op'>=</span> <span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key_parameter'>key_parameter</span><span class='comma'>,</span> <span class='id identifier rubyid_hsh'>hsh</span><span class='op'>|</span>
261
+ <span class='id identifier rubyid_hsh'>hsh</span><span class='lbracket'>[</span><span class='id identifier rubyid_key_parameter'>key_parameter</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_bnd'>bnd</span><span class='period'>.</span><span class='id identifier rubyid_local_variable_get'>local_variable_get</span><span class='lparen'>(</span><span class='id identifier rubyid_key_parameter'>key_parameter</span><span class='rparen'>)</span>
262
+ <span class='kw'>end</span>
263
+
264
+ <span class='id identifier rubyid_parameters'>parameters</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='op'>|</span>
265
+ <span class='lbracket'>[</span><span class='id identifier rubyid_mode'>mode</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_default_values'>default_values</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
266
+ <span class='kw'>end</span>
267
+ <span class='kw'>end</span></pre>
268
+ </td>
269
+ </tr>
270
+ </table>
271
+ </div>
272
+
273
+ </div>
274
+
275
+ </div>
276
+
277
+ <div id="footer">
278
+ Generated on Wed Dec 4 22:57:13 2019 by
279
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
280
+ 0.9.20 (ruby-2.5.1).
281
+ </div>
282
+
283
+ </div>
284
+ </body>
285
+ </html>