netlinx-compile 1.0.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.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/README.txt +2 -0
  3. data/bin/netlinx-compile +4 -0
  4. data/doc/NetLinx.html +151 -0
  5. data/doc/NetLinx/Compile.html +148 -0
  6. data/doc/NetLinx/Compile/Extension.html +145 -0
  7. data/doc/NetLinx/Compile/Extension/AXS.html +154 -0
  8. data/doc/NetLinx/Compile/ExtensionDiscovery.html +324 -0
  9. data/doc/NetLinx/Compile/ExtensionHandler.html +396 -0
  10. data/doc/NetLinx/Compile/Script.html +293 -0
  11. data/doc/NetLinx/Compiler.html +295 -0
  12. data/doc/NetLinx/CompilerResult.html +501 -0
  13. data/doc/NetLinx/NoCompilerError.html +155 -0
  14. data/doc/NetLinx/SourceFile.html +430 -0
  15. data/doc/Test.html +147 -0
  16. data/doc/Test/NetLinx.html +147 -0
  17. data/doc/Test/NetLinx/Compilable.html +148 -0
  18. data/doc/Test/NetLinx/Compile.html +146 -0
  19. data/doc/Test/NetLinx/Compile/Discoverable.html +148 -0
  20. data/doc/Test/NetLinx/Compile/Invokable.html +149 -0
  21. data/doc/created.rid +12 -0
  22. data/doc/images/add.png +0 -0
  23. data/doc/images/arrow_up.png +0 -0
  24. data/doc/images/brick.png +0 -0
  25. data/doc/images/brick_link.png +0 -0
  26. data/doc/images/bug.png +0 -0
  27. data/doc/images/bullet_black.png +0 -0
  28. data/doc/images/bullet_toggle_minus.png +0 -0
  29. data/doc/images/bullet_toggle_plus.png +0 -0
  30. data/doc/images/date.png +0 -0
  31. data/doc/images/delete.png +0 -0
  32. data/doc/images/find.png +0 -0
  33. data/doc/images/loadingAnimation.gif +0 -0
  34. data/doc/images/macFFBgHack.png +0 -0
  35. data/doc/images/package.png +0 -0
  36. data/doc/images/page_green.png +0 -0
  37. data/doc/images/page_white_text.png +0 -0
  38. data/doc/images/page_white_width.png +0 -0
  39. data/doc/images/plugin.png +0 -0
  40. data/doc/images/ruby.png +0 -0
  41. data/doc/images/tag_blue.png +0 -0
  42. data/doc/images/tag_green.png +0 -0
  43. data/doc/images/transparent.png +0 -0
  44. data/doc/images/wrench.png +0 -0
  45. data/doc/images/wrench_orange.png +0 -0
  46. data/doc/images/zoom.png +0 -0
  47. data/doc/index.html +103 -0
  48. data/doc/js/darkfish.js +155 -0
  49. data/doc/js/jquery.js +18 -0
  50. data/doc/js/navigation.js +142 -0
  51. data/doc/js/search.js +94 -0
  52. data/doc/js/search_index.js +1 -0
  53. data/doc/js/searcher.js +228 -0
  54. data/doc/rdoc.css +595 -0
  55. data/doc/table_of_contents.html +138 -0
  56. data/lib/netlinx-compile.rb +1 -0
  57. data/lib/netlinx/compile/extension/axs.rb +18 -0
  58. data/lib/netlinx/compile/extension_discovery.rb +62 -0
  59. data/lib/netlinx/compile/extension_handler.rb +86 -0
  60. data/lib/netlinx/compile/script.rb +115 -0
  61. data/lib/netlinx/compiler.rb +71 -0
  62. data/lib/netlinx/compiler_result.rb +72 -0
  63. data/lib/netlinx/source_file.rb +78 -0
  64. data/lib/test/netlinx/compilable.rb +48 -0
  65. data/lib/test/netlinx/compile/discoverable.rb +14 -0
  66. data/lib/test/netlinx/compile/invokable.rb +15 -0
  67. data/license.txt +13 -0
  68. metadata +156 -0
@@ -0,0 +1,72 @@
1
+ module NetLinx
2
+ # Contains info pertaining to a job run through the compiler.
3
+ class CompilerResult
4
+ # The raw stream of text returned by the compiler.
5
+ attr_reader :stream
6
+ # Number of compiler errors.
7
+ attr_reader :errors
8
+ # Number of compiler warnings.
9
+ attr_reader :warnings
10
+
11
+ # Implement the Compilable interface.
12
+
13
+ # See Compilable interface.
14
+ attr_reader :compiler_target_files
15
+ # See Compilable interface.
16
+ attr_reader :compiler_include_paths
17
+ # See Compilable interface.
18
+ attr_reader :compiler_module_paths
19
+ # See Compilable interface.
20
+ attr_reader :compiler_library_paths
21
+
22
+ # Args:
23
+ # stream -- The raw stream of text returned by the compiler.
24
+ # compiler_target_files -- See Compilable interface.
25
+ # compiler_include_paths -- See Compilable interface.
26
+ # compiler_module_paths -- See Compilable interface.
27
+ # compiler_library_paths -- See Compilable interface.
28
+ def initialize(**kvargs)
29
+ @stream = kvargs.fetch :stream, ''
30
+
31
+ @compiler_target_files = kvargs.fetch :compiler_target_files, []
32
+ @compiler_include_paths = kvargs.fetch :compiler_include_paths, []
33
+ @compiler_module_paths = kvargs.fetch :compiler_module_paths, []
34
+ @compiler_library_paths = kvargs.fetch :compiler_library_paths, []
35
+
36
+ # Capture error and warning counts.
37
+ @errors = nil
38
+ @warnings = nil
39
+
40
+ @stream.scan /(\d+) error\(s\), (\d+) warning\(s\)/ do |e, w|
41
+ @errors = e.to_i if e
42
+ @warnings = w.to_i if w
43
+ end
44
+ end
45
+
46
+ # Alias of #stream.
47
+ def to_s
48
+ @stream
49
+ end
50
+
51
+ # Returns the absolute path of the source code file that was compiled.
52
+ def target_file
53
+ @compiler_target_files.first
54
+ end
55
+
56
+ # Compile was successful?
57
+ def success?
58
+ @errors == 0 && @warnings == 0
59
+ end
60
+
61
+ # An enumerable list of warnings.
62
+ def warning_items
63
+ @stream.scan(/(^WARNING: .*$)/).map {|i| i.first}
64
+ end
65
+
66
+ # An enumerable list of errors.
67
+ def error_items
68
+ @stream.scan(/(^ERROR: .*$)/).map {|i| i.first}
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,78 @@
1
+ module NetLinx
2
+ class SourceFile
3
+
4
+ # Parameters:
5
+ # file: Name or path of the file to compile.
6
+ # compiler_include_paths: Array of additional paths for the compiler to find include files.
7
+ # compiler_module_paths: Array of additional paths for the compiler to find module files.
8
+ # NOTE: SourceFile already searches the body of the source file to automatically determine
9
+ # include and module paths.
10
+ def initialize(**kvargs)
11
+ @compiler_target_files = [ (kvargs.fetch :file, nil) ]
12
+ @compiler_include_paths = kvargs.fetch :compiler_include_paths, []
13
+ @compiler_module_paths = kvargs.fetch :compiler_module_paths, []
14
+
15
+ return unless @compiler_target_files.first
16
+
17
+ source_code = File.open(@compiler_target_files.first).read
18
+
19
+ # Scan file for additional include paths.
20
+ includes = source_code.scan(/(?i)^\s*(?:\#include)\s+'([\w\-]+)'/)
21
+
22
+ includes.each do |inc|
23
+ inc = inc.first
24
+
25
+ path = Dir["./**/#{inc}.*"].first
26
+ next unless path
27
+
28
+ path = File.expand_path path
29
+ @compiler_include_paths << File.dirname(path)
30
+ end
31
+
32
+ @compiler_include_paths.uniq!
33
+
34
+ # Scan file for additional module paths.
35
+ modules = source_code.scan(/(?i)^\s*(?:define_module)\s+'([\w\-]+)'/)
36
+
37
+ modules.each do |mod|
38
+ mod = mod.first
39
+
40
+ path = Dir["./**/#{mod}.*"].first
41
+ next unless path
42
+
43
+ path = File.expand_path path
44
+ @compiler_module_paths << File.dirname(path)
45
+ end
46
+
47
+ @compiler_module_paths.uniq!
48
+ end
49
+
50
+ # See Test::NetLinx::Compilable interface.
51
+ def compiler_target_files
52
+ @compiler_target_files
53
+ end
54
+
55
+ # See Test::NetLinx::Compilable interface.
56
+ def compiler_include_paths
57
+ @compiler_include_paths
58
+ end
59
+
60
+ # See Test::NetLinx::Compilable interface.
61
+ def compiler_module_paths
62
+ @compiler_module_paths
63
+ end
64
+
65
+ # See Test::NetLinx::Compilable interface.
66
+ def compiler_library_paths
67
+ []
68
+ end
69
+
70
+ # Execute the compiler on itself.
71
+ def compile
72
+ require 'netlinx/compiler'
73
+ compiler = NetLinx::Compiler.new
74
+ result = compiler.compile self
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,48 @@
1
+ module Test
2
+ module NetLinx
3
+ # Interface tests for an object that can be compiled with NetLinx::Compiler.
4
+ module Compilable
5
+
6
+ # :nodoc:
7
+ def test_responds_to_compiler_target_files
8
+ assert_respond_to @object, :compiler_target_files
9
+ end
10
+
11
+ # :nodoc:
12
+ def test_responds_to_compiler_include_paths
13
+ assert_respond_to @object, :compiler_include_paths
14
+ end
15
+
16
+ # :nodoc:
17
+ def test_responds_to_compiler_library_paths
18
+ assert_respond_to @object, :compiler_library_paths
19
+ end
20
+
21
+ # :nodoc:
22
+ def test_responds_to_compiler_module_paths
23
+ assert_respond_to @object, :compiler_module_paths
24
+ end
25
+
26
+ # :nodoc:
27
+ def test_compiler_target_files_is_an_array
28
+ assert @object.compiler_target_files.is_a? Array
29
+ end
30
+
31
+ # :nodoc:
32
+ def test_compiler_include_paths_is_an_array
33
+ assert @object.compiler_include_paths.is_a? Array
34
+ end
35
+
36
+ # :nodoc:
37
+ def test_compiler_library_paths_is_an_array
38
+ assert @object.compiler_library_paths.is_a? Array
39
+ end
40
+
41
+ # :nodoc:
42
+ def test_compiler_module_paths_is_an_array
43
+ assert @object.compiler_module_paths.is_a? Array
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,14 @@
1
+ module Test
2
+ module NetLinx
3
+ module Compile
4
+ # Interface tests for an object that registers an EventHandler
5
+ # under NetLinx::Compile::Extension.
6
+ module Discoverable
7
+ # :nodoc:
8
+ def test_responds_to_get_handler
9
+ assert_respond_to @object, :get_handler
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Test
2
+ module NetLinx
3
+ module Compile
4
+ # Interface tests for an object that provides a means to
5
+ # invoke the compiler on a Compilable file extension.
6
+ # See ExtensionDiscovery.
7
+ module Invokable
8
+ # :nodoc:
9
+ def test_responds_to_compile
10
+ assert_respond_to @object, :compile
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ Copyright 2013 Alex McLain
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netlinx-compile
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex McLain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This library provides an executable, netlinx-compile, that wraps the
56
+ nlrc.exe NetLinx compiler provided by AMX. It is designed for easier command line
57
+ access, as well as for integration with third-party tools with source code build
58
+ support, like text editors and IDE's. Also provided in this library is a Ruby API
59
+ for invoking the NetLinx compiler.
60
+ email: alex@alexmclain.com
61
+ executables:
62
+ - netlinx-compile
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - license.txt
67
+ - README.txt
68
+ - bin/netlinx-compile
69
+ - lib/netlinx/compile/extension/axs.rb
70
+ - lib/netlinx/compile/extension_discovery.rb
71
+ - lib/netlinx/compile/extension_handler.rb
72
+ - lib/netlinx/compile/script.rb
73
+ - lib/netlinx/compiler.rb
74
+ - lib/netlinx/compiler_result.rb
75
+ - lib/netlinx/source_file.rb
76
+ - lib/netlinx-compile.rb
77
+ - lib/test/netlinx/compilable.rb
78
+ - lib/test/netlinx/compile/discoverable.rb
79
+ - lib/test/netlinx/compile/invokable.rb
80
+ - doc/created.rid
81
+ - doc/images/add.png
82
+ - doc/images/arrow_up.png
83
+ - doc/images/brick.png
84
+ - doc/images/brick_link.png
85
+ - doc/images/bug.png
86
+ - doc/images/bullet_black.png
87
+ - doc/images/bullet_toggle_minus.png
88
+ - doc/images/bullet_toggle_plus.png
89
+ - doc/images/date.png
90
+ - doc/images/delete.png
91
+ - doc/images/find.png
92
+ - doc/images/loadingAnimation.gif
93
+ - doc/images/macFFBgHack.png
94
+ - doc/images/package.png
95
+ - doc/images/page_green.png
96
+ - doc/images/page_white_text.png
97
+ - doc/images/page_white_width.png
98
+ - doc/images/plugin.png
99
+ - doc/images/ruby.png
100
+ - doc/images/tag_blue.png
101
+ - doc/images/tag_green.png
102
+ - doc/images/transparent.png
103
+ - doc/images/wrench.png
104
+ - doc/images/wrench_orange.png
105
+ - doc/images/zoom.png
106
+ - doc/index.html
107
+ - doc/js/darkfish.js
108
+ - doc/js/jquery.js
109
+ - doc/js/navigation.js
110
+ - doc/js/search.js
111
+ - doc/js/searcher.js
112
+ - doc/js/search_index.js
113
+ - doc/NetLinx/Compile/Extension/AXS.html
114
+ - doc/NetLinx/Compile/Extension.html
115
+ - doc/NetLinx/Compile/ExtensionDiscovery.html
116
+ - doc/NetLinx/Compile/ExtensionHandler.html
117
+ - doc/NetLinx/Compile/Script.html
118
+ - doc/NetLinx/Compile.html
119
+ - doc/NetLinx/Compiler.html
120
+ - doc/NetLinx/CompilerResult.html
121
+ - doc/NetLinx/NoCompilerError.html
122
+ - doc/NetLinx/SourceFile.html
123
+ - doc/NetLinx.html
124
+ - doc/rdoc.css
125
+ - doc/table_of_contents.html
126
+ - doc/Test/NetLinx/Compilable.html
127
+ - doc/Test/NetLinx/Compile/Discoverable.html
128
+ - doc/Test/NetLinx/Compile/Invokable.html
129
+ - doc/Test/NetLinx/Compile.html
130
+ - doc/Test/NetLinx.html
131
+ - doc/Test.html
132
+ homepage: https://sourceforge.net/projects/netlinx-compile/
133
+ licenses:
134
+ - Apache 2.0
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.0.3
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: A wrapper utility for the AMX NetLinx compiler.
156
+ test_files: []