netlinx-src 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -103,9 +103,9 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Wed May 7 18:13:49 2014 by
106
+ Generated on Mon May 12 11:49:57 2014 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.7.4 (ruby-2.1.1).
108
+ 0.8.7.4 (ruby-2.0.0).
109
109
  </div>
110
110
 
111
111
  </body>
@@ -0,0 +1,11 @@
1
+ require 'netlinx/rake/src/pack'
2
+ require 'netlinx/rake/src/unpack'
3
+ require 'netlinx/rake/src/srcignore'
4
+ require 'netlinx/rake/src/mkzip'
5
+ require 'netlinx/rake/src/delzip'
6
+
7
+ NetLinx::Rake::Pack.new
8
+ NetLinx::Rake::Unpack.new
9
+ NetLinx::Rake::SrcIgnore.new
10
+ NetLinx::Rake::MkZip.new
11
+ NetLinx::Rake::DelZip.new
@@ -0,0 +1,36 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'netlinx/src/package'
4
+
5
+ module NetLinx
6
+ module Rake
7
+
8
+ # Delete .src.zip files.
9
+ class DelZip < ::Rake::TaskLib
10
+
11
+ attr_accessor :name
12
+
13
+
14
+ def initialize name = :delzip
15
+ @name = name
16
+
17
+ yield self if block_given?
18
+
19
+ define
20
+ end
21
+
22
+
23
+ protected
24
+
25
+ def define
26
+ desc "Delete .src.zip files."
27
+
28
+ task(name) do
29
+ Dir['*.src.zip'].each { |file| File.delete file }
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'netlinx/src/package'
4
+
5
+ module NetLinx
6
+ module Rake
7
+
8
+ # Copy .src file and append .zip.
9
+ class MkZip < ::Rake::TaskLib
10
+
11
+ attr_accessor :name
12
+
13
+
14
+ def initialize name = :mkzip
15
+ @name = name
16
+
17
+ yield self if block_given?
18
+
19
+ define
20
+ end
21
+
22
+
23
+ protected
24
+
25
+ def define
26
+ desc "Copy .src file and append .zip."
27
+
28
+ # TODO: Creates the project .src file if it doesn't exist.
29
+
30
+ task(name) do
31
+ Dir['*.src'].each { |file| NetLinx::SRC::Package.new(file: file).copy_to_zip }
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'netlinx/src/package'
4
+ require 'netlinx/workspace'
5
+
6
+ module NetLinx
7
+ module Rake
8
+
9
+ # Generate a NetLinx .src source code package.
10
+ class Pack < ::Rake::TaskLib
11
+
12
+ attr_accessor :name
13
+
14
+
15
+ def initialize name = :pack
16
+ @name = name
17
+
18
+ yield self if block_given?
19
+
20
+ define
21
+ end
22
+
23
+
24
+ protected
25
+
26
+ def define
27
+ desc "Generate a NetLinx .src source code package."
28
+
29
+ task(name) do
30
+ workspace = NetLinx::Workspace.search
31
+ file_name = 'package.src' # Default name if workspace not found.
32
+
33
+ if workspace
34
+ # Create package with workspace name.
35
+ file_name = File.basename(workspace.file, '.apw') + '.src'
36
+ end
37
+
38
+ package = NetLinx::SRC::Package.new file: file_name
39
+ package.pack
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,36 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'netlinx/src/package'
4
+
5
+ module NetLinx
6
+ module Rake
7
+
8
+ # Generate a default .srcignore file.
9
+ class SrcIgnore < ::Rake::TaskLib
10
+
11
+ attr_accessor :name
12
+
13
+
14
+ def initialize name = :srcignore
15
+ @name = name
16
+
17
+ yield self if block_given?
18
+
19
+ define
20
+ end
21
+
22
+
23
+ protected
24
+
25
+ def define
26
+ desc "Generate a default .srcignore file."
27
+
28
+ task(name) do
29
+ NetLinx::SRC::Package.new.make_srcignore
30
+ end
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'netlinx/src/package'
4
+ require 'netlinx/workspace'
5
+
6
+ module NetLinx
7
+ module Rake
8
+
9
+ # Unpack a NetLinx .src source code package.
10
+ class Unpack < ::Rake::TaskLib
11
+
12
+ attr_accessor :name
13
+
14
+
15
+ def initialize name = :unpack
16
+ @name = name
17
+
18
+ yield self if block_given?
19
+
20
+ define
21
+ end
22
+
23
+
24
+ protected
25
+
26
+ def define
27
+ desc "Unpack a NetLinx .src source code package."
28
+
29
+ task(name) do
30
+ workspace = NetLinx::Workspace.search
31
+ file_name = 'package.src' # Default name if workspace not found.
32
+
33
+ if workspace
34
+ # Create package with workspace name.
35
+ file_name = File.basename(workspace.file, '.apw') + '.src'
36
+ end
37
+
38
+ package = NetLinx::SRC::Package.new file: file_name
39
+ package.unpack '_extracted'
40
+ end
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'src/package'
2
+
3
+
4
+ # :nodoc:
5
+ module NetLinx
6
+
7
+ # Pertaining to .src files.
8
+ module SRC
9
+ end
10
+
11
+ # Rake tasks.
12
+ module Rake
13
+ end
14
+
15
+ end
@@ -0,0 +1,154 @@
1
+ require 'zip'
2
+
3
+ module NetLinx
4
+ module SRC
5
+
6
+ # A NetLinx .src source code package.
7
+ class Package
8
+
9
+ # Parameters:
10
+ #
11
+ # Mode:
12
+ # :standard - Intelligently package all files pertaining to a
13
+ # NetLinx project.
14
+ #
15
+ # :classic - Emulates the AMX file packager, including only .axs
16
+ # and .axi files in the package. Also mimicks the same folder
17
+ # structure.
18
+ #
19
+ def initialize **kvargs
20
+ @file = kvargs.fetch :file, ''
21
+ @mode = kvargs.fetch :mode, :standard
22
+
23
+ @warning_file = '_FILE_EXTRACTION_WARNING.txt'
24
+ end
25
+
26
+ # Pack the project into a NetLinx .src package.
27
+ def pack
28
+ File.delete @file if File.exists? @file
29
+
30
+ files = Dir['**/*'] - Dir[@file] + Dir['.srcignore']
31
+
32
+ # Exclude ignored files.
33
+ exclusions = load_exclusions.map { |e| Dir[e] }.flatten
34
+ files = files - exclusions
35
+
36
+ Zip::File.open @file, Zip::File::CREATE do |zip|
37
+ files.each { |file| zip.add file, file }
38
+
39
+ zip.get_output_stream(@warning_file) { |f|
40
+ f.puts make_warning_file
41
+ }
42
+ end
43
+ end
44
+
45
+ # Unpack a NetLinx .src project package.
46
+ # Unpacks to the given directory, if provided.
47
+ def unpack dir = nil
48
+ Zip::File.open @file do |zip|
49
+ zip.each_entry do |e|
50
+ path = dir.nil? ? e.name : "#{dir}/#{e.name}"
51
+ e.extract path unless e.name == @warning_file
52
+ end
53
+ end
54
+ end
55
+
56
+ # Load a list of file exclusions (glob format) from .srcignore.
57
+ def load_exclusions
58
+ return [] unless File.exists? '.srcignore'
59
+
60
+ lines = File.read('.srcignore').lines.map(&:strip)
61
+ .reject { |l| l.empty? } # Remove empty lines.
62
+ .reject { |l| l.start_with? '#' } # Remove commented lines.
63
+ .map { |l| l.include?('/') ? l : "**/#{l}" } # Append **/ if a specific path isn't referenced.
64
+ end
65
+
66
+ # Copy the NetLinx .src file to .zip for easy browsing without unpacking.
67
+ def copy_to_zip
68
+ FileUtils.cp @file, "#{@file}.zip"
69
+ end
70
+
71
+ # Remove the .zip version of this NetLinx .src file if it exists.
72
+ def remove_zip
73
+ File.delete "#{@file}.zip" if File.exists? "#{@file}.zip"
74
+ end
75
+
76
+ # Create a standard .srcignore file in the current directory.
77
+ # Raises exception if file exists.
78
+ def make_srcignore
79
+ raise IOError, "A .srcignore file already exists in this directory." \
80
+ if File.exists? '.srcignore'
81
+
82
+ string = <<-EOS
83
+ # --------------------------------------------------- #
84
+ # Files to exclude from .SRC package (glob format). #
85
+ # --------------------------------------------------- #
86
+
87
+ # AMX
88
+
89
+ *.src
90
+ *.tp4
91
+
92
+ # Graphics
93
+
94
+ *.ai
95
+ *.bmp
96
+ *.eps
97
+ *.gif
98
+ *.jpg
99
+ *.jpeg
100
+ *.png
101
+ *.psd
102
+ *.svg
103
+
104
+ # Archives
105
+
106
+ *.gz
107
+ *.tar
108
+ *.zip
109
+
110
+ # Documentation
111
+
112
+ *.pdf
113
+
114
+ EOS
115
+
116
+ File.write '.srcignore', string
117
+ end
118
+
119
+ # Returns a string for the unpack warning file.
120
+ def make_warning_file
121
+ <<-EOS
122
+ # ---------------------------------------------------------------------- #
123
+ # WARNING: This archive should be unpacked with the netlinx-src utility #
124
+ # ---------------------------------------------------------------------- #
125
+
126
+ Download
127
+ --------
128
+
129
+ http://sourceforge.net/p/netlinx-src/wiki/Home/
130
+
131
+
132
+ About
133
+ -----
134
+
135
+ netlinx-src is a third-party utility for creating and extracting NetLinx
136
+ .src source code package files. Unlike the standard utility that ships
137
+ with NetLinx Studio, netlinx-src will retain the project's folder
138
+ structure when the project is extracted. This becomes increasingly more
139
+ important based on the number of files a project contains.
140
+
141
+ Packaging a project with netlinx-src is also more comprehensive than
142
+ using the standard utility. Not only is netlinx-src courteous enough
143
+ to package files necessary for maintenance of the system (IR libraries,
144
+ Duet modules, NetLinx modules, etc.), it also features a fine-grained
145
+ file exclusion list that can prevent bulky touch panel files or graphics
146
+ from filling up the disk space on the master.
147
+ EOS
148
+ .gsub("\n", "\r\n") # Format for readability in Notepad.
149
+ end
150
+
151
+ end
152
+
153
+ end
154
+ end
metadata CHANGED
@@ -1,111 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netlinx-src
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McLain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: netlinx-workspace
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - ">="
45
+ - - '>='
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - '>='
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: yard
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ">="
59
+ - - '>='
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ">="
66
+ - - '>='
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: fivemat
70
+ name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - '>='
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - '>='
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: yard
84
+ name: fivemat
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ">="
87
+ - - '>='
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ">="
94
+ - - '>='
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: pry
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ">="
101
+ - - '>='
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">="
108
+ - - '>='
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rb-readline
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ">="
115
+ - - '>='
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ">="
122
+ - - '>='
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  description: ''
@@ -114,17 +128,22 @@ executables: []
114
128
  extensions: []
115
129
  extra_rdoc_files: []
116
130
  files:
131
+ - license.txt
117
132
  - README.md
118
- - doc/NetLinx.html
119
- - doc/NetLinx/ProjectPackage.html
120
- - doc/_index.html
133
+ - lib/netlinx/rake/src/delzip.rb
134
+ - lib/netlinx/rake/src/mkzip.rb
135
+ - lib/netlinx/rake/src/pack.rb
136
+ - lib/netlinx/rake/src/srcignore.rb
137
+ - lib/netlinx/rake/src/unpack.rb
138
+ - lib/netlinx/rake/src.rb
139
+ - lib/netlinx/src/package.rb
140
+ - lib/netlinx/src.rb
121
141
  - doc/class_list.html
122
142
  - doc/css/common.css
123
143
  - doc/css/full_list.css
124
144
  - doc/css/style.css
125
- - doc/file.README.html
126
- - doc/file.README.md.html
127
145
  - doc/file.license.html
146
+ - doc/file.README.html
128
147
  - doc/file_list.html
129
148
  - doc/frames.html
130
149
  - doc/index.html
@@ -132,10 +151,20 @@ files:
132
151
  - doc/js/full_list.js
133
152
  - doc/js/jquery.js
134
153
  - doc/method_list.html
154
+ - doc/NetLinx/ProjectPackage.html
155
+ - doc/NetLinx/Rake/DelZip.html
156
+ - doc/NetLinx/Rake/MkZip.html
157
+ - doc/NetLinx/Rake/Pack.html
158
+ - doc/NetLinx/Rake/SrcIgnore.html
159
+ - doc/NetLinx/Rake/ToZip.html
160
+ - doc/NetLinx/Rake/Unpack.html
161
+ - doc/NetLinx/Rake/Zip.html
162
+ - doc/NetLinx/Rake.html
163
+ - doc/NetLinx/SRC/Package.html
164
+ - doc/NetLinx/SRC.html
165
+ - doc/NetLinx.html
135
166
  - doc/top-level-namespace.html
136
- - lib/netlinx-src.rb
137
- - lib/netlinx/project_package.rb
138
- - license.txt
167
+ - doc/_index.html
139
168
  homepage: https://sourceforge.net/projects/netlinx-src/
140
169
  licenses:
141
170
  - Apache 2.0
@@ -146,19 +175,19 @@ require_paths:
146
175
  - lib
147
176
  required_ruby_version: !ruby/object:Gem::Requirement
148
177
  requirements:
149
- - - ">="
178
+ - - '>='
150
179
  - !ruby/object:Gem::Version
151
180
  version: '0'
152
181
  required_rubygems_version: !ruby/object:Gem::Requirement
153
182
  requirements:
154
- - - ">="
183
+ - - '>='
155
184
  - !ruby/object:Gem::Version
156
185
  version: '0'
157
186
  requirements: []
158
187
  rubyforge_project:
159
- rubygems_version: 2.2.2
188
+ rubygems_version: 2.0.3
160
189
  signing_key:
161
190
  specification_version: 4
162
- summary: A utility for managing NetLinx Source (.src) files.
191
+ summary: A toolset for working with NetLinx source code packages (.src).
163
192
  test_files: []
164
193
  has_rdoc: