Tells netlinx-compile which class handles the compiling of a set of file extensions.
A list of file extensions that this ExtensionHandler handles.
The class to invoke to handle compiling a file extension specified in this ExtensionHandler.
A list of file extensions that this ExtensionHandler usurps. For example, third-party workspace extensions would probably usurp the .apw workspace extension.
Parameters:
extensions: An array of file extensions (without the leading dot) that this ExtensionHandler supports. usurps: Future. Lets this ExtensionHandler take priority over other ones. For example, most third-party handlers would probably usurp the .apw NetLinx Studio workspace extension. is_a_workspace: Set to true if this ExtensionHandler is for compiling a workspace. False by default. This parameter assists with smart compiling, as ExtensionDiscovery can return all workspace_handlers. handler_class: A reference to the class that should be instantiated if this handler is selected. For example, NetLinx::SourceFile is the class that handles files with the .axs extension.
# File lib/netlinx/compile/extension_handler.rb, line 37 def initialize(**kvargs) @extensions = kvargs.fetch :extensions, [] @usurps = kvargs.fetch :usurps, [] @is_a_workspace = kvargs.fetch :is_a_workspace, false @handler_class = kvargs.fetch :handler_class, nil end
Alias to add a file extension.
# File lib/netlinx/compile/extension_handler.rb, line 45 def <<(file_extension) @extensions << parse_extension(file_extension) end
Returns true if this ExtensionHandler can handle the specified file extension.
# File lib/netlinx/compile/extension_handler.rb, line 64 def include?(file_extension) @extensions.include? parse_extension(file_extension) end
Returns true if the ExtensionHandler handles a workspace file (as opposed to a source code file).
Workspace files are significant because they contain information about a project, connection settings for a master, and possibly multiple systems that need to be compiled. Therefore, when smart-compiling, workspaces need to be distinguished from source code files because discovering a workspace should be considered a better match than discovering a source code file.
# File lib/netlinx/compile/extension_handler.rb, line 58 def is_a_workspace? @is_a_workspace end