netlinx-workspace 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/README.html +0 -0
  3. data/doc/NetLinx/Compile/Extension/APW.html +136 -0
  4. data/doc/NetLinx/Compile/Extension.html +127 -0
  5. data/doc/NetLinx/Compile.html +127 -0
  6. data/doc/NetLinx/Project.html +464 -0
  7. data/doc/NetLinx/System.html +588 -0
  8. data/doc/NetLinx/SystemFile.html +302 -0
  9. data/doc/NetLinx/Workspace.html +445 -0
  10. data/doc/NetLinx.html +131 -0
  11. data/doc/created.rid +7 -0
  12. data/doc/images/add.png +0 -0
  13. data/doc/images/arrow_up.png +0 -0
  14. data/doc/images/brick.png +0 -0
  15. data/doc/images/brick_link.png +0 -0
  16. data/doc/images/bug.png +0 -0
  17. data/doc/images/bullet_black.png +0 -0
  18. data/doc/images/bullet_toggle_minus.png +0 -0
  19. data/doc/images/bullet_toggle_plus.png +0 -0
  20. data/doc/images/date.png +0 -0
  21. data/doc/images/delete.png +0 -0
  22. data/doc/images/find.png +0 -0
  23. data/doc/images/loadingAnimation.gif +0 -0
  24. data/doc/images/macFFBgHack.png +0 -0
  25. data/doc/images/package.png +0 -0
  26. data/doc/images/page_green.png +0 -0
  27. data/doc/images/page_white_text.png +0 -0
  28. data/doc/images/page_white_width.png +0 -0
  29. data/doc/images/plugin.png +0 -0
  30. data/doc/images/ruby.png +0 -0
  31. data/doc/images/tag_blue.png +0 -0
  32. data/doc/images/tag_green.png +0 -0
  33. data/doc/images/transparent.png +0 -0
  34. data/doc/images/wrench.png +0 -0
  35. data/doc/images/wrench_orange.png +0 -0
  36. data/doc/images/zoom.png +0 -0
  37. data/doc/index.html +85 -0
  38. data/doc/js/darkfish.js +155 -0
  39. data/doc/js/jquery.js +18 -0
  40. data/doc/js/navigation.js +142 -0
  41. data/doc/js/search.js +94 -0
  42. data/doc/js/search_index.js +1 -0
  43. data/doc/js/searcher.js +228 -0
  44. data/doc/rdoc.css +595 -0
  45. data/doc/table_of_contents.html +111 -0
  46. data/lib/netlinx/compile/extension/apw.rb +19 -0
  47. data/lib/netlinx/project.rb +83 -0
  48. data/lib/netlinx/system.rb +122 -0
  49. data/lib/netlinx/system_file.rb +36 -0
  50. data/lib/netlinx/workspace.rb +89 -0
  51. data/lib/netlinx-workspace.rb +1 -0
  52. data/license.txt +13 -0
  53. metadata +152 -0
@@ -0,0 +1,83 @@
1
+ require 'netlinx/system'
2
+
3
+ module NetLinx
4
+ # A collection of NeTLinx systems.
5
+ # Workspace -> Project -> System
6
+ class Project
7
+ attr_accessor :name
8
+ attr_accessor :description
9
+ attr_accessor :dealer
10
+ attr_accessor :designer
11
+ attr_accessor :sales_order
12
+ attr_accessor :purchase_order
13
+ attr_accessor :workspace # A reference to the project's parent workspace.
14
+ attr_accessor :systems
15
+
16
+ def initialize(**kvargs)
17
+ @name = kvargs.fetch :name, ''
18
+ @description = kvargs.fetch :description, ''
19
+ @dealer = kvargs.fetch :dealer, ''
20
+ @designer = kvargs.fetch :designer, ''
21
+ @sales_order = kvargs.fetch :sales_order, ''
22
+ @purchase_order = kvargs.fetch :purchase_order, ''
23
+ @workspace = kvargs.fetch :workspace, nil
24
+
25
+ @systems = []
26
+
27
+ project_element = kvargs.fetch :element, nil
28
+ parse_xml_element project_element if project_element
29
+ end
30
+
31
+ # Alias to add a system.
32
+ def <<(system)
33
+ @systems << system
34
+ system.project = self
35
+ end
36
+
37
+ # Returns the project name.
38
+ def to_s
39
+ @name
40
+ end
41
+
42
+ # Returns true if the project contains the specified file.
43
+ def include?(file)
44
+ included = false
45
+
46
+ systems.each do |system|
47
+ included = system.include? file
48
+ break if included
49
+ end
50
+
51
+ included
52
+ end
53
+
54
+ # Compile all systems in this project.
55
+ def compile
56
+ compiler_results = []
57
+ @systems.each {|system| compiler_results << (system.compile).first}
58
+ compiler_results
59
+ end
60
+
61
+ private
62
+
63
+ def parse_xml_element(project)
64
+ # Load project params.
65
+ @name = project.elements['Identifier'].text.strip
66
+ @designer = project.elements['Designer'].text
67
+ @dealer = project.elements['DealerID'].text
68
+ @sales_order = project.elements['SalesOrder'].text
69
+ @purchase_order = project.elements['PurchaseOrder'].text
70
+ @description = project.elements['Comments'].text
71
+
72
+ # Load systems.
73
+ project.each_element 'System' do |e|
74
+ system = NetLinx::System.new \
75
+ element: e,
76
+ project: self
77
+
78
+ @systems << system
79
+ end
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,122 @@
1
+ require 'netlinx/system_file'
2
+
3
+ module NetLinx
4
+ # A collection of resources loaded onto a NetLinx master.
5
+ # Workspace -> Project -> System
6
+ class System
7
+ attr_accessor :name
8
+ attr_accessor :id
9
+ attr_accessor :description
10
+ attr_accessor :project # A reference to the system's parent project.
11
+ attr_accessor :files
12
+
13
+ def initialize(**kvargs)
14
+ @name = kvargs.fetch :name, ''
15
+ @id = kvargs.fetch :id, ''
16
+ @description = kvargs.fetch :description, ''
17
+ @project = kvargs.fetch :project, nil
18
+
19
+ @files = []
20
+
21
+ @compiler_target_files = []
22
+ @compiler_include_paths = []
23
+ @compiler_module_paths = []
24
+ @compiler_library_paths = []
25
+
26
+ system_element = kvargs.fetch :element, nil
27
+ parse_xml_element system_element if system_element
28
+ end
29
+
30
+ # Alias to add a file.
31
+ def <<(file)
32
+ @files << file
33
+ file.system = self
34
+ end
35
+
36
+ # Returns the system name.
37
+ def to_s
38
+ @name
39
+ end
40
+
41
+ # See Test::NetLinx::Compilable.
42
+ def compiler_target_files
43
+ @files
44
+ .select {|f| f.type == 'MasterSrc'}
45
+ .map {|f| File.expand_path \
46
+ f.path,
47
+ f.system.project.workspace.path
48
+ }
49
+ end
50
+
51
+ # See Test::NetLinx::Compilable.
52
+ def compiler_include_paths
53
+ @files
54
+ .select {|f| f.type == 'Include'}
55
+ .map {|f| File.expand_path \
56
+ File.dirname(f.path),
57
+ f.system.project.workspace.path
58
+ }
59
+ end
60
+
61
+ # See Test::NetLinx::Compilable.
62
+ def compiler_module_paths
63
+ @files
64
+ .select {|f| f.type == 'Module' || f.type == 'TKO' || f.type == 'DUET'}
65
+ .map {|f| File.expand_path \
66
+ File.dirname(f.path),
67
+ f.system.project.workspace.path
68
+ }
69
+ end
70
+
71
+ # See Test::NetLinx::Compilable.
72
+ def compiler_library_paths
73
+ []
74
+ end
75
+
76
+ # Returns true if the project contains the specified file.
77
+ def include?(file)
78
+ included = false
79
+
80
+ @files.each do |f|
81
+ name_included = f.name.downcase.eql? file.downcase
82
+
83
+ # TODO: This should probably be relative to the workspace path,
84
+ # which can be found by traversing @project, @workspace.
85
+ path_included = file.gsub(/\\/, '/').include? f.path.gsub(/\\/, '/')
86
+
87
+ included = name_included || path_included
88
+ break if included
89
+ end
90
+
91
+ included
92
+ end
93
+
94
+ # Compile this system.
95
+ def compile
96
+ # The compiler dependency is only needed if this method is called.
97
+ require 'netlinx/compiler'
98
+
99
+ compiler = NetLinx::Compiler.new
100
+ compiler.compile self
101
+ end
102
+
103
+ private
104
+
105
+ def parse_xml_element(system)
106
+ # Load system params.
107
+ @name = system.elements['Identifier'].text.strip
108
+ @id = system.elements['SysID'].text.strip.to_i
109
+ @description = system.elements['Comments'].text
110
+
111
+ # Create system files.
112
+ system.each_element 'File' do |e|
113
+ system_file = NetLinx::SystemFile.new \
114
+ element: e,
115
+ system: self
116
+
117
+ @files << system_file
118
+ end
119
+ end
120
+
121
+ end
122
+ end
@@ -0,0 +1,36 @@
1
+ module NetLinx
2
+ class SystemFile
3
+ attr_accessor :name
4
+ attr_accessor :type
5
+ attr_accessor :path
6
+ attr_accessor :description
7
+ attr_accessor :system
8
+
9
+ def initialize(**kvargs)
10
+ @name = kvargs.fetch :name, ''
11
+ @type = kvargs.fetch :type, ''
12
+ @path = kvargs.fetch :path, ''
13
+ @description = kvargs.fetch :description, ''
14
+ @system = kvargs.fetch :system, nil
15
+
16
+ system_file_element = kvargs.fetch :element, nil
17
+ parse_xml_element system_file_element if system_file_element
18
+ end
19
+
20
+ # Print the SystemFile's name.
21
+ def to_s
22
+ @name
23
+ end
24
+
25
+ private
26
+
27
+ def parse_xml_element(system_file)
28
+ # Load system file params.
29
+ @name = system_file.elements['Identifier'].text.strip
30
+ @type = system_file.attributes['Type']
31
+ @path = system_file.elements['FilePathName'].text.strip
32
+ @description = system_file.elements['Comments'].text
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,89 @@
1
+ require 'rexml/document'
2
+ require 'netlinx/project'
3
+
4
+ module NetLinx
5
+
6
+ # A NetLinx Studio workspace.
7
+ # Collection of projects.
8
+ # Workspace -> Project -> System
9
+ class Workspace
10
+ attr_accessor :name
11
+ attr_accessor :description
12
+ attr_accessor :projects
13
+ attr_reader :file
14
+
15
+ def initialize(**kvargs)
16
+ @name = kvargs.fetch :name, ''
17
+ @description = kvargs.fetch :description, ''
18
+ @projects = []
19
+
20
+ @file = kvargs.fetch :file, nil
21
+ load_workspace @file if @file
22
+ end
23
+
24
+ # Alias to add a project.
25
+ def <<(project)
26
+ @projects << project
27
+ project.workspace = self
28
+ end
29
+
30
+ # Returns the name of the workspace.
31
+ def to_s
32
+ @name
33
+ end
34
+
35
+ # Directory the workspace resides in.
36
+ def path
37
+ File.dirname @file if @file
38
+ end
39
+
40
+ # Returns true if the workspace contains the specified file.
41
+ def include?(file)
42
+ included = false
43
+
44
+ projects.each do |project|
45
+ included = project.include? file
46
+ break if included
47
+ end
48
+
49
+ included
50
+ end
51
+
52
+ # Compile all projects in this workspace.
53
+ def compile
54
+ compiler_results = []
55
+
56
+ @projects.each do |project|
57
+ project.compile.each {|result| compiler_results << result}
58
+ end
59
+
60
+ compiler_results
61
+ end
62
+
63
+ private
64
+
65
+ # Load the workspace from a given NetLinx Studio .apw file.
66
+ def load_workspace(file)
67
+ raise LoadError, "File does not exist at:\n#{file}" unless File.exists? file
68
+
69
+ doc = nil
70
+ File.open file, 'r' do |f|
71
+ doc = REXML::Document.new f
72
+ end
73
+
74
+ # Load workspace params.
75
+ @name = doc.elements['/Workspace/Identifier'].text.strip
76
+ @description = doc.elements['/Workspace/Comments'].text
77
+
78
+ # Load projects.
79
+ doc.each_element '/Workspace/Project' do |e|
80
+ project = NetLinx::Project.new \
81
+ element: e,
82
+ workspace: self
83
+
84
+ @projects << project
85
+ end
86
+ end
87
+
88
+ end
89
+ end
@@ -0,0 +1 @@
1
+ require 'netlinx/workspace'
data/license.txt ADDED
@@ -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,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netlinx-workspace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.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: netlinx-compile
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: rake
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: rdoc
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
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: This library provides a developer API for working with NetLinx Studio
70
+ workspaces in Ruby. It also adds compiler support to the NetLinx Compile gem for
71
+ these workspaces.
72
+ email: alex@alexmclain.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - license.txt
78
+ - README.html
79
+ - lib/netlinx/compile/extension/apw.rb
80
+ - lib/netlinx/project.rb
81
+ - lib/netlinx/system.rb
82
+ - lib/netlinx/system_file.rb
83
+ - lib/netlinx/workspace.rb
84
+ - lib/netlinx-workspace.rb
85
+ - doc/created.rid
86
+ - doc/images/add.png
87
+ - doc/images/arrow_up.png
88
+ - doc/images/brick.png
89
+ - doc/images/brick_link.png
90
+ - doc/images/bug.png
91
+ - doc/images/bullet_black.png
92
+ - doc/images/bullet_toggle_minus.png
93
+ - doc/images/bullet_toggle_plus.png
94
+ - doc/images/date.png
95
+ - doc/images/delete.png
96
+ - doc/images/find.png
97
+ - doc/images/loadingAnimation.gif
98
+ - doc/images/macFFBgHack.png
99
+ - doc/images/package.png
100
+ - doc/images/page_green.png
101
+ - doc/images/page_white_text.png
102
+ - doc/images/page_white_width.png
103
+ - doc/images/plugin.png
104
+ - doc/images/ruby.png
105
+ - doc/images/tag_blue.png
106
+ - doc/images/tag_green.png
107
+ - doc/images/transparent.png
108
+ - doc/images/wrench.png
109
+ - doc/images/wrench_orange.png
110
+ - doc/images/zoom.png
111
+ - doc/index.html
112
+ - doc/js/darkfish.js
113
+ - doc/js/jquery.js
114
+ - doc/js/navigation.js
115
+ - doc/js/search.js
116
+ - doc/js/searcher.js
117
+ - doc/js/search_index.js
118
+ - doc/NetLinx/Compile/Extension/APW.html
119
+ - doc/NetLinx/Compile/Extension.html
120
+ - doc/NetLinx/Compile.html
121
+ - doc/NetLinx/Project.html
122
+ - doc/NetLinx/System.html
123
+ - doc/NetLinx/SystemFile.html
124
+ - doc/NetLinx/Workspace.html
125
+ - doc/NetLinx.html
126
+ - doc/rdoc.css
127
+ - doc/table_of_contents.html
128
+ homepage: https://sourceforge.net/projects/netlinx-workspace/
129
+ licenses:
130
+ - Apache 2.0
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 2.0.3
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: A library for working with AMX NetLinx Studio workspaces in Ruby.
152
+ test_files: []