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.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.rubocop.yml +10 -2
- data/Gemfile +3 -1
- data/Makefile +7 -11
- data/README.md +67 -2
- data/TODO.txt +3 -0
- data/VERSION +1 -1
- data/doc/Simple/Service/Action/Comment/Extractor.html +347 -0
- data/doc/Simple/Service/Action/Comment.html +451 -0
- data/doc/Simple/Service/Action/MethodReflection.html +285 -0
- data/doc/Simple/Service/Action/Parameter.html +816 -0
- data/doc/Simple/Service/Action.html +923 -0
- data/doc/Simple/Service/ArgumentError.html +128 -0
- data/doc/Simple/Service/ClassMethods.html +187 -0
- data/doc/Simple/Service/Context.html +379 -0
- data/doc/Simple/Service/ContextMissingError.html +124 -0
- data/doc/Simple/Service/ContextReadOnlyError.html +206 -0
- data/doc/Simple/Service/ExtraArguments.html +428 -0
- data/doc/Simple/Service/GemHelper.html +190 -0
- data/doc/Simple/Service/MissingArguments.html +426 -0
- data/doc/Simple/Service/NoSuchAction.html +433 -0
- data/doc/Simple/Service.html +865 -0
- data/doc/Simple.html +117 -0
- data/doc/_index.html +274 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +146 -0
- data/doc/file.TODO.html +70 -0
- data/doc/file_list.html +61 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +146 -0
- data/doc/js/app.js +303 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +483 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/simple/service/action/comment.rb +2 -2
- data/lib/simple/service/action/method_reflection.rb +1 -1
- data/lib/simple/service/action/parameter.rb +1 -1
- data/lib/simple/service/action.rb +34 -46
- data/lib/simple/service/errors.rb +4 -3
- data/lib/simple/service/version.rb +2 -2
- data/lib/simple/service.rb +109 -34
- data/lib/simple/workflow/context.rb +105 -0
- data/lib/simple/workflow/current_context.rb +33 -0
- data/lib/simple/workflow/reloader.rb +84 -0
- data/lib/simple/workflow/rspec_helper.rb +15 -0
- data/lib/simple/workflow.rb +96 -0
- data/lib/simple-workflow.rb +3 -0
- data/scripts/test +2 -0
- data/simple-service.gemspec +1 -0
- data/spec/simple/service/action_invoke3_spec.rb +258 -0
- data/spec/simple/service/action_invoke_spec.rb +49 -87
- data/spec/simple/service/service_spec.rb +40 -32
- data/spec/simple/workflow/context_spec.rb +90 -0
- data/spec/simple/workflow/current_context_spec.rb +41 -0
- data/spec/simple/workflow/reloader_spec/example1.rb +10 -0
- data/spec/simple/workflow/reloader_spec/example2.rb +7 -0
- data/spec/simple/workflow/reloader_spec.rb +48 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/support/spec_services.rb +8 -2
- metadata +74 -9
- data/lib/simple/service/action/indie_hash.rb +0 -37
- data/lib/simple/service/context.rb +0 -94
- data/spec/simple/service/action_invoke2_spec.rb +0 -166
- data/spec/simple/service/context_spec.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 706a23842071b121c2b6298b7bdaec0b43c4b110125c2c09011537541c4f5b9b
|
4
|
+
data.tar.gz: 9ad938ece973392233c554053aa1906da0ea799722d527cb15870913ef108070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68563b2c8d9c955049814f90d31b765a30c077553d7199287c4d0117d7d1ed0eb2ce71674195820d482de52bd2f53c70dbb798549d2bf6a7c35ef2f149de3b56
|
7
|
+
data.tar.gz: ccb9fc69a58b3a9f7225e60e1b8120dced8ec58802483ee4151cb6a0fc71c20b5b3f9b4393b6b9c09de2ec18d3c09bfbdac16f341669ac055b3daa9b31b98ae0
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 2.7
|
3
4
|
Exclude:
|
4
5
|
- 'spec/**/*'
|
5
6
|
- 'test/**/*'
|
@@ -14,7 +15,7 @@ Metrics/BlockLength:
|
|
14
15
|
Exclude:
|
15
16
|
- 'spec/**/*'
|
16
17
|
|
17
|
-
|
18
|
+
Layout/LineLength:
|
18
19
|
Max: 140
|
19
20
|
|
20
21
|
Metrics/MethodLength:
|
@@ -98,3 +99,10 @@ Style/DoubleNegation:
|
|
98
99
|
|
99
100
|
Style/ParallelAssignment:
|
100
101
|
Enabled: false
|
102
|
+
|
103
|
+
Style/CommentedKeyword:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
Style/AccessorGrouping:
|
107
|
+
Enabled: false
|
108
|
+
|
data/Gemfile
CHANGED
data/Makefile
CHANGED
@@ -3,14 +3,10 @@
|
|
3
3
|
test:
|
4
4
|
rspec
|
5
5
|
|
6
|
-
.PHONY: doc
|
7
|
-
doc:
|
8
|
-
|
9
|
-
doc
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
lib/simple/service/action.rb \
|
14
|
-
lib/simple/service/context.rb \
|
15
|
-
lib/simple/service/errors.rb \
|
16
|
-
lib/simple/service/version.rb
|
6
|
+
.PHONY: doc
|
7
|
+
doc: todo
|
8
|
+
rm -rf doc/*
|
9
|
+
yard doc -o doc - TODO.txt
|
10
|
+
|
11
|
+
todo:
|
12
|
+
lentil . -f comp | tee TODO.txt
|
data/README.md
CHANGED
@@ -1,3 +1,68 @@
|
|
1
|
-
# simple-service –
|
1
|
+
# simple-service – at your service!
|
2
2
|
|
3
|
-
|
3
|
+
The `simple-service` ruby gem helps you turn your ruby source code into *"services".* A service is a module which provides interfaces to one or more methods (*"actions"*) that implement business logic.
|
4
|
+
|
5
|
+
While one could, of course, call any such method any way one wants, this gem lets you
|
6
|
+
|
7
|
+
- discover available services (their names, their parameters (name, type, default values), comments - see `Simple::Service.actions`;
|
8
|
+
- an interface to "run" (or "execute") a service, with separation from any other parallel runs - see `Simple::Service.invoke` and `Simple::Service.invoke2`;
|
9
|
+
- a semi-constant "*environment*" for the duration of an execution;
|
10
|
+
- ![TODO](https://badgen.net/badge/TODO/high?color=red) a normalized interface to check whether or not a specific service is allowed to run based on the current context.
|
11
|
+
|
12
|
+
These features allow *simple-service* to serve as a building block for other tools. It is currently in used in:
|
13
|
+
|
14
|
+
- *simple-httpd*: a simple web server
|
15
|
+
- *simple-cli*: the best way to build a ruby CLI.
|
16
|
+
|
17
|
+
## Example
|
18
|
+
|
19
|
+
### Defining a service
|
20
|
+
|
21
|
+
A service module can define one or more services. The following example defines a single service:
|
22
|
+
|
23
|
+
# A service which constructs universes with different physics.
|
24
|
+
module GodMode
|
25
|
+
include Simple::Service
|
26
|
+
|
27
|
+
# Build a universe.
|
28
|
+
#
|
29
|
+
# This comment will become part of the full description of the
|
30
|
+
# "build_universe" service
|
31
|
+
def build_universe(name, c: , pi: 3.14, e: 2.781)
|
32
|
+
# at this point I realize that *I* am not God.
|
33
|
+
|
34
|
+
42 # Best try approach
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
### Running a service
|
39
|
+
|
40
|
+
To run the service one uses one of two different methods. If you have an **anonymous array** of arguments - think command line interface - you would call it like this:
|
41
|
+
|
42
|
+
Simple::Service.invoke GodMode, :build_universe,
|
43
|
+
"My Universe",
|
44
|
+
c: 3e8
|
45
|
+
|
46
|
+
If the calling site, however, has **named arguments** (in a Hash), one would invoke a service using `invoke2`. This is used for HTTPD integration (with `simple-httpd`.)
|
47
|
+
|
48
|
+
args = { name: "My Universe", c: 299792458}
|
49
|
+
Simple::Service.invoke2 GodMode,
|
50
|
+
:build_universe,
|
51
|
+
args: args
|
52
|
+
|
53
|
+
Note that you must set a context during the execution; this is done by `with_context`. A `nil` context is a valid value which describes an empty context.
|
54
|
+
|
55
|
+
A full example could therefore look like:
|
56
|
+
|
57
|
+
Simple::Service.with_context(nil) do
|
58
|
+
args = { name: "My Universe", c: 299792458}
|
59
|
+
Simple::Service.invoke2 GodMode,
|
60
|
+
:build_universe,
|
61
|
+
args: args
|
62
|
+
end
|
63
|
+
|
64
|
+
## History
|
65
|
+
|
66
|
+
Historically, the `simple-cli` gem implemented an easy way to build a CLI application, and therefore needed a way to reflect on existing code to determine which methods to call, which arguments they support etc. Also, the `postjob` job queue calls a specific method based on its name and an arguments Array or Hash, which is being read from a database. Finally, when I tried to extent `postjob` with a HTTP interface I discovered that a similar feature would again be extremely useful.
|
67
|
+
|
68
|
+
I therefore extracted these features into a standalone gem.
|
data/TODO.txt
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,347 @@
|
|
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::Comment::Extractor
|
8
|
+
|
9
|
+
— 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::Comment::Extractor";
|
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 (E)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../../../Simple.html" title="Simple (module)">Simple</a></span></span> » <span class='title'><span class='object_link'><a href="../../../Service.html" title="Simple::Service (module)">Service</a></span></span> » <span class='title'><span class='object_link'><a href="../../Action.html" title="Simple::Service::Action (class)">Action</a></span></span> » <span class='title'><span class='object_link'><a href="../Comment.html" title="Simple::Service::Action::Comment (class)">Comment</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Extractor</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::Comment::Extractor
|
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::Comment::Extractor (module)">Extractor</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::Comment::Extractor (module)">Extractor</a></span></dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<dl>
|
90
|
+
<dt>Defined in:</dt>
|
91
|
+
<dd>lib/simple/service/action/comment.rb</dd>
|
92
|
+
</dl>
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
<h2>
|
105
|
+
Instance Method Summary
|
106
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
107
|
+
</h2>
|
108
|
+
|
109
|
+
<ul class="summary">
|
110
|
+
|
111
|
+
<li class="public ">
|
112
|
+
<span class="summary_signature">
|
113
|
+
|
114
|
+
<a href="#_parse_source-instance_method" title="#_parse_source (instance method)">#<strong>_parse_source</strong>(file) ⇒ Object </a>
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
</span>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
129
|
+
|
130
|
+
</li>
|
131
|
+
|
132
|
+
|
133
|
+
<li class="public ">
|
134
|
+
<span class="summary_signature">
|
135
|
+
|
136
|
+
<a href="#extract_comment_lines-instance_method" title="#extract_comment_lines (instance method)">#<strong>extract_comment_lines</strong>(file:, before_line:) ⇒ Object </a>
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
</span>
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
151
|
+
|
152
|
+
</li>
|
153
|
+
|
154
|
+
|
155
|
+
<li class="public ">
|
156
|
+
<span class="summary_signature">
|
157
|
+
|
158
|
+
<a href="#parse_source-instance_method" title="#parse_source (instance method)">#<strong>parse_source</strong>(file) ⇒ Object </a>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
</span>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
<span class="summary_desc"><div class='inline'>
|
173
|
+
<p>reads the source a file and turns each non-comment into :code and each comment into a string without the leading comment markup.</p>
|
174
|
+
</div></span>
|
175
|
+
|
176
|
+
</li>
|
177
|
+
|
178
|
+
|
179
|
+
</ul>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<div id="instance_method_details" class="method_details_list">
|
185
|
+
<h2>Instance Method Details</h2>
|
186
|
+
|
187
|
+
|
188
|
+
<div class="method_details first">
|
189
|
+
<h3 class="signature first" id="_parse_source-instance_method">
|
190
|
+
|
191
|
+
#<strong>_parse_source</strong>(file) ⇒ <tt>Object</tt>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
</h3><table class="source_code">
|
198
|
+
<tr>
|
199
|
+
<td>
|
200
|
+
<pre class="lines">
|
201
|
+
|
202
|
+
|
203
|
+
27
|
204
|
+
28
|
205
|
+
29
|
206
|
+
30
|
207
|
+
31
|
208
|
+
32
|
209
|
+
33
|
210
|
+
34</pre>
|
211
|
+
</td>
|
212
|
+
<td>
|
213
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service/action/comment.rb', line 27</span>
|
214
|
+
|
215
|
+
<span class='kw'>def</span> <span class='id identifier rubyid__parse_source'>_parse_source</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
|
216
|
+
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_readlines'>readlines</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</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_line'>line</span><span class='op'>|</span>
|
217
|
+
<span class='kw'>case</span> <span class='id identifier rubyid_line'>line</span>
|
218
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\s*# ?(.*)$</span><span class='regexp_end'>/</span></span> <span class='kw'>then</span> <span class='backref'>$1</span>
|
219
|
+
<span class='kw'>when</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\s*end</span><span class='regexp_end'>/</span></span> <span class='kw'>then</span> <span class='symbol'>:end</span>
|
220
|
+
<span class='kw'>end</span>
|
221
|
+
<span class='kw'>end</span>
|
222
|
+
<span class='kw'>end</span></pre>
|
223
|
+
</td>
|
224
|
+
</tr>
|
225
|
+
</table>
|
226
|
+
</div>
|
227
|
+
|
228
|
+
<div class="method_details ">
|
229
|
+
<h3 class="signature " id="extract_comment_lines-instance_method">
|
230
|
+
|
231
|
+
#<strong>extract_comment_lines</strong>(file:, before_line:) ⇒ <tt>Object</tt>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
</h3><table class="source_code">
|
238
|
+
<tr>
|
239
|
+
<td>
|
240
|
+
<pre class="lines">
|
241
|
+
|
242
|
+
|
243
|
+
36
|
244
|
+
37
|
245
|
+
38
|
246
|
+
39
|
247
|
+
40
|
248
|
+
41
|
249
|
+
42
|
250
|
+
43
|
251
|
+
44
|
252
|
+
45
|
253
|
+
46
|
254
|
+
47
|
255
|
+
48
|
256
|
+
49
|
257
|
+
50
|
258
|
+
51
|
259
|
+
52
|
260
|
+
53
|
261
|
+
54
|
262
|
+
55</pre>
|
263
|
+
</td>
|
264
|
+
<td>
|
265
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service/action/comment.rb', line 36</span>
|
266
|
+
|
267
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_extract_comment_lines'>extract_comment_lines</span><span class='lparen'>(</span><span class='label'>file:</span><span class='comma'>,</span> <span class='label'>before_line:</span><span class='rparen'>)</span>
|
268
|
+
<span class='id identifier rubyid_parsed_source'>parsed_source</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_source'>parse_source</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
|
269
|
+
|
270
|
+
<span class='comment'># go down from before_line until we see a line which is either a comment
|
271
|
+
</span> <span class='comment'># or an :end. Note that the line at before_line-1 should be the first
|
272
|
+
</span> <span class='comment'># line of the method definition in question.
|
273
|
+
</span> <span class='id identifier rubyid_last_line'>last_line</span> <span class='op'>=</span> <span class='id identifier rubyid_before_line'>before_line</span> <span class='op'>-</span> <span class='int'>1</span>
|
274
|
+
<span class='id identifier rubyid_last_line'>last_line</span> <span class='op'>-=</span> <span class='int'>1</span> <span class='kw'>while</span> <span class='id identifier rubyid_last_line'>last_line</span> <span class='op'>>=</span> <span class='int'>0</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid_parsed_source'>parsed_source</span><span class='lbracket'>[</span><span class='id identifier rubyid_last_line'>last_line</span><span class='rbracket'>]</span>
|
275
|
+
|
276
|
+
<span class='id identifier rubyid_first_line'>first_line</span> <span class='op'>=</span> <span class='id identifier rubyid_last_line'>last_line</span>
|
277
|
+
<span class='id identifier rubyid_first_line'>first_line</span> <span class='op'>-=</span> <span class='int'>1</span> <span class='kw'>while</span> <span class='id identifier rubyid_first_line'>first_line</span> <span class='op'>>=</span> <span class='int'>0</span> <span class='op'>&&</span> <span class='id identifier rubyid_parsed_source'>parsed_source</span><span class='lbracket'>[</span><span class='id identifier rubyid_first_line'>first_line</span><span class='rbracket'>]</span>
|
278
|
+
<span class='id identifier rubyid_first_line'>first_line</span> <span class='op'>+=</span> <span class='int'>1</span>
|
279
|
+
|
280
|
+
<span class='id identifier rubyid_comments'>comments</span> <span class='op'>=</span> <span class='id identifier rubyid_parsed_source'>parsed_source</span><span class='lbracket'>[</span><span class='id identifier rubyid_first_line'>first_line</span><span class='op'>..</span><span class='id identifier rubyid_last_line'>last_line</span><span class='rbracket'>]</span>
|
281
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_comments'>comments</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='symbol'>:end</span><span class='rparen'>)</span>
|
282
|
+
<span class='lbracket'>[</span><span class='rbracket'>]</span>
|
283
|
+
<span class='kw'>else</span>
|
284
|
+
<span class='id identifier rubyid_parsed_source'>parsed_source</span><span class='lbracket'>[</span><span class='id identifier rubyid_first_line'>first_line</span><span class='op'>..</span><span class='id identifier rubyid_last_line'>last_line</span><span class='rbracket'>]</span>
|
285
|
+
<span class='kw'>end</span>
|
286
|
+
<span class='kw'>end</span></pre>
|
287
|
+
</td>
|
288
|
+
</tr>
|
289
|
+
</table>
|
290
|
+
</div>
|
291
|
+
|
292
|
+
<div class="method_details ">
|
293
|
+
<h3 class="signature " id="parse_source-instance_method">
|
294
|
+
|
295
|
+
#<strong>parse_source</strong>(file) ⇒ <tt>Object</tt>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
</h3><div class="docstring">
|
302
|
+
<div class="discussion">
|
303
|
+
|
304
|
+
<p>reads the source a file and turns each non-comment into :code and each comment into a string without the leading comment markup.</p>
|
305
|
+
|
306
|
+
|
307
|
+
</div>
|
308
|
+
</div>
|
309
|
+
<div class="tags">
|
310
|
+
|
311
|
+
|
312
|
+
</div><table class="source_code">
|
313
|
+
<tr>
|
314
|
+
<td>
|
315
|
+
<pre class="lines">
|
316
|
+
|
317
|
+
|
318
|
+
22
|
319
|
+
23
|
320
|
+
24
|
321
|
+
25</pre>
|
322
|
+
</td>
|
323
|
+
<td>
|
324
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service/action/comment.rb', line 22</span>
|
325
|
+
|
326
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_parse_source'>parse_source</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
|
327
|
+
<span class='ivar'>@parsed_sources</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
328
|
+
<span class='ivar'>@parsed_sources</span><span class='lbracket'>[</span><span class='id identifier rubyid_file'>file</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid__parse_source'>_parse_source</span><span class='lparen'>(</span><span class='id identifier rubyid_file'>file</span><span class='rparen'>)</span>
|
329
|
+
<span class='kw'>end</span></pre>
|
330
|
+
</td>
|
331
|
+
</tr>
|
332
|
+
</table>
|
333
|
+
</div>
|
334
|
+
|
335
|
+
</div>
|
336
|
+
|
337
|
+
</div>
|
338
|
+
|
339
|
+
<div id="footer">
|
340
|
+
Generated on Wed Dec 4 22:57:13 2019 by
|
341
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
342
|
+
0.9.20 (ruby-2.5.1).
|
343
|
+
</div>
|
344
|
+
|
345
|
+
</div>
|
346
|
+
</body>
|
347
|
+
</html>
|