netlinx-compile 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -108,7 +108,7 @@ href="https://sourceforge.net/p/netlinx-compile/wiki/Home/">sourceforge.net/p/ne
108
108
  </div></div>
109
109
 
110
110
  <div id="footer">
111
- Generated on Mon Jan 26 15:35:58 2015 by
111
+ Generated on Mon Jan 26 15:36:24 2015 by
112
112
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
113
113
  0.8.7.6 (ruby-2.1.5).
114
114
  </div>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Mon Jan 26 15:35:58 2015 by
106
+ Generated on Mon Jan 26 15:36:24 2015 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.6 (ruby-2.1.5).
109
109
  </div>
@@ -1 +1,11 @@
1
- require 'netlinx/compiler'
1
+ require 'netlinx/compiler'
2
+
3
+ # :nodoc:
4
+ module NetLinx
5
+ # :nodoc:
6
+ module Compile
7
+ # :nodoc:
8
+ module Extension
9
+ end
10
+ end
11
+ end
@@ -43,7 +43,7 @@ module NetLinx
43
43
  .select{|c| not c.nil?}
44
44
  end
45
45
 
46
- # Returns an array of workspace file extensions.
46
+ # @return [Array<String>] workspace file extensions.
47
47
  def workspace_extensions
48
48
  @handlers
49
49
  .select{|h| h.is_a_workspace?}
@@ -51,7 +51,9 @@ module NetLinx
51
51
  .flatten
52
52
  end
53
53
 
54
- # Get an ExtensionHandler for a given file or extension.
54
+ # @param filename [String] File or extension to find a
55
+ # {NetLinx::Compile::ExtensionHandler} for.
56
+ # @return [ExtensionHandler]
55
57
  def get_handler(filename)
56
58
  @handlers.select{|h| h.include? filename}.first
57
59
  end
@@ -15,30 +15,28 @@ module NetLinx
15
15
  # in this ExtensionHandler.
16
16
  attr_reader :handler_class
17
17
 
18
- # Parameters:
19
- # extensions: An array of file extensions (without the leading dot)
20
- # that this ExtensionHandler supports.
18
+ # @option kwargs [Array<String>] :extensions File extensions (without the
19
+ # leading dot) that this ExtensionHandler supports.
21
20
  #
22
- # usurps: Future.
23
- # Lets this ExtensionHandler take priority over other
24
- # ones. For example, most third-party handlers would
25
- # probably usurp the .apw NetLinx Studio workspace
26
- # extension.
21
+ # @option kwargs [Array<String>] :usurps Future.
22
+ # Lets this ExtensionHandler take priority over other ones. For example,
23
+ # most third-party handlers would probably usurp the .apw NetLinx Studio
24
+ # workspace extension.
27
25
  #
28
- # is_a_workspace: Set to true if this ExtensionHandler is for
29
- # compiling a workspace. False by default. This
30
- # parameter assists with smart compiling, as
31
- # ExtensionDiscovery can return all workspace_handlers.
26
+ # @option kwargs [Boolean] :is_a_workspace Set to true if this
27
+ # ExtensionHandler is for compiling a workspace. False by default. This
28
+ # parameter assists with smart compiling, as {ExtensionDiscovery} can
29
+ # return all workspace_handlers.
32
30
  #
33
- # handler_class: A reference to the class that should be instantiated
34
- # if this handler is selected. For example,
35
- # NetLinx::SourceFile is the class that handles files
36
- # with the .axs extension.
37
- def initialize(**kvargs)
38
- @extensions = kvargs.fetch :extensions, []
39
- @usurps = kvargs.fetch :usurps, []
40
- @is_a_workspace = kvargs.fetch :is_a_workspace, false
41
- @handler_class = kvargs.fetch :handler_class, nil
31
+ # @option kwargs [Extension] :handler_class A reference to the class that
32
+ # should be instantiated if this handler is selected. For example,
33
+ # {NetLinx::SourceFile} is the class that handles files with the .axs
34
+ # extension.
35
+ def initialize(**kwargs)
36
+ @extensions = kwargs.fetch :extensions, []
37
+ @usurps = kwargs.fetch :usurps, []
38
+ @is_a_workspace = kwargs.fetch :is_a_workspace, false
39
+ @handler_class = kwargs.fetch :handler_class, nil
42
40
  end
43
41
 
44
42
  # Alias to add a file extension.
@@ -46,8 +44,8 @@ module NetLinx
46
44
  @extensions << parse_extension(file_extension)
47
45
  end
48
46
 
49
- # Returns true if the ExtensionHandler handles a workspace file
50
- # (as opposed to a source code file).
47
+ # @return [Boolean] true if the {ExtensionHandler} handles a workspace file
48
+ # (as opposed to a source code file).
51
49
  #
52
50
  # Workspace files are significant because they contain information
53
51
  # about a project, connection settings for a master, and possibly
@@ -59,7 +57,7 @@ module NetLinx
59
57
  @is_a_workspace
60
58
  end
61
59
 
62
- # Returns true if this ExtensionHandler can handle the specified
60
+ # Returns true if this {ExtensionHandler} can handle the specified
63
61
  # file extension.
64
62
  def include?(file_extension)
65
63
  @extensions.include? parse_extension(file_extension)
@@ -69,7 +67,7 @@ module NetLinx
69
67
 
70
68
  # Parse a file extension from the given string.
71
69
  #
72
- # Examples:
70
+ # @example
73
71
  # apw
74
72
  # .apw
75
73
  # workspace.apw
@@ -10,9 +10,10 @@ module NetLinx
10
10
 
11
11
  class << self
12
12
  # Run the script.
13
- def run(**kvargs)
14
- # :argv is a convenience to override ARGV, like for testing.
15
- args = kvargs.fetch :argv, ARGV
13
+ # @option kwargs [Array<String>] :argv A convenience to override ARGV,
14
+ # like for testing.
15
+ def run(**kwargs)
16
+ args = kwargs.fetch :argv, ARGV
16
17
 
17
18
  # Command line options.
18
19
  @options = OpenStruct.new \
@@ -2,38 +2,54 @@ require 'netlinx/compiler_result'
2
2
 
3
3
  module NetLinx
4
4
  # Raised when the NetLinx compiler (nlrc.exe) cannot be found on the system.
5
- # See NetLinx::Compiler.
5
+ # @see NetLinx::Compiler
6
6
  class NoCompilerError < Exception; end
7
7
 
8
8
  # A wrapper class for the AMX NetLinx compiler executable (nlrc.exe).
9
9
  class Compiler
10
10
 
11
11
  # Checks for the AMX NetLinx compiler (third-party software, nlrc.exe) at the
12
- # default installation path. This can be overridden by specifying :compiler_path.
13
- def initialize(**kvargs)
14
- @compiler_exe = 'nlrc.exe'
12
+ # default installation path.
13
+ #
14
+ # @option kwargs [String] :compiler_exe ('nlrc.exe')
15
+ # @option kwargs [String] :compiler_path Recommend a directory to look for
16
+ # the compiler_exe.
17
+ # @option kwargs [String] :use_wine (false) Set to true to force `wine` at
18
+ # the front of the compiler command. This is automatic if nlrc.exe is
19
+ # installed at Wine's default Program Files path.
20
+ # @raise [NetLinx::NoCompilerError] Compiler not found.
21
+ def initialize(**kwargs)
22
+ @compiler_exe = kwargs.fetch :compiler_exe, 'nlrc.exe'
23
+ user_specified_path = kwargs.fetch :compiler_path, nil
24
+ @use_wine = kwargs.fetch :use_wine, false
15
25
 
16
- @compiler_path = kvargs.fetch :compiler_path,
17
- File.expand_path('C:\Program Files (x86)\Common Files\AMXShare\COM') # 64-bit O/S path
18
-
19
- # Check for NetLinx compiler at :compiler_path or the 64-bit O/S path.
20
- unless File.exists? File.expand_path('nlrc.exe', @compiler_path)
21
- # Compiler not found. Try 32-bit O/S path.
22
- @compiler_path = File.expand_path('C:\Program Files\Common Files\AMXShare\COM')
23
- unless File.exists? File.expand_path('nlrc.exe', @compiler_path)
24
- # ---------------------------------------------------------
25
- # TODO: Check if the compiler was added to the system path.
26
- # Execute system('nlrc').
27
- # ---------------------------------------------------------
28
-
29
- # Compiler not found.
30
- raise NetLinx::NoCompilerError, 'The NetLinx compiler (nlrc.exe) could not be found on the system.'
26
+ default_paths = [
27
+ user_specified_path,
28
+ 'C:\Program Files (x86)\Common Files\AMXShare\COM', # 64-bit O/S path
29
+ 'C:\Program Files\Common Files\AMXShare\COM', # 32-bit O/S path
30
+ '~/.wine/drive_c/Program\ Files/Common\ Files/AMXShare/COM', # Wine path
31
+ ].compact
32
+
33
+ # Check for NetLinx compiler.
34
+ default_paths.each do |path|
35
+ if File.exists? File.expand_path(@compiler_exe, path)
36
+ @compiler_path = path
37
+ break
31
38
  end
32
39
  end
40
+
41
+ # ---------------------------------------------------------
42
+ # TODO: Check if the compiler was added to the system path.
43
+ # Execute system(@compiler_exe).
44
+ # ---------------------------------------------------------
45
+
46
+ # Compiler not found.
47
+ raise NetLinx::NoCompilerError, "The NetLinx compiler (#{@compiler_exe}) could not be found on the system." \
48
+ unless @compiler_path
33
49
  end
34
50
 
35
51
  # Compile the specified object with the NetLinx compiler.
36
- # See Test::NetLinx::Compilable.
52
+ # @see Test::NetLinx::Compilable.
37
53
  def compile(compilable)
38
54
  compiler = File.expand_path @compiler_exe, @compiler_path
39
55
  result = []
@@ -51,7 +67,9 @@ module NetLinx
51
67
 
52
68
  # Run the NetLinx compiler.
53
69
  # Note: NLRC.exe v2.1 freaks out if empty arguments ("") are in the command.
54
- cmd = "\"#{compiler}\" \"#{target_file}\""
70
+ cmd = ''
71
+ cmd += 'wine ' if @use_wine or compiler.include? '/.wine/'
72
+ cmd += "\"#{compiler}\" \"#{target_file}\""
55
73
  cmd += " \"#{include_paths}\"" if include_paths
56
74
  cmd += " \"#{module_paths}\"" if module_paths
57
75
  cmd += " \"#{library_paths}\"" if library_paths
@@ -19,19 +19,18 @@ module NetLinx
19
19
  # See Compilable interface.
20
20
  attr_reader :compiler_library_paths
21
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, ''
22
+ # @option kwargs [String] :stream The raw stream of text returned by the compiler.
23
+ # @option kwargs [Array<String>] :compiler_target_files See Compilable interface.
24
+ # @option kwargs [Array<String>] :compiler_include_paths See Compilable interface.
25
+ # @option kwargs [Array<String>] :compiler_module_paths See Compilable interface.
26
+ # @option kwargs [Array<String>] :compiler_library_paths See Compilable interface.
27
+ def initialize(**kwargs)
28
+ @stream = kwargs.fetch :stream, ''
30
29
 
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, []
30
+ @compiler_target_files = kwargs.fetch :compiler_target_files, []
31
+ @compiler_include_paths = kwargs.fetch :compiler_include_paths, []
32
+ @compiler_module_paths = kwargs.fetch :compiler_module_paths, []
33
+ @compiler_library_paths = kwargs.fetch :compiler_library_paths, []
35
34
 
36
35
  # Capture error and warning counts.
37
36
  @errors = nil
@@ -43,27 +42,27 @@ module NetLinx
43
42
  end
44
43
  end
45
44
 
46
- # Alias of #stream.
45
+ # Alias of {#stream}.
47
46
  def to_s
48
47
  @stream
49
48
  end
50
49
 
51
- # Returns the absolute path of the source code file that was compiled.
50
+ # @return [String] the absolute path of the source code file that was compiled.
52
51
  def target_file
53
52
  @compiler_target_files.first
54
53
  end
55
54
 
56
- # Compile was successful?
55
+ # @return [Boolean] true if compile was successful.
57
56
  def success?
58
57
  @errors == 0 && @warnings == 0
59
58
  end
60
59
 
61
- # An enumerable list of warnings.
60
+ # @return [Array<String>] a list of warnings.
62
61
  def warning_items
63
62
  @stream.scan(/(^WARNING: .*$)/).map {|i| i.first}
64
63
  end
65
64
 
66
- # An enumerable list of errors.
65
+ # @return [Array<String>] a list of errors.
67
66
  def error_items
68
67
  @stream.scan(/(^ERROR: .*$)/).map {|i| i.first}
69
68
  end
@@ -1,16 +1,18 @@
1
1
  module NetLinx
2
+ # A NetLinx source code file.
3
+ # Typically .axs or .axi.
2
4
  class SourceFile
3
5
 
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, []
6
+ # NOTE: SourceFile searches the body of the source file to automatically
7
+ # determine include and module paths.
8
+ #
9
+ # @option kwargs [String] :file Name or path of the file to compile.
10
+ # @option kwargs [Array<String>] :compiler_include_paths Additional paths for the compiler to find include files.
11
+ # @option kwargs [Array<String>] :compiler_module_paths Additional paths for the compiler to find module files.
12
+ def initialize(**kwargs)
13
+ @compiler_target_files = [ kwargs.fetch(:file, nil) ]
14
+ @compiler_include_paths = kwargs.fetch :compiler_include_paths, []
15
+ @compiler_module_paths = kwargs.fetch :compiler_module_paths, []
14
16
 
15
17
  return unless @compiler_target_files.first
16
18
 
@@ -47,22 +49,22 @@ module NetLinx
47
49
  @compiler_module_paths.uniq!
48
50
  end
49
51
 
50
- # See Test::NetLinx::Compilable interface.
52
+ # @see _ lib/test/netlinx/compilable.rb interface.
51
53
  def compiler_target_files
52
54
  @compiler_target_files
53
55
  end
54
56
 
55
- # See Test::NetLinx::Compilable interface.
57
+ # @see _ lib/test/netlinx/compilable.rb interface.
56
58
  def compiler_include_paths
57
59
  @compiler_include_paths
58
60
  end
59
61
 
60
- # See Test::NetLinx::Compilable interface.
62
+ # @see _ lib/test/netlinx/compilable.rb interface.
61
63
  def compiler_module_paths
62
64
  @compiler_module_paths
63
65
  end
64
66
 
65
- # See Test::NetLinx::Compilable interface.
67
+ # @see _ lib/test/netlinx/compilable.rb interface.
66
68
  def compiler_library_paths
67
69
  []
68
70
  end
@@ -1,4 +1,4 @@
1
- Copyright 2013 Alex McLain
1
+ Copyright 2013, 2015 Alex McLain
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netlinx-compile
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McLain
@@ -14,72 +14,72 @@ dependencies:
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '10.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '10.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: yard
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.7.3
33
+ version: 0.8.7
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.7.3
40
+ version: 0.8.7
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.0
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.0.0
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-its
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.1
61
+ version: '1.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.1
68
+ version: '1.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fivemat
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement