netlinx-erb 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +126 -1
- data/bin/netlinx-erb +48 -0
- data/doc/Array.html +1 -1
- data/doc/Hash.html +1 -1
- data/doc/NetLinx.html +1 -1
- data/doc/NetLinx/ERB.html +13 -2
- data/doc/NetLinx/ERB/HashHelpers.html +1 -1
- data/doc/NetLinx/ERB/Helpers.html +1 -1
- data/doc/NetLinx/Rake.html +15 -4
- data/doc/NetLinx/Rake/ERB.html +15 -4
- data/doc/NetLinx/Rake/ERB/GenerateERB.html +1 -1
- data/doc/NetLinx/Rake/ERB/GenerateRPC.html +1 -1
- data/doc/NetLinx/Rake/ERB/Lines.html +1 -1
- data/doc/RPC.html +72 -59
- data/doc/String.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +149 -2
- data/doc/file.license.html +2 -2
- data/doc/index.html +149 -2
- data/doc/top-level-namespace.html +1 -1
- data/lib/netlinx-erb.rb +8 -0
- data/lib/netlinx/erb/rpc.rb +34 -57
- data/lib/netlinx/rake/erb.rb +6 -1
- data/license.txt +1 -1
- data/template.zip +0 -0
- metadata +9 -10
- data/template/Gemfile +0 -9
- data/template/README.md +0 -130
- data/template/Rakefile +0 -11
- data/template/rpc.axi +0 -148
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d128ee559e5039b040d656ada09d817f56be6c
|
4
|
+
data.tar.gz: 9d255c77d16daf54de3eda423593d9a5f347fea5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b71728fcd3e0895efb397cbcfda9738c837250254eb939249106f67d1c38e4f48190bbabf400638fa59c0808a80e3ab37ca8426f05e045ac4aec3e81bd8a927e
|
7
|
+
data.tar.gz: e9ee04ac514436a62c73520f4f3fa4945b65beb50ec718298a3934f86c341dae276f02af40a205bb81bfc80499373b8c1326639a71df2c1abee07e3006c2c8fa
|
data/README.md
CHANGED
@@ -4,6 +4,131 @@ netlinx-erb
|
|
4
4
|
|
5
5
|
A code generation utility for AMX NetLinx control systems.
|
6
6
|
|
7
|
-
[
|
7
|
+
[](http://badge.fury.io/rb/netlinx-erb)
|
8
|
+
[](http://www.rubydoc.info/gems/netlinx-erb)
|
8
9
|
|
9
10
|
Syntax highlighting is included in [sublime-netlinx](https://github.com/amclain/sublime-netlinx).
|
11
|
+
|
12
|
+
|
13
|
+
## Overview
|
14
|
+
|
15
|
+
Use a descriptive syntax...
|
16
|
+
|
17
|
+
[](https://github.com/amclain/netlinx-erb/blob/master/screenshots/example_erb.png)
|
18
|
+
|
19
|
+
To generate repetitive NetLinx code...
|
20
|
+
|
21
|
+
[](https://github.com/amclain/netlinx-erb/blob/master/screenshots/example_axi.png)
|
22
|
+
|
23
|
+
With netlinx-erb, configuration is separated from implementation. For example,
|
24
|
+
touch panel button numbers and video inputs (configuration) are separated from
|
25
|
+
the code that handles video patching when a button is pressed (implementation).
|
26
|
+
Under this paradigm, reconfiguration can happen quickly as project requirements
|
27
|
+
change. Since the implementation code is separated from these changes and code
|
28
|
+
generation is automated, there is less chance of inducing bugs into the system
|
29
|
+
when a change in configuration happens.
|
30
|
+
|
31
|
+
For example, in the code above, let's say the client decides to add a camera
|
32
|
+
to the system. All we have to do to update this file is add the following to
|
33
|
+
the `video_sources` hash:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
BTN_VID_CAMERA: { btn: 14, input: :VID_SRC_CAMERA }
|
37
|
+
```
|
38
|
+
|
39
|
+
This defines a new touch panel button constant `BTN_VID_CAMERA`, assigns that
|
40
|
+
constant to channel number `14`, and adds a case to the button event handler
|
41
|
+
to switch the video matrix to `VID_SRC_CAMERA` when the button is pressed.
|
42
|
+
Since the implementation code for this change is auto-generated, and we know
|
43
|
+
that the implementation code works correctly, it is unlikely that this change
|
44
|
+
will create any bugs. There is a clear advantage to this method as the amount
|
45
|
+
of code grows and the project becomes more complex.
|
46
|
+
|
47
|
+
### RPC
|
48
|
+
|
49
|
+
A remote procedure call (RPC) mechanism is included to be able to call NetLinx
|
50
|
+
functions through ICSLan (NetLinx Diagnostics, Telnet, etc.). To issue an RPC
|
51
|
+
function call, `send_string` to `34500:1:0`. The body of the string should
|
52
|
+
start with the name of the function, followed by a space-separated list of
|
53
|
+
arguments.
|
54
|
+
|
55
|
+
For the following function:
|
56
|
+
|
57
|
+
```c
|
58
|
+
define_function patch_video(integer input, integer output)
|
59
|
+
{
|
60
|
+
// Patch video matrix.
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
`patch_video 1 2` is the RPC string that would patch video input 1 to output 2.
|
65
|
+
|
66
|
+
### Backward Compatibility
|
67
|
+
|
68
|
+
The NetLinx files generated by netlinx-erb are designed to be fully backward
|
69
|
+
compatible with traditional NetLinx project development, including readability
|
70
|
+
and adequate whitespace. This means that any NetLinx programmer can take over
|
71
|
+
maintenance of the project using the standard development tools provided by AMX
|
72
|
+
and does not need to have any experience with netlinx-erb.
|
73
|
+
|
74
|
+
It is important to note that ***this process is a one-way street***. Once the
|
75
|
+
generated files are modified by hand, the changes must be manually converted
|
76
|
+
back to the template files or else they will be erased the next time the
|
77
|
+
generator is run. Backward compatibility is designed for projects that are
|
78
|
+
permanently passed to other programmers who are not familiar with netlinx-erb
|
79
|
+
and are not able to learn it, like due to time constraints.
|
80
|
+
|
81
|
+
|
82
|
+
## Issues, Bugs, Feature Requests
|
83
|
+
|
84
|
+
Any bugs and feature requests should be reported on the GitHub issue tracker:
|
85
|
+
|
86
|
+
https://github.com/amclain/netlinx-erb/issues
|
87
|
+
|
88
|
+
|
89
|
+
**Pull requests are preferred via GitHub.**
|
90
|
+
|
91
|
+
Mercurial users can use [Hg-Git](http://hg-git.github.io/) to interact with
|
92
|
+
GitHub repositories.
|
93
|
+
|
94
|
+
|
95
|
+
## Installation
|
96
|
+
|
97
|
+
netlinx-erb is available as a Ruby gem.
|
98
|
+
|
99
|
+
1. Install [Ruby](https://www.ruby-lang.org) 2.1.5 or higher.
|
100
|
+
* Windows: Use [RubyInstaller](http://rubyinstaller.org/downloads/)
|
101
|
+
and make sure ruby/bin is in your [system path](http://www.computerhope.com/issues/ch000549.htm).
|
102
|
+
* Linux: Use [rbenv](https://github.com/sstephenson/rbenv#basic-github-checkout).
|
103
|
+
|
104
|
+
2. Open the [command line](http://www.addictivetips.com/windows-tips/windows-7-elevated-command-prompt-in-context-menu/)
|
105
|
+
and type:
|
106
|
+
|
107
|
+
***gem install netlinx-erb***
|
108
|
+
|
109
|
+
|
110
|
+
*NOTE: The NetLinx compiler executable provided by AMX, nlrc.exe, must be
|
111
|
+
installed on your computer for this utility to work. It is included in the
|
112
|
+
NetLinx Studio installation by default.*
|
113
|
+
|
114
|
+
**If you receive the following error when running gem install:**
|
115
|
+
`Unable to download data from https://rubygems.org/ - SSL_connect returned=1`
|
116
|
+
|
117
|
+
Follow this guide:
|
118
|
+
[Workaround RubyGems' SSL errors on Ruby for Windows (RubyInstaller)](https://gist.github.com/luislavena/f064211759ee0f806c88)
|
119
|
+
|
120
|
+
|
121
|
+
## Prerequisite Knowledge
|
122
|
+
|
123
|
+
netlinx-erb is a complex utility and does have a learning curve. However, the
|
124
|
+
time invested in learning this utility pays off in time saved from generating
|
125
|
+
code that would otherwise be handwritten, and troubleshooting fewer bugs. Due
|
126
|
+
to this, project maintenance also becomes easier.
|
127
|
+
|
128
|
+
Basic experience with the [Ruby programming language](https://www.ruby-lang.org)
|
129
|
+
is required, as well as [ERB templating](http://www.stuartellis.eu/articles/erb/).
|
130
|
+
|
131
|
+
|
132
|
+
## Getting Started
|
133
|
+
|
134
|
+
## Code Examples
|
data/bin/netlinx-erb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'rake'
|
4
|
+
require 'zip'
|
5
|
+
|
6
|
+
$0 = 'netlinx-erb'
|
7
|
+
|
8
|
+
ARGV << '-h' if ARGV.empty?
|
9
|
+
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: netlinx-erb [options]"
|
12
|
+
|
13
|
+
opts.on '-h', '--help', 'Display this help screen.' do
|
14
|
+
puts opts
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on '-n', '--new [name]', 'Create a new project.' do |name|
|
19
|
+
puts "Creating workspace..."
|
20
|
+
|
21
|
+
Dir.mkdir name if name and not Dir.exists? name
|
22
|
+
|
23
|
+
name ||= '.'
|
24
|
+
|
25
|
+
Dir.chdir name do
|
26
|
+
if File.exists? 'Rakefile'
|
27
|
+
puts "Project already exists.\nAborted."
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'netlinx/rake/workspace/create_workspace_config'
|
32
|
+
NetLinx::Rake::Workspace::CreateWorkspaceConfig.new
|
33
|
+
Rake.application['create_workspace_config'].invoke
|
34
|
+
|
35
|
+
gem_spec = Gem::Specification.find_by_name 'netlinx-erb'
|
36
|
+
template_path = "#{gem_spec.gem_dir}/template.zip"
|
37
|
+
|
38
|
+
Zip::File.open template_path do |zip|
|
39
|
+
zip.each do |file|
|
40
|
+
file.extract
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
puts "Done."
|
46
|
+
end
|
47
|
+
|
48
|
+
end.parse! ARGV
|
data/doc/Array.html
CHANGED
@@ -204,7 +204,7 @@
|
|
204
204
|
</div>
|
205
205
|
|
206
206
|
<div id="footer">
|
207
|
-
Generated on
|
207
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
208
208
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
209
209
|
0.8.7.6 (ruby-2.1.3).
|
210
210
|
</div>
|
data/doc/Hash.html
CHANGED
@@ -257,7 +257,7 @@
|
|
257
257
|
</div>
|
258
258
|
|
259
259
|
<div id="footer">
|
260
|
-
Generated on
|
260
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
261
261
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
262
262
|
0.8.7.6 (ruby-2.1.3).
|
263
263
|
</div>
|
data/doc/NetLinx.html
CHANGED
@@ -119,7 +119,7 @@
|
|
119
119
|
</div>
|
120
120
|
|
121
121
|
<div id="footer">
|
122
|
-
Generated on
|
122
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
123
123
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
124
124
|
0.8.7.6 (ruby-2.1.3).
|
125
125
|
</div>
|
data/doc/NetLinx/ERB.html
CHANGED
@@ -86,7 +86,18 @@
|
|
86
86
|
</dl>
|
87
87
|
<div class="clear"></div>
|
88
88
|
|
89
|
-
<h2>
|
89
|
+
<h2>Overview</h2><div class="docstring">
|
90
|
+
<div class="discussion">
|
91
|
+
|
92
|
+
<p>NetLinx code generation.</p>
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
<div class="tags">
|
98
|
+
|
99
|
+
|
100
|
+
</div><h2>Defined Under Namespace</h2>
|
90
101
|
<p class="children">
|
91
102
|
|
92
103
|
|
@@ -224,7 +235,7 @@
|
|
224
235
|
</div>
|
225
236
|
|
226
237
|
<div id="footer">
|
227
|
-
Generated on
|
238
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
228
239
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
229
240
|
0.8.7.6 (ruby-2.1.3).
|
230
241
|
</div>
|
@@ -404,7 +404,7 @@ with the result.</p>
|
|
404
404
|
</div>
|
405
405
|
|
406
406
|
<div id="footer">
|
407
|
-
Generated on
|
407
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
408
408
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
409
409
|
0.8.7.6 (ruby-2.1.3).
|
410
410
|
</div>
|
@@ -2148,7 +2148,7 @@ in itoa().</p>
|
|
2148
2148
|
</div>
|
2149
2149
|
|
2150
2150
|
<div id="footer">
|
2151
|
-
Generated on
|
2151
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
2152
2152
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2153
2153
|
0.8.7.6 (ruby-2.1.3).
|
2154
2154
|
</div>
|
data/doc/NetLinx/Rake.html
CHANGED
@@ -79,14 +79,25 @@
|
|
79
79
|
|
80
80
|
|
81
81
|
<dt class="r1 last">Defined in:</dt>
|
82
|
-
<dd class="r1 last">lib/netlinx
|
83
|
-
lib/netlinx/rake/erb/generate_rpc.rb,<br /> lib/netlinx/rake/erb/generate_erb.rb</span>
|
82
|
+
<dd class="r1 last">lib/netlinx-erb.rb<span class="defines">,<br />
|
83
|
+
lib/netlinx/rake/erb/lines.rb,<br /> lib/netlinx/rake/erb/generate_rpc.rb,<br /> lib/netlinx/rake/erb/generate_erb.rb</span>
|
84
84
|
</dd>
|
85
85
|
|
86
86
|
</dl>
|
87
87
|
<div class="clear"></div>
|
88
88
|
|
89
|
-
<h2>
|
89
|
+
<h2>Overview</h2><div class="docstring">
|
90
|
+
<div class="discussion">
|
91
|
+
|
92
|
+
<p>:nodoc:</p>
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
<div class="tags">
|
98
|
+
|
99
|
+
|
100
|
+
</div><h2>Defined Under Namespace</h2>
|
90
101
|
<p class="children">
|
91
102
|
|
92
103
|
|
@@ -108,7 +119,7 @@
|
|
108
119
|
</div>
|
109
120
|
|
110
121
|
<div id="footer">
|
111
|
-
Generated on
|
122
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
112
123
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
124
|
0.8.7.6 (ruby-2.1.3).
|
114
125
|
</div>
|
data/doc/NetLinx/Rake/ERB.html
CHANGED
@@ -79,14 +79,25 @@
|
|
79
79
|
|
80
80
|
|
81
81
|
<dt class="r1 last">Defined in:</dt>
|
82
|
-
<dd class="r1 last">lib/netlinx
|
83
|
-
lib/netlinx/rake/erb/generate_rpc.rb,<br /> lib/netlinx/rake/erb/generate_erb.rb</span>
|
82
|
+
<dd class="r1 last">lib/netlinx-erb.rb<span class="defines">,<br />
|
83
|
+
lib/netlinx/rake/erb/lines.rb,<br /> lib/netlinx/rake/erb/generate_rpc.rb,<br /> lib/netlinx/rake/erb/generate_erb.rb</span>
|
84
84
|
</dd>
|
85
85
|
|
86
86
|
</dl>
|
87
87
|
<div class="clear"></div>
|
88
88
|
|
89
|
-
<h2>
|
89
|
+
<h2>Overview</h2><div class="docstring">
|
90
|
+
<div class="discussion">
|
91
|
+
|
92
|
+
<p>NetLinx code generation rake tasks.</p>
|
93
|
+
|
94
|
+
|
95
|
+
</div>
|
96
|
+
</div>
|
97
|
+
<div class="tags">
|
98
|
+
|
99
|
+
|
100
|
+
</div><h2>Defined Under Namespace</h2>
|
90
101
|
<p class="children">
|
91
102
|
|
92
103
|
|
@@ -108,7 +119,7 @@
|
|
108
119
|
</div>
|
109
120
|
|
110
121
|
<div id="footer">
|
111
|
-
Generated on
|
122
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
112
123
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
124
|
0.8.7.6 (ruby-2.1.3).
|
114
125
|
</div>
|
@@ -410,7 +410,7 @@
|
|
410
410
|
</div>
|
411
411
|
|
412
412
|
<div id="footer">
|
413
|
-
Generated on
|
413
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
414
414
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
415
415
|
0.8.7.6 (ruby-2.1.3).
|
416
416
|
</div>
|
@@ -340,7 +340,7 @@
|
|
340
340
|
</div>
|
341
341
|
|
342
342
|
<div id="footer">
|
343
|
-
Generated on
|
343
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
344
344
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
345
345
|
0.8.7.6 (ruby-2.1.3).
|
346
346
|
</div>
|
@@ -372,7 +372,7 @@
|
|
372
372
|
</div>
|
373
373
|
|
374
374
|
<div id="footer">
|
375
|
-
Generated on
|
375
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
376
376
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
377
377
|
0.8.7.6 (ruby-2.1.3).
|
378
378
|
</div>
|
data/doc/RPC.html
CHANGED
@@ -177,6 +177,19 @@
|
|
177
177
|
</div>
|
178
178
|
<div class="tags">
|
179
179
|
|
180
|
+
<p class="tag_title">Raises:</p>
|
181
|
+
<ul class="raise">
|
182
|
+
|
183
|
+
<li>
|
184
|
+
|
185
|
+
|
186
|
+
<span class='type'>(<tt>Errno::ENOENT</tt>)</span>
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
</li>
|
191
|
+
|
192
|
+
</ul>
|
180
193
|
|
181
194
|
</div><table class="source_code">
|
182
195
|
<tr>
|
@@ -184,6 +197,29 @@
|
|
184
197
|
<pre class="lines">
|
185
198
|
|
186
199
|
|
200
|
+
8
|
201
|
+
9
|
202
|
+
10
|
203
|
+
11
|
204
|
+
12
|
205
|
+
13
|
206
|
+
14
|
207
|
+
15
|
208
|
+
16
|
209
|
+
17
|
210
|
+
18
|
211
|
+
19
|
212
|
+
20
|
213
|
+
21
|
214
|
+
22
|
215
|
+
23
|
216
|
+
24
|
217
|
+
25
|
218
|
+
26
|
219
|
+
27
|
220
|
+
28
|
221
|
+
29
|
222
|
+
30
|
187
223
|
31
|
188
224
|
32
|
189
225
|
33
|
@@ -398,33 +434,10 @@
|
|
398
434
|
242
|
399
435
|
243
|
400
436
|
244
|
401
|
-
245
|
402
|
-
246
|
403
|
-
247
|
404
|
-
248
|
405
|
-
249
|
406
|
-
250
|
407
|
-
251
|
408
|
-
252
|
409
|
-
253
|
410
|
-
254
|
411
|
-
255
|
412
|
-
256
|
413
|
-
257
|
414
|
-
258
|
415
|
-
259
|
416
|
-
260
|
417
|
-
261
|
418
|
-
262
|
419
|
-
263
|
420
|
-
264
|
421
|
-
265
|
422
|
-
266
|
423
|
-
267
|
424
|
-
268</pre>
|
437
|
+
245</pre>
|
425
438
|
</td>
|
426
439
|
<td>
|
427
|
-
<pre class="code"><span class="info file"># File 'lib/netlinx/erb/rpc.rb', line
|
440
|
+
<pre class="code"><span class="info file"># File 'lib/netlinx/erb/rpc.rb', line 8</span>
|
428
441
|
|
429
442
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_build'>build</span>
|
430
443
|
<span class='id identifier rubyid_fn_exp'>fn_exp</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>
|
@@ -433,42 +446,42 @@
|
|
433
446
|
Does not have to exist.
|
434
447
|
)
|
435
448
|
^(?<desc>[\t ]*\/\*(?:[^\*]|\*[^\/])*\*\/)?\s*
|
436
|
-
|
449
|
+
|
437
450
|
(?# Find the function definition. )
|
438
451
|
define_function\s+
|
439
|
-
|
452
|
+
|
440
453
|
(?# Capture function's return type, if it exists.)
|
441
454
|
(?<rtn>\w+(?<width>\[\d+\])?)??\s*
|
442
|
-
|
455
|
+
|
443
456
|
(?# Capture the function name. )
|
444
457
|
(?<name>\w+)
|
445
|
-
|
458
|
+
|
446
459
|
(?#
|
447
460
|
Capture the function parameters.
|
448
461
|
Run this through another regex to get the type\\name pairs.
|
449
462
|
)
|
450
463
|
\(\s*(?<params>.*?)\s*\)\s*
|
451
|
-
|
464
|
+
|
452
465
|
(?# Capture the function's source code. )
|
453
466
|
{[\r\n]*(?<code>(?:.|\r|\n)*?)?[\r\n]*}
|
454
467
|
</span><span class='regexp_end'>/x</span></span>
|
455
|
-
|
468
|
+
|
456
469
|
<span class='id identifier rubyid_param_exp'>param_exp</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\s*(?:(?<type>\w+)\s+(?<name>\w+(?<width>\[\d*\])?)),?\s*</span><span class='regexp_end'>/</span></span>
|
457
|
-
|
470
|
+
|
458
471
|
<span class='id identifier rubyid_sections'>sections</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='comment'># Collect a set of matches for each file, separated by file.
|
459
|
-
</span>
|
460
|
-
|
472
|
+
</span>
|
473
|
+
|
461
474
|
<span class='comment'># Pull file list from workspace.
|
462
|
-
</span> <span class='id identifier
|
463
|
-
<span class='id identifier
|
464
|
-
|
475
|
+
</span> <span class='id identifier rubyid_workspace'>workspace</span> <span class='op'>=</span> <span class='const'>NetLinx</span><span class='op'>::</span><span class='const'>Workspace</span><span class='period'>.</span><span class='id identifier rubyid_search'>search</span>
|
476
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>ENOENT</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Workspace not found.</span><span class='tstring_end'>'</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_workspace'>workspace</span>
|
477
|
+
|
465
478
|
<span class='id identifier rubyid_file_paths'>file_paths</span> <span class='op'>=</span> <span class='id identifier rubyid_workspace'>workspace</span><span class='period'>.</span><span class='id identifier rubyid_projects'>projects</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_systems'>systems</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_files'>files</span><span class='period'>
|
466
479
|
</span><span class='id identifier rubyid_ .map'> .map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:path</span><span class='rparen'>)</span><span class='period'>
|
467
480
|
</span><span class='id identifier rubyid_ .select'> .select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_path'>path</span><span class='op'>|</span> <span class='id identifier rubyid_path'>path</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\.axi|\.axs)$</span><span class='regexp_end'>/</span></span> <span class='rbrace'>}</span><span class='period'>
|
468
481
|
</span><span class='id identifier rubyid_ .reject'> .reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_path'>path</span><span class='op'>|</span> <span class='id identifier rubyid_path'>path</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>rpc(?:-|_.*?)?\.axi</span><span class='regexp_end'>/</span></span> <span class='rbrace'>}</span> <span class='comment'># Remove RPC files.
|
469
|
-
</span>
|
482
|
+
</span>
|
470
483
|
<span class='comment'># file_paths = Dir['**/*.axi']
|
471
|
-
</span>
|
484
|
+
</span>
|
472
485
|
<span class='id identifier rubyid_file_paths'>file_paths</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
|
473
486
|
<span class='id identifier rubyid_str'>str</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>\\</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>r:iso-8859-1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span>
|
474
487
|
<span class='id identifier rubyid_matches'>matches</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
@@ -480,47 +493,47 @@
|
|
480
493
|
|
481
494
|
<span class='id identifier rubyid_sections'>sections</span><span class='lbracket'>[</span><span class='id identifier rubyid_f'>f</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_matches'>matches</span>
|
482
495
|
<span class='kw'>end</span>
|
483
|
-
|
496
|
+
|
484
497
|
<span class='comment'># -----------------------
|
485
498
|
</span> <span class='comment'># Documentation Generator
|
486
499
|
</span> <span class='comment'># -----------------------
|
487
|
-
</span>
|
500
|
+
</span>
|
488
501
|
<span class='comment'># output = ''
|
489
502
|
</span> <span class='comment'># sections.each do |name, matches|
|
490
|
-
</span>
|
503
|
+
</span>
|
491
504
|
<span class='comment'># output << "--------------------------------------------------\n"
|
492
505
|
</span> <span class='comment'># output << "FILE: '#{name}'\n"
|
493
506
|
</span> <span class='comment'># output << "--------------------------------------------------\n"
|
494
507
|
</span> <span class='comment'># output << "\n\n"
|
495
|
-
</span>
|
508
|
+
</span>
|
496
509
|
<span class='comment'># matches.each do |m|
|
497
510
|
</span> <span class='comment'># output << m[:desc].to_s
|
498
511
|
</span> <span class='comment'># output << "\n"
|
499
512
|
</span> <span class='comment'># output << m[:name].to_s
|
500
513
|
</span> <span class='comment'># output << "\n\n\n"
|
501
514
|
</span> <span class='comment'># end
|
502
|
-
</span>
|
515
|
+
</span>
|
503
516
|
<span class='comment'># end
|
504
|
-
</span>
|
517
|
+
</span>
|
505
518
|
<span class='comment'># File.open('functions.axi', 'w+') { |f| f << output }
|
506
|
-
</span>
|
507
|
-
|
519
|
+
</span>
|
520
|
+
|
508
521
|
<span class='comment'># ----------------------
|
509
522
|
</span> <span class='comment'># RPC Function Generator
|
510
523
|
</span> <span class='comment'># ----------------------
|
511
|
-
</span>
|
524
|
+
</span>
|
512
525
|
<span class='comment'># Generate list of included and excluded files for sanity check.
|
513
526
|
</span> <span class='id identifier rubyid_directory_files'>directory_files</span> <span class='op'>=</span> <span class='const'>Dir</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>**/*.axi</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>+</span> <span class='const'>Dir</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>**/*.axs</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
|
514
|
-
|
527
|
+
|
515
528
|
<span class='id identifier rubyid_included_files'>included_files</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
516
529
|
<span class='id identifier rubyid_file_paths'>file_paths</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_path'>path</span><span class='op'>|</span> <span class='id identifier rubyid_included_files'>included_files</span> <span class='op'><<</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>\\</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span> <span class='comment'># TODO: As string.
|
517
|
-
</span>
|
530
|
+
</span>
|
518
531
|
<span class='id identifier rubyid_excluded_files'>excluded_files</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
519
532
|
<span class='lparen'>(</span><span class='id identifier rubyid_directory_files'>directory_files</span> <span class='op'>-</span> <span class='id identifier rubyid_file_paths'>file_paths</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_path'>path</span><span class='op'>|</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>\\</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_path'>path</span><span class='op'>|</span> <span class='id identifier rubyid_excluded_files'>excluded_files</span> <span class='op'><<</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>\\</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>\n</span><span class='tstring_end'>"</span></span> <span class='rbrace'>}</span>
|
520
|
-
|
533
|
+
|
521
534
|
<span class='id identifier rubyid_fn_symbols'>fn_symbols</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='comment'># Symbol names to avoid duplicates.
|
522
535
|
</span> <span class='id identifier rubyid_output'>output</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
523
|
-
|
536
|
+
|
524
537
|
<span class='id identifier rubyid_output'>output</span> <span class='op'><<</span> <span class='heredoc_beg'><<-EOS</span>
|
525
538
|
<span class='tstring_content'>(***********************************************************)
|
526
539
|
(* WARNING *)
|
@@ -606,9 +619,9 @@ data_event[vdvRPC]
|
|
606
619
|
|
607
620
|
<span class='id identifier rubyid_fn_output'>fn_output</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_fn'>fn</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>(</span><span class='tstring_end'>"</span></span>
|
608
621
|
<span class='id identifier rubyid_fn_output'>fn_output</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>);\n</span><span class='tstring_end'>"</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
609
|
-
|
622
|
+
|
610
623
|
<span class='id identifier rubyid_function_valid'>function_valid</span> <span class='op'>=</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='lbracket'>[</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='symbol'>:integer</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span> <span class='id identifier rubyid_return_type'>return_type</span>
|
611
|
-
|
624
|
+
|
612
625
|
<span class='comment'># Generate parameters.
|
613
626
|
</span> <span class='id identifier rubyid_param_index'>param_index</span> <span class='op'>=</span> <span class='int'>0</span>
|
614
627
|
<span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_param'>param</span><span class='op'>|</span>
|
@@ -645,7 +658,7 @@ data_event[vdvRPC]
|
|
645
658
|
<span class='kw'>end</span>
|
646
659
|
|
647
660
|
<span class='id identifier rubyid_fn_output'>fn_output</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> }\n\n</span><span class='tstring_end'>"</span></span>
|
648
|
-
|
661
|
+
|
649
662
|
<span class='comment'># Store function string.
|
650
663
|
</span> <span class='kw'>if</span> <span class='id identifier rubyid_function_valid'>function_valid</span>
|
651
664
|
<span class='id identifier rubyid_output'>output</span> <span class='op'><<</span> <span class='id identifier rubyid_fn_output'>fn_output</span>
|
@@ -656,12 +669,12 @@ data_event[vdvRPC]
|
|
656
669
|
<span class='kw'>end</span>
|
657
670
|
|
658
671
|
<span class='kw'>end</span>
|
659
|
-
|
672
|
+
|
660
673
|
<span class='id identifier rubyid_output'>output</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'> }\n</span><span class='tstring_end'>"</span></span>
|
661
674
|
<span class='id identifier rubyid_output'>output</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>}\n</span><span class='tstring_end'>"</span></span>
|
662
675
|
<span class='id identifier rubyid_output'>output</span> <span class='op'><<</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>#end_if\n\n</span><span class='tstring_end'>"</span></span>
|
663
|
-
|
664
|
-
|
676
|
+
|
677
|
+
|
665
678
|
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>include/rpc-functions.axi</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>w+</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='id identifier rubyid_f'>f</span> <span class='op'><<</span> <span class='id identifier rubyid_output'>output</span> <span class='rbrace'>}</span>
|
666
679
|
<span class='kw'>end</span></pre>
|
667
680
|
</td>
|
@@ -674,7 +687,7 @@ data_event[vdvRPC]
|
|
674
687
|
</div>
|
675
688
|
|
676
689
|
<div id="footer">
|
677
|
-
Generated on
|
690
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
678
691
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
679
692
|
0.8.7.6 (ruby-2.1.3).
|
680
693
|
</div>
|