netlinx-erb 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/doc/String.html
CHANGED
@@ -313,7 +313,7 @@
|
|
313
313
|
</div>
|
314
314
|
|
315
315
|
<div id="footer">
|
316
|
-
Generated on
|
316
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
317
317
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
318
318
|
0.8.7.6 (ruby-2.1.3).
|
319
319
|
</div>
|
data/doc/_index.html
CHANGED
@@ -239,7 +239,7 @@
|
|
239
239
|
</div>
|
240
240
|
|
241
241
|
<div id="footer">
|
242
|
-
Generated on
|
242
|
+
Generated on Wed Feb 25 14:28:05 2015 by
|
243
243
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
244
244
|
0.8.7.6 (ruby-2.1.3).
|
245
245
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -68,14 +68,161 @@
|
|
68
68
|
|
69
69
|
<p>A code generation utility for AMX NetLinx control systems.</p>
|
70
70
|
|
71
|
-
<p
|
71
|
+
<p><a href="http://badge.fury.io/rb/netlinx-erb"><img
|
72
|
+
src="https://badge.fury.io/rb/netlinx-erb.svg"></a> <a
|
73
|
+
href="http://www.rubydoc.info/gems/netlinx-erb"><img
|
74
|
+
src="http://img.shields.io/badge/docs-api-blue.svg"></a></p>
|
72
75
|
|
73
76
|
<p>Syntax highlighting is included in <a
|
74
77
|
href="https://github.com/amclain/sublime-netlinx">sublime-netlinx</a>.</p>
|
78
|
+
|
79
|
+
<h2 id="label-Overview">Overview</h2>
|
80
|
+
|
81
|
+
<p>Use a descriptive syntax…</p>
|
82
|
+
|
83
|
+
<p><img
|
84
|
+
src="https://github.com/amclain/netlinx-erb/blob/master/screenshots/example_erb.png"
|
85
|
+
/></p>
|
86
|
+
|
87
|
+
<p>To generate repetitive NetLinx code…</p>
|
88
|
+
|
89
|
+
<p><img
|
90
|
+
src="https://github.com/amclain/netlinx-erb/blob/master/screenshots/example_axi.png"
|
91
|
+
/></p>
|
92
|
+
|
93
|
+
<p>With netlinx-erb, configuration is separated from implementation. For
|
94
|
+
example, touch panel button numbers and video inputs (configuration) are
|
95
|
+
separated from the code that handles video patching when a button is
|
96
|
+
pressed (implementation). Under this paradigm, reconfiguration can happen
|
97
|
+
quickly as project requirements change. Since the implementation code is
|
98
|
+
separated from these changes and code generation is automated, there is
|
99
|
+
less chance of inducing bugs into the system when a change in configuration
|
100
|
+
happens.</p>
|
101
|
+
|
102
|
+
<p>For example, in the code above, let's say the client decides to add a
|
103
|
+
camera to the system. All we have to do to update this file is add the
|
104
|
+
following to the <code>video_sources</code> hash:</p>
|
105
|
+
|
106
|
+
<pre class="code ruby"><code class="ruby">BTN_VID_CAMERA: { btn: 14, input: :VID_SRC_CAMERA }
|
107
|
+
</code></pre>
|
108
|
+
|
109
|
+
<p>This defines a new touch panel button constant <code>BTN_VID_CAMERA</code>,
|
110
|
+
assigns that constant to channel number <code>14</code>, and adds a case to
|
111
|
+
the button event handler to switch the video matrix to
|
112
|
+
<code>VID_SRC_CAMERA</code> when the button is pressed. Since the
|
113
|
+
implementation code for this change is auto-generated, and we know that the
|
114
|
+
implementation code works correctly, it is unlikely that this change will
|
115
|
+
create any bugs. There is a clear advantage to this method as the amount of
|
116
|
+
code grows and the project becomes more complex.</p>
|
117
|
+
|
118
|
+
<h3 id="label-RPC">RPC</h3>
|
119
|
+
|
120
|
+
<p>A remote procedure call (RPC) mechanism is included to be able to call
|
121
|
+
NetLinx functions through ICSLan (NetLinx Diagnostics, Telnet, etc.). To
|
122
|
+
issue an RPC function call, <code>send_string</code> to
|
123
|
+
<code>34500:1:0</code>. The body of the string should start with the name
|
124
|
+
of the function, followed by a space-separated list of arguments.</p>
|
125
|
+
|
126
|
+
<p>For the following function:</p>
|
127
|
+
|
128
|
+
<pre class="code ruby"><code class="ruby">define_function patch_video(integer input, integer output)
|
129
|
+
{
|
130
|
+
// Patch video matrix.
|
131
|
+
}</code></pre>
|
132
|
+
|
133
|
+
<p><code>patch_video 1 2</code> is the RPC string that would patch video input
|
134
|
+
1 to output 2.</p>
|
135
|
+
|
136
|
+
<h3 id="label-Backward+Compatibility">Backward Compatibility</h3>
|
137
|
+
|
138
|
+
<p>The NetLinx files generated by netlinx-erb are designed to be fully
|
139
|
+
backward compatible with traditional NetLinx project development, including
|
140
|
+
readability and adequate whitespace. This means that any NetLinx programmer
|
141
|
+
can take over maintenance of the project using the standard development
|
142
|
+
tools provided by AMX and does not need to have any experience with
|
143
|
+
netlinx-erb.</p>
|
144
|
+
|
145
|
+
<p>It is important to note that <strong><em>this process is a one-way
|
146
|
+
street</em></strong>. Once the generated files are modified by hand, the
|
147
|
+
changes must be manually converted back to the template files or else they
|
148
|
+
will be erased the next time the generator is run. Backward compatibility
|
149
|
+
is designed for projects that are permanently passed to other programmers
|
150
|
+
who are not familiar with netlinx-erb and are not able to learn it, like
|
151
|
+
due to time constraints.</p>
|
152
|
+
|
153
|
+
<h2 id="label-Issues-2C+Bugs-2C+Feature+Requests">Issues, Bugs, Feature Requests</h2>
|
154
|
+
|
155
|
+
<p>Any bugs and feature requests should be reported on the GitHub issue
|
156
|
+
tracker:</p>
|
157
|
+
|
158
|
+
<p><a
|
159
|
+
href="https://github.com/amclain/netlinx-erb/issues">github.com/amclain/netlinx-erb/issues</a></p>
|
160
|
+
|
161
|
+
<p><strong>Pull requests are preferred via GitHub.</strong></p>
|
162
|
+
|
163
|
+
<p>Mercurial users can use <a href="http://hg-git.github.io/">Hg-Git</a> to
|
164
|
+
interact with GitHub repositories.</p>
|
165
|
+
|
166
|
+
<h2 id="label-Installation">Installation</h2>
|
167
|
+
|
168
|
+
<p>netlinx-erb is available as a Ruby gem.</p>
|
169
|
+
<ol><li>
|
170
|
+
<p>Install <a href="https://www.ruby-lang.org">Ruby</a> 2.1.5 or higher.</p>
|
171
|
+
<ul><li>
|
172
|
+
<p>Windows: Use <a
|
173
|
+
href="http://rubyinstaller.org/downloads/">RubyInstaller</a> and make sure
|
174
|
+
ruby/bin is in your <a
|
175
|
+
href="http://www.computerhope.com/issues/ch000549.htm">system path</a>.</p>
|
176
|
+
</li><li>
|
177
|
+
<p>Linux: Use <a
|
178
|
+
href="https://github.com/sstephenson/rbenv#basic-github-checkout">rbenv</a>.</p>
|
179
|
+
</li><li>
|
180
|
+
<p>Windows: Use <a
|
181
|
+
href="http://rubyinstaller.org/downloads/">RubyInstaller</a> and make sure
|
182
|
+
ruby/bin is in your <a
|
183
|
+
href="http://www.computerhope.com/issues/ch000549.htm">system path</a>.</p>
|
184
|
+
</li><li>
|
185
|
+
<p>Linux: Use <a
|
186
|
+
href="https://github.com/sstephenson/rbenv#basic-github-checkout">rbenv</a>.</p>
|
187
|
+
</li></ul>
|
188
|
+
</li><li>
|
189
|
+
<p>Open the <a
|
190
|
+
href="http://www.addictivetips.com/windows-tips/windows-7-elevated-command-prompt-in-context-menu/">command
|
191
|
+
line</a> and type:</p>
|
192
|
+
|
193
|
+
<p><strong><em>gem install netlinx-erb</em></strong></p>
|
194
|
+
</li></ol>
|
195
|
+
|
196
|
+
<p><em>NOTE: The NetLinx compiler executable provided by AMX, nlrc.exe, must
|
197
|
+
be installed on your computer for this utility to work. It is included in
|
198
|
+
the NetLinx Studio installation by default.</em></p>
|
199
|
+
|
200
|
+
<p><strong>If you receive the following error when running gem
|
201
|
+
install:</strong> <code>Unable to download data from https://rubygems.org/
|
202
|
+
- SSL_connect returned=1</code></p>
|
203
|
+
|
204
|
+
<p>Follow this guide: <a
|
205
|
+
href="https://gist.github.com/luislavena/f064211759ee0f806c88">Workaround
|
206
|
+
RubyGems’ SSL errors on Ruby for Windows (RubyInstaller)</a></p>
|
207
|
+
|
208
|
+
<h2 id="label-Prerequisite+Knowledge">Prerequisite Knowledge</h2>
|
209
|
+
|
210
|
+
<p>netlinx-erb is a complex utility and does have a learning curve. However,
|
211
|
+
the time invested in learning this utility pays off in time saved from
|
212
|
+
generating code that would otherwise be handwritten, and troubleshooting
|
213
|
+
fewer bugs. Due to this, project maintenance also becomes easier.</p>
|
214
|
+
|
215
|
+
<p>Basic experience with the <a href="https://www.ruby-lang.org">Ruby
|
216
|
+
programming language</a> is required, as well as <a
|
217
|
+
href="http://www.stuartellis.eu/articles/erb/">ERB templating</a>.</p>
|
218
|
+
|
219
|
+
<h2 id="label-Getting+Started">Getting Started</h2>
|
220
|
+
|
221
|
+
<h2 id="label-Code+Examples">Code Examples</h2>
|
75
222
|
</div></div>
|
76
223
|
|
77
224
|
<div id="footer">
|
78
|
-
Generated on
|
225
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
79
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
80
227
|
0.8.7.6 (ruby-2.1.3).
|
81
228
|
</div>
|
data/doc/file.license.html
CHANGED
@@ -61,10 +61,10 @@
|
|
61
61
|
|
62
62
|
<iframe id="search_frame"></iframe>
|
63
63
|
|
64
|
-
<div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2015 Alex McLain and Joe McIlvain<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the "Software"), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
|
64
|
+
<div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2014-2015 Alex McLain and Joe McIlvain<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the "Software"), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
|
65
65
|
|
66
66
|
<div id="footer">
|
67
|
-
Generated on
|
67
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
68
68
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
69
69
|
0.8.7.6 (ruby-2.1.3).
|
70
70
|
</div>
|
data/doc/index.html
CHANGED
@@ -68,14 +68,161 @@
|
|
68
68
|
|
69
69
|
<p>A code generation utility for AMX NetLinx control systems.</p>
|
70
70
|
|
71
|
-
<p
|
71
|
+
<p><a href="http://badge.fury.io/rb/netlinx-erb"><img
|
72
|
+
src="https://badge.fury.io/rb/netlinx-erb.svg"></a> <a
|
73
|
+
href="http://www.rubydoc.info/gems/netlinx-erb"><img
|
74
|
+
src="http://img.shields.io/badge/docs-api-blue.svg"></a></p>
|
72
75
|
|
73
76
|
<p>Syntax highlighting is included in <a
|
74
77
|
href="https://github.com/amclain/sublime-netlinx">sublime-netlinx</a>.</p>
|
78
|
+
|
79
|
+
<h2 id="label-Overview">Overview</h2>
|
80
|
+
|
81
|
+
<p>Use a descriptive syntax…</p>
|
82
|
+
|
83
|
+
<p><img
|
84
|
+
src="https://github.com/amclain/netlinx-erb/blob/master/screenshots/example_erb.png"
|
85
|
+
/></p>
|
86
|
+
|
87
|
+
<p>To generate repetitive NetLinx code…</p>
|
88
|
+
|
89
|
+
<p><img
|
90
|
+
src="https://github.com/amclain/netlinx-erb/blob/master/screenshots/example_axi.png"
|
91
|
+
/></p>
|
92
|
+
|
93
|
+
<p>With netlinx-erb, configuration is separated from implementation. For
|
94
|
+
example, touch panel button numbers and video inputs (configuration) are
|
95
|
+
separated from the code that handles video patching when a button is
|
96
|
+
pressed (implementation). Under this paradigm, reconfiguration can happen
|
97
|
+
quickly as project requirements change. Since the implementation code is
|
98
|
+
separated from these changes and code generation is automated, there is
|
99
|
+
less chance of inducing bugs into the system when a change in configuration
|
100
|
+
happens.</p>
|
101
|
+
|
102
|
+
<p>For example, in the code above, let's say the client decides to add a
|
103
|
+
camera to the system. All we have to do to update this file is add the
|
104
|
+
following to the <code>video_sources</code> hash:</p>
|
105
|
+
|
106
|
+
<pre class="code ruby"><code class="ruby">BTN_VID_CAMERA: { btn: 14, input: :VID_SRC_CAMERA }
|
107
|
+
</code></pre>
|
108
|
+
|
109
|
+
<p>This defines a new touch panel button constant <code>BTN_VID_CAMERA</code>,
|
110
|
+
assigns that constant to channel number <code>14</code>, and adds a case to
|
111
|
+
the button event handler to switch the video matrix to
|
112
|
+
<code>VID_SRC_CAMERA</code> when the button is pressed. Since the
|
113
|
+
implementation code for this change is auto-generated, and we know that the
|
114
|
+
implementation code works correctly, it is unlikely that this change will
|
115
|
+
create any bugs. There is a clear advantage to this method as the amount of
|
116
|
+
code grows and the project becomes more complex.</p>
|
117
|
+
|
118
|
+
<h3 id="label-RPC">RPC</h3>
|
119
|
+
|
120
|
+
<p>A remote procedure call (RPC) mechanism is included to be able to call
|
121
|
+
NetLinx functions through ICSLan (NetLinx Diagnostics, Telnet, etc.). To
|
122
|
+
issue an RPC function call, <code>send_string</code> to
|
123
|
+
<code>34500:1:0</code>. The body of the string should start with the name
|
124
|
+
of the function, followed by a space-separated list of arguments.</p>
|
125
|
+
|
126
|
+
<p>For the following function:</p>
|
127
|
+
|
128
|
+
<pre class="code ruby"><code class="ruby">define_function patch_video(integer input, integer output)
|
129
|
+
{
|
130
|
+
// Patch video matrix.
|
131
|
+
}</code></pre>
|
132
|
+
|
133
|
+
<p><code>patch_video 1 2</code> is the RPC string that would patch video input
|
134
|
+
1 to output 2.</p>
|
135
|
+
|
136
|
+
<h3 id="label-Backward+Compatibility">Backward Compatibility</h3>
|
137
|
+
|
138
|
+
<p>The NetLinx files generated by netlinx-erb are designed to be fully
|
139
|
+
backward compatible with traditional NetLinx project development, including
|
140
|
+
readability and adequate whitespace. This means that any NetLinx programmer
|
141
|
+
can take over maintenance of the project using the standard development
|
142
|
+
tools provided by AMX and does not need to have any experience with
|
143
|
+
netlinx-erb.</p>
|
144
|
+
|
145
|
+
<p>It is important to note that <strong><em>this process is a one-way
|
146
|
+
street</em></strong>. Once the generated files are modified by hand, the
|
147
|
+
changes must be manually converted back to the template files or else they
|
148
|
+
will be erased the next time the generator is run. Backward compatibility
|
149
|
+
is designed for projects that are permanently passed to other programmers
|
150
|
+
who are not familiar with netlinx-erb and are not able to learn it, like
|
151
|
+
due to time constraints.</p>
|
152
|
+
|
153
|
+
<h2 id="label-Issues-2C+Bugs-2C+Feature+Requests">Issues, Bugs, Feature Requests</h2>
|
154
|
+
|
155
|
+
<p>Any bugs and feature requests should be reported on the GitHub issue
|
156
|
+
tracker:</p>
|
157
|
+
|
158
|
+
<p><a
|
159
|
+
href="https://github.com/amclain/netlinx-erb/issues">github.com/amclain/netlinx-erb/issues</a></p>
|
160
|
+
|
161
|
+
<p><strong>Pull requests are preferred via GitHub.</strong></p>
|
162
|
+
|
163
|
+
<p>Mercurial users can use <a href="http://hg-git.github.io/">Hg-Git</a> to
|
164
|
+
interact with GitHub repositories.</p>
|
165
|
+
|
166
|
+
<h2 id="label-Installation">Installation</h2>
|
167
|
+
|
168
|
+
<p>netlinx-erb is available as a Ruby gem.</p>
|
169
|
+
<ol><li>
|
170
|
+
<p>Install <a href="https://www.ruby-lang.org">Ruby</a> 2.1.5 or higher.</p>
|
171
|
+
<ul><li>
|
172
|
+
<p>Windows: Use <a
|
173
|
+
href="http://rubyinstaller.org/downloads/">RubyInstaller</a> and make sure
|
174
|
+
ruby/bin is in your <a
|
175
|
+
href="http://www.computerhope.com/issues/ch000549.htm">system path</a>.</p>
|
176
|
+
</li><li>
|
177
|
+
<p>Linux: Use <a
|
178
|
+
href="https://github.com/sstephenson/rbenv#basic-github-checkout">rbenv</a>.</p>
|
179
|
+
</li><li>
|
180
|
+
<p>Windows: Use <a
|
181
|
+
href="http://rubyinstaller.org/downloads/">RubyInstaller</a> and make sure
|
182
|
+
ruby/bin is in your <a
|
183
|
+
href="http://www.computerhope.com/issues/ch000549.htm">system path</a>.</p>
|
184
|
+
</li><li>
|
185
|
+
<p>Linux: Use <a
|
186
|
+
href="https://github.com/sstephenson/rbenv#basic-github-checkout">rbenv</a>.</p>
|
187
|
+
</li></ul>
|
188
|
+
</li><li>
|
189
|
+
<p>Open the <a
|
190
|
+
href="http://www.addictivetips.com/windows-tips/windows-7-elevated-command-prompt-in-context-menu/">command
|
191
|
+
line</a> and type:</p>
|
192
|
+
|
193
|
+
<p><strong><em>gem install netlinx-erb</em></strong></p>
|
194
|
+
</li></ol>
|
195
|
+
|
196
|
+
<p><em>NOTE: The NetLinx compiler executable provided by AMX, nlrc.exe, must
|
197
|
+
be installed on your computer for this utility to work. It is included in
|
198
|
+
the NetLinx Studio installation by default.</em></p>
|
199
|
+
|
200
|
+
<p><strong>If you receive the following error when running gem
|
201
|
+
install:</strong> <code>Unable to download data from https://rubygems.org/
|
202
|
+
- SSL_connect returned=1</code></p>
|
203
|
+
|
204
|
+
<p>Follow this guide: <a
|
205
|
+
href="https://gist.github.com/luislavena/f064211759ee0f806c88">Workaround
|
206
|
+
RubyGems’ SSL errors on Ruby for Windows (RubyInstaller)</a></p>
|
207
|
+
|
208
|
+
<h2 id="label-Prerequisite+Knowledge">Prerequisite Knowledge</h2>
|
209
|
+
|
210
|
+
<p>netlinx-erb is a complex utility and does have a learning curve. However,
|
211
|
+
the time invested in learning this utility pays off in time saved from
|
212
|
+
generating code that would otherwise be handwritten, and troubleshooting
|
213
|
+
fewer bugs. Due to this, project maintenance also becomes easier.</p>
|
214
|
+
|
215
|
+
<p>Basic experience with the <a href="https://www.ruby-lang.org">Ruby
|
216
|
+
programming language</a> is required, as well as <a
|
217
|
+
href="http://www.stuartellis.eu/articles/erb/">ERB templating</a>.</p>
|
218
|
+
|
219
|
+
<h2 id="label-Getting+Started">Getting Started</h2>
|
220
|
+
|
221
|
+
<h2 id="label-Code+Examples">Code Examples</h2>
|
75
222
|
</div></div>
|
76
223
|
|
77
224
|
<div id="footer">
|
78
|
-
Generated on
|
225
|
+
Generated on Wed Feb 25 14:28:06 2015 by
|
79
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
80
227
|
0.8.7.6 (ruby-2.1.3).
|
81
228
|
</div>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on
|
108
|
+
Generated on Wed Feb 25 14:28:07 2015 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.8.7.6 (ruby-2.1.3).
|
111
111
|
</div>
|
data/lib/netlinx-erb.rb
CHANGED
data/lib/netlinx/erb/rpc.rb
CHANGED
@@ -1,26 +1,3 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
# The MIT License (MIT)
|
3
|
-
|
4
|
-
# Copyright (c) 2014 Alex McLain and Joe McIlvain
|
5
|
-
|
6
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
-
# of this software and associated documentation files (the "Software"), to deal
|
8
|
-
# in the Software without restriction, including without limitation the rights
|
9
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
# copies of the Software, and to permit persons to whom the Software is
|
11
|
-
# furnished to do so, subject to the following conditions:
|
12
|
-
|
13
|
-
# The above copyright notice and this permission notice shall be included in
|
14
|
-
# all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
-
# THE SOFTWARE.
|
23
|
-
# -----------------------------------------------------------------------------
|
24
1
|
|
25
2
|
require 'netlinx/workspace'
|
26
3
|
|
@@ -35,42 +12,42 @@ class RPC
|
|
35
12
|
Does not have to exist.
|
36
13
|
)
|
37
14
|
^(?<desc>[\t ]*\/\*(?:[^\*]|\*[^\/])*\*\/)?\s*
|
38
|
-
|
15
|
+
|
39
16
|
(?# Find the function definition. )
|
40
17
|
define_function\s+
|
41
|
-
|
18
|
+
|
42
19
|
(?# Capture function's return type, if it exists.)
|
43
20
|
(?<rtn>\w+(?<width>\[\d+\])?)??\s*
|
44
|
-
|
21
|
+
|
45
22
|
(?# Capture the function name. )
|
46
23
|
(?<name>\w+)
|
47
|
-
|
24
|
+
|
48
25
|
(?#
|
49
26
|
Capture the function parameters.
|
50
27
|
Run this through another regex to get the type\\name pairs.
|
51
28
|
)
|
52
29
|
\(\s*(?<params>.*?)\s*\)\s*
|
53
|
-
|
30
|
+
|
54
31
|
(?# Capture the function's source code. )
|
55
32
|
{[\r\n]*(?<code>(?:.|\r|\n)*?)?[\r\n]*}
|
56
33
|
/x
|
57
|
-
|
34
|
+
|
58
35
|
param_exp = /\s*(?:(?<type>\w+)\s+(?<name>\w+(?<width>\[\d*\])?)),?\s*/
|
59
|
-
|
36
|
+
|
60
37
|
sections = {} # Collect a set of matches for each file, separated by file.
|
61
|
-
|
62
|
-
|
38
|
+
|
39
|
+
|
63
40
|
# Pull file list from workspace.
|
64
|
-
|
65
|
-
|
66
|
-
|
41
|
+
workspace = NetLinx::Workspace.search
|
42
|
+
raise Errno::ENOENT, 'Workspace not found.' unless workspace
|
43
|
+
|
67
44
|
file_paths = workspace.projects.first.systems.first.files
|
68
45
|
.map(&:path)
|
69
46
|
.select { |path| path =~ /(\.axi|\.axs)$/ }
|
70
47
|
.reject { |path| path =~ /rpc(?:-|_.*?)?\.axi/ } # Remove RPC files.
|
71
|
-
|
48
|
+
|
72
49
|
# file_paths = Dir['**/*.axi']
|
73
|
-
|
50
|
+
|
74
51
|
file_paths.each do |f|
|
75
52
|
str = File.open(f.gsub('\\', '/'), "r:iso-8859-1").read
|
76
53
|
matches = []
|
@@ -82,47 +59,47 @@ class RPC
|
|
82
59
|
|
83
60
|
sections[f] = matches
|
84
61
|
end
|
85
|
-
|
62
|
+
|
86
63
|
# -----------------------
|
87
64
|
# Documentation Generator
|
88
65
|
# -----------------------
|
89
|
-
|
66
|
+
|
90
67
|
# output = ''
|
91
68
|
# sections.each do |name, matches|
|
92
|
-
|
69
|
+
|
93
70
|
# output << "--------------------------------------------------\n"
|
94
71
|
# output << "FILE: '#{name}'\n"
|
95
72
|
# output << "--------------------------------------------------\n"
|
96
73
|
# output << "\n\n"
|
97
|
-
|
74
|
+
|
98
75
|
# matches.each do |m|
|
99
76
|
# output << m[:desc].to_s
|
100
77
|
# output << "\n"
|
101
78
|
# output << m[:name].to_s
|
102
79
|
# output << "\n\n\n"
|
103
80
|
# end
|
104
|
-
|
81
|
+
|
105
82
|
# end
|
106
|
-
|
83
|
+
|
107
84
|
# File.open('functions.axi', 'w+') { |f| f << output }
|
108
|
-
|
109
|
-
|
85
|
+
|
86
|
+
|
110
87
|
# ----------------------
|
111
88
|
# RPC Function Generator
|
112
89
|
# ----------------------
|
113
|
-
|
90
|
+
|
114
91
|
# Generate list of included and excluded files for sanity check.
|
115
92
|
directory_files = Dir['**/*.axi'] + Dir['**/*.axs']
|
116
|
-
|
93
|
+
|
117
94
|
included_files = ''
|
118
95
|
file_paths.each { |path| included_files << path.to_s.gsub('\\', '/') + "\n" } # TODO: As string.
|
119
|
-
|
96
|
+
|
120
97
|
excluded_files = ''
|
121
98
|
(directory_files - file_paths.map { |path| path.gsub '\\', '/' }).each { |path| excluded_files << path.to_s.gsub('\\', '/') + "\n" }
|
122
|
-
|
99
|
+
|
123
100
|
fn_symbols = [] # Symbol names to avoid duplicates.
|
124
101
|
output = ''
|
125
|
-
|
102
|
+
|
126
103
|
output << <<-EOS
|
127
104
|
(***********************************************************)
|
128
105
|
(* WARNING *)
|
@@ -208,9 +185,9 @@ EOS
|
|
208
185
|
|
209
186
|
fn_output << "#{fn[:name]}("
|
210
187
|
fn_output << ");\n" if params.empty?
|
211
|
-
|
188
|
+
|
212
189
|
function_valid = false unless [nil, :integer].include? return_type
|
213
|
-
|
190
|
+
|
214
191
|
# Generate parameters.
|
215
192
|
param_index = 0
|
216
193
|
params.each do |param|
|
@@ -247,7 +224,7 @@ EOS
|
|
247
224
|
end
|
248
225
|
|
249
226
|
fn_output << " }\n\n"
|
250
|
-
|
227
|
+
|
251
228
|
# Store function string.
|
252
229
|
if function_valid
|
253
230
|
output << fn_output
|
@@ -258,13 +235,13 @@ EOS
|
|
258
235
|
end
|
259
236
|
|
260
237
|
end
|
261
|
-
|
238
|
+
|
262
239
|
output << " }\n"
|
263
240
|
output << "}\n"
|
264
241
|
output << "#end_if\n\n"
|
265
|
-
|
266
|
-
|
242
|
+
|
243
|
+
|
267
244
|
File.open('include/rpc-functions.axi', 'w+') { |f| f << output }
|
268
245
|
end
|
269
246
|
|
270
|
-
end
|
247
|
+
end
|