rakeutils 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e23e6dac5c8ee4272ba0f17402120561ce65ac6c
4
+ data.tar.gz: a99f02663582dec209bab72f7e51f98a12c60f60
5
+ SHA512:
6
+ metadata.gz: ca863240165b59e9193bb53c882103753e80b751be19e83fcece77d887c3b23e29e35b8e4e46011a55fd328d4fba800d71b08fbf4147459d4984bf02c7b6c7e0
7
+ data.tar.gz: 36638ffc2b0be93669b38709713950f9069bac87a9ba1290f4ba19e0a52aa8194a97294e994414cf667c202377334e1546b6f6bac261d03b042433be829aebb9
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ # .gitignore
2
+ install.cmd
3
+ buildgem
4
+ buildgem.cmd
5
+ /pkg
6
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in test.gemspec
4
+ gemspec
5
+
6
+ # If the .gemspec in each of these git repos doesn't match the version
7
+ # required by THIS gem's .gemspec, bundler will print an error.
8
+
9
+ # FIXME: Remove ktcommon if not needed:
10
+ #gem 'ktcommon', :git => 'ssh://git@bitbucket.org/ktechsystems/ktcommon.git'
11
+ gem 'ktutils', :git => 'git@github.com:jmcaffee/ktutils.git'
12
+
13
+ group :test do
14
+ gem 'fakefs', require: "fakefs/safe"
15
+ end
16
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jeff McAffee
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # RakeUtils
2
+
3
+ A Ruby gem providing helper tasks for calling external applications.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rakeutils'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rakeutils
20
+
21
+ ## Usage
22
+
23
+ Within your `rakefile`, require the tasks you'd like to use:
24
+
25
+ ```ruby
26
+ require "rakeutils" # Require ALL RakeUtils tasks OR
27
+
28
+ # Require individual tasks as needed
29
+ require "rakeutils/filegentask"
30
+ require "rakeutils/innotask"
31
+ require "rakeutils/javacctask"
32
+ require "rakeutils/jjtreetask"
33
+ require "rakeutils/ocratask"
34
+ require "rakeutils/tex2rtf"
35
+ require "rakeutils/versioninc"
36
+ require "rakeutils/ziptask"
37
+ ```
38
+
39
+ ## TODOs
40
+
41
+ This gem was created quite a while ago and I used java naming conventions when
42
+ it was written.
43
+
44
+ - TODO: Refactor all remaining identifiers to ruby naming conventions.
45
+
46
+
47
+ ## Bugs/Questions/Get Help
48
+
49
+ Create an issue at [https://github.com/jmcaffee/rakeutils/issues](https://github.com/jmcaffee/rakeutils/issues).
50
+
51
+ ## Testing
52
+
53
+ From the root project dir, run:
54
+
55
+ $ rspec spec/
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it ( https://github.com/jmcaffee/rakeutils/fork )
60
+ 2. Clone it (`git clone git@github.com:[my-github-username]/rakeutils.git`)
61
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 4. Create your tests
63
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 6. Push to the branch (`git push origin my-new-feature`)
65
+ 7. Create a new Pull Request
66
+
@@ -0,0 +1,91 @@
1
+ ######################################################################################
2
+ #
3
+ # clApp.rb
4
+ #
5
+ # Jeff McAffee 10/25/08
6
+ #
7
+ # Purpose: CLApp is a base class for command line application classes.
8
+ # CLApp is used to create classes that call 3rd party command line apps.
9
+ #
10
+ ######################################################################################
11
+
12
+ # Base class that provides common functionality for command line application caller classes.
13
+
14
+ class CLApp
15
+
16
+ # Constructor
17
+ # app_path:: absolute path to application to control
18
+ def initialize(app_path)
19
+ @app_path = app_path
20
+ end # initialize
21
+
22
+ # Apply quotes around a text value (helper function for GLT class)
23
+ # val:: Value to apply quotes to
24
+ # returns:: quoted value
25
+ def quote_value(val)
26
+ q_vals = '"' + "#{val}" + '"'
27
+
28
+ return q_vals
29
+ end # quote_value
30
+
31
+ # Apply quotes around an array of text values (helper function)
32
+ # values:: Value to apply quotes to
33
+ # returns:: quoted value
34
+ def quote_all_values(values)
35
+ q_vals = []
36
+ values.each do |val|
37
+ q_vals << quote_value(val)
38
+ end
39
+
40
+ return q_vals
41
+ end # quote_all_values
42
+
43
+ # Return a normalized directory path (if the path is to a file, return the file's directory). This will make sure that the path is quoted if it contains spaces.
44
+ # dirpath:: Path to directory
45
+ # returns:: Path to directory
46
+ def normalize_dir_path(dirpath)
47
+ if (!File.directory?(dirpath)) # This is not a path to a directory...
48
+ if(File.exists?(dirpath))
49
+ dirpath = File.dirname(dirpath)
50
+ end
51
+ end
52
+
53
+ if(!dirpath.include?('"') && !dirpath.include?("'")) # Do not add quotes around path if it already contains quotes.
54
+ if(dirpath.include?(' ')) # Add quotes around path if it contains spaces.
55
+ dirpath = quote_value(dirpath)
56
+ end
57
+ end
58
+
59
+ return dirpath
60
+ end # normalize_dir_path
61
+
62
+ # Convert windows path seperators to ruby (backslash to forward slash).
63
+ # path:: path to convert
64
+ # returns:: converted path
65
+ def rubyize_path(path)
66
+ return path.gsub(/\\/, "/")
67
+ end # rubyize_path
68
+
69
+ # Convert ruby path seperators to windows ( forward slash to backslash).
70
+ # path:: path to convert
71
+ # returns:: converted path
72
+ def windowize_path(path)
73
+ return path.gsub(/\//, "\\")
74
+ end # windowize_path
75
+
76
+ # Execute application.
77
+ # cmd_line:: Command line to pass to the application
78
+ # can_throw:: If true, throw exception if command fails.
79
+ # throws:: Exception if command failed.
80
+ def execute(cmd_line, can_throw=true)
81
+ app_cmd = "#{@app_path} #{cmd_line}"
82
+ puts "Executing: #{app_cmd}"
83
+ if( !File.exists?(@app_path) )
84
+ raise "Invalid application path: #{@app_path}"
85
+ end
86
+
87
+ if( !Kernel.system("#{app_cmd}") && can_throw )
88
+ raise "Application threw an exception for the command: ".concat(app_cmd)
89
+ end
90
+ end # execute
91
+ end # class CLApp
@@ -0,0 +1,115 @@
1
+ ##############################################################################
2
+ # File:: filegentask.rb
3
+ # Purpose:: Generate a file from a template file using data from a YML file.
4
+ #
5
+ # Author:: Jeff McAffee 03/03/2010
6
+ # Copyright:: Copyright (c) 2010 kTech Systems LLC. All rights reserved.
7
+ # Website:: http://ktechsystems.com
8
+ ##############################################################################
9
+
10
+ require 'yaml'
11
+ require 'fileutils'
12
+
13
+ require 'ktutils/parse_template'
14
+
15
+ class DataFile
16
+
17
+ attr_accessor :root_dir
18
+
19
+ def initialize(rootdir = nil)
20
+ @root_dir = rootdir
21
+
22
+ if( rootdir )
23
+ @root_dir = File.rubypath(@root_dir)
24
+ if( !File.exists?(@root_dir))
25
+ FileUtils.mkdir(@root_dir)
26
+ end
27
+ end
28
+ end
29
+
30
+ def write(filename, data)
31
+ filepath = filename
32
+ if( root_dir )
33
+ filepath = File.join(root_dir, filename)
34
+ end
35
+
36
+ open(filepath, 'w') { |f| YAML.dump(data, f) }
37
+ end
38
+
39
+ def read(filename)
40
+ filepath = filename
41
+ if( root_dir )
42
+ filepath = File.join(root_dir, filename)
43
+ end
44
+
45
+ data = {}
46
+
47
+ open(filepath) { |f| data = YAML.load(f) }
48
+ data
49
+ end
50
+ end # DataFile
51
+
52
+
53
+ # Define a generator object that creates a file from a template and a YML
54
+ # data file.
55
+ class FileGenTask
56
+
57
+ # Constructor
58
+ # verbose:: verbose output flag. Default = false
59
+ def initialize(verbose=false)
60
+ @src = ""
61
+ @dest = ""
62
+ @data_file = ""
63
+ @start_delim = "@"
64
+ @stop_delim = "@"
65
+ @verbose = verbose
66
+ end
67
+
68
+ # Set token delimiters
69
+ # start:: start delimiter char
70
+ # stop:: stop delimiter char
71
+ def set_delimiters(start, stop)
72
+ @start_delim = start
73
+ @stop_delim = stop
74
+ puts "FileGenTask: Setting token delimeters to #{@start_delim}, #{@stop_delim}" if @verbose
75
+ end
76
+
77
+ # Generate files.
78
+ # src:: source template file
79
+ # dest:: name of file to output.
80
+ # data:: string or hash. if a string, it will be treated as a YML filename.
81
+ def generate(src, dest, data)
82
+ puts "FileGenTask: Generating file [ #{dest} ] from [ #{src} ]" if @verbose
83
+ if(data.class == String)
84
+ load_data(data)
85
+ else
86
+ if( data.class != Hash )
87
+ puts "* ERROR: FileGenTask::generate - data must be string (YML filename) or hash *"
88
+ return unless (data.class == Hash)
89
+ end
90
+ @data = data
91
+ end
92
+
93
+ parse_src_to( src, dest )
94
+ end
95
+
96
+ # Load data from YAML based data file.
97
+ # data_file:: name/path of YAML based data file
98
+ def load_data(data_file)
99
+ puts "FileGenTask: Loading data from YML file [ #{data_file} ]" if @verbose
100
+ df = DataFile.new
101
+ @data = df.read( data_file )
102
+ end
103
+
104
+ # Parse the source file and create the destination file.
105
+ # src:: source template file
106
+ # dest:: Destination filename and path
107
+ def parse_src_to(src, dest)
108
+ pt = Ktutils::ParseTemplate.new(@start_delim, @stop_delim)
109
+
110
+ @data.each do |t, v|
111
+ pt.add_token( t, v )
112
+ end
113
+ pt.parse( src, dest )
114
+ end
115
+ end # class FileGenTask
@@ -0,0 +1,77 @@
1
+ ######################################################################################
2
+ #
3
+ # innoTask.rb
4
+ #
5
+ # Jeff McAffee 10/30/08
6
+ #
7
+ # Purpose: Implements InnoSetup5 functionality for rake usage
8
+ #
9
+ ######################################################################################
10
+
11
+ =begin
12
+ InnoSetup command line:
13
+ m:\Inno5.3.5\ISCC.exe /OOutPutDir /FOutputBaseFileName SCRIPT
14
+ =end
15
+
16
+ require_relative 'clapp'
17
+
18
+ # Implements programmatic control of the InnoSetup5 application.
19
+ class InnoTask < CLApp
20
+ include FileUtils
21
+
22
+ # Constructor
23
+ def initialize()
24
+ super( find_app ) # Call parent constructor.
25
+
26
+ app_path = find_app
27
+ if app_path.nil? or app_path.empty? or !File.exist?(app_path)
28
+ if Ktutils::OS.windows?
29
+ # ISCC_EXE_PATH env var should point to the executable.
30
+ # ie. "M:/Inno5.3.5/ISCC.exe"
31
+ msg = "ISCC_EXE_PATH environment variable is not configured correctly "
32
+ msg += "or Inno Setup is not installed."
33
+ msg += "\nISCC not found"
34
+ raise msg
35
+ else
36
+ msg = "iscc command not found. "
37
+ msg += "See <https://katastrophos.net/andre/blog/2009/03/16/setting-up-the-inno-setup-compiler-on-debian/> "
38
+ msg += "for instructions on installing Inno Setup in linux."
39
+ msg += "\niscc not found"
40
+ raise msg
41
+ end
42
+ end
43
+
44
+ end # initialize
45
+
46
+ def find_app
47
+ if Ktutils::OS.windows?
48
+ app_path = ENV["ISCC_EXE_PATH"]
49
+ else
50
+ app_path = `which iscc`.chomp
51
+ end
52
+ end
53
+
54
+ # Compile setup script.
55
+ #
56
+ # dest_dir:: destination directory
57
+ # filename:: Output base filename
58
+ # script:: Script to be compiled
59
+ def compile(dest_dir, filename, script)
60
+ dest_dir = File.expand_path( dest_dir )
61
+ script = File.expand_path( script )
62
+ # Make sure the paths are in windows format for the compiler.
63
+ dest_dir = windowize_path( dest_dir )
64
+ script = windowize_path( script )
65
+
66
+ puts "dest_dir: #{dest_dir}"
67
+ puts "filename: #{filename}"
68
+ puts "script: #{script}"
69
+
70
+ begin
71
+ execute( cmd_line, false )
72
+ rescue Exception => e
73
+ puts "!!! Errors occured during compilation of setup script."
74
+ puts e.message
75
+ end
76
+ end # compile
77
+ end # class InnoTask
@@ -0,0 +1,108 @@
1
+ ##############################################################################
2
+ # File:: javaccTask.rb
3
+ # Purpose:: Run JavaCC against a grammar file to generate java code.
4
+ #
5
+ # Author:: Jeff McAffee 02/26/2010
6
+ # Copyright:: Copyright (c) 2010 kTech Systems LLC. All rights reserved.
7
+ # Website:: http://ktechsystems.com
8
+ ##############################################################################
9
+
10
+
11
+ =begin
12
+ javacc.bat command line:
13
+ javacc [OPTIONS] GRAMMAR_FILE
14
+ =end
15
+ require 'ktutils/os'
16
+ require 'fileutils'
17
+
18
+ require_relative 'clapp'
19
+
20
+ # Implements programmatic control of the JavaCC application.
21
+
22
+ class JavaCCTask < CLApp
23
+ include FileUtils
24
+
25
+ # Constructor
26
+ def initialize()
27
+ super( find_app ) # Call parent constructor.
28
+
29
+ app_path = find_app
30
+ if app_path.nil? or app_path.empty? or !File.exist?(app_path)
31
+ if Ktutils::OS.windows?
32
+ msg = "JAVACC_HOME environment variable is not configured correctly "
33
+ msg += "or JavaCC is not installed."
34
+ msg += "\njavacc.bat not found"
35
+ raise msg
36
+ else
37
+ raise "javacc not found"
38
+ end
39
+ end
40
+
41
+ @look_ahead = ""
42
+ @static = ""
43
+ @output_dir = ""
44
+ end # initialize
45
+
46
+ def find_app
47
+ if Ktutils::OS.windows?
48
+ app_home = ENV["JAVACC_HOME"]
49
+ unless app_home.nil? or app_home.empty?
50
+ app_path = File.join(app_home, "bin", "javacc.bat")
51
+ end
52
+ else
53
+ app_path = `which javacc`.chomp
54
+ end
55
+ end
56
+
57
+ # Set the static class generation flag.
58
+ # true_or_false:: string; value (true or false). Default = true.
59
+ def static(true_or_false)
60
+ if (true_or_false != 'true' && true_or_false != 'false')
61
+ puts "JJTreeTask Error: static must be string value ('true' or 'false')"
62
+ return
63
+ end
64
+ @static = true_or_false
65
+ end
66
+
67
+ # Set the lookahead depth.
68
+ # look_ahead:: string; depth of lookahead. Default = 1.
69
+ def output_file(look_ahead)
70
+ @look_ahead = look_ahead.to_s
71
+ end
72
+
73
+ # Set the output directory.
74
+ # pathname:: string; path of output directory. Default = current directory.
75
+ def output_dir(pathname)
76
+ @output_dir = pathname
77
+ end
78
+
79
+ # Generate java classes based on JavaCC grammar description file.
80
+ # grammar:: grammar description file (.jj)
81
+ def generate_from(grammar)
82
+ puts "Generating Java classes based on grammar file: #{grammar}"
83
+
84
+ # Note: javacc help states that args can be supplied using either of
85
+ # 2 forms:
86
+ # -OPTION=value
87
+ # -OPTION:value
88
+ #
89
+ # So far, I get errors (and javacc doesn't recognize) options
90
+ # passed with '='.
91
+ #
92
+ # Use form -OPTION: instead.
93
+ options = []
94
+ options << "-STATIC:#{@static}" unless @static.empty?
95
+ options << "-LOOKAHEAD:#{@look_ahead}" unless @look_ahead.empty?
96
+ options << "-OUTPUT_DIRECTORY:#{@output_dir}" unless @output_dir.empty?
97
+
98
+ cmd_line = options.join(' ') + " #{grammar}"
99
+
100
+ begin
101
+ execute( cmd_line, false )
102
+ rescue Exception => e
103
+ puts "!!! Errors occured during parsing of JavaCC grammar."
104
+ puts e.message
105
+ #exit
106
+ end
107
+ end # generate
108
+ end # class JavaCCTask
@@ -0,0 +1,109 @@
1
+ ##############################################################################
2
+ # File:: jjTreeTask.rb
3
+ # Purpose:: Run JJTree (JavaCC) against a grammar file (.jjt) to generate
4
+ # javacc grammar file (.jj).
5
+ #
6
+ # Author:: Jeff McAffee 02/26/2010
7
+ # Copyright:: Copyright (c) 2010 kTech Systems LLC. All rights reserved.
8
+ # Website:: http://ktechsystems.com
9
+ ##############################################################################
10
+
11
+
12
+ =begin
13
+ jjtree.bat command line:
14
+ jjtree [OPTIONS] GRAMMAR_FILE
15
+ =end
16
+
17
+ require 'ktutils/os'
18
+
19
+ require_relative 'clapp'
20
+
21
+ # Implements programmatic control of the JJTree application.
22
+
23
+ class JJTreeTask < CLApp
24
+ include FileUtils
25
+
26
+ # Constructor
27
+ def initialize()
28
+ super( find_app ) # Call parent constructor.
29
+
30
+ app_path = find_app
31
+ if app_path.nil? or app_path.empty? or !File.exist?(app_path)
32
+ if Ktutils::OS.windows?
33
+ msg = "JAVACC_HOME environment variable is not configured correctly "
34
+ msg += "or JavaCC is not installed."
35
+ msg += "\njjtree.bat not found"
36
+ raise msg
37
+ else
38
+ raise "jjtree not found"
39
+ end
40
+ end
41
+
42
+ @static = ""
43
+ @output_file = ""
44
+ @output_dir = ""
45
+ end # initialize
46
+
47
+ def find_app
48
+ if Ktutils::OS.windows?
49
+ app_home = ENV["JAVACC_HOME"]
50
+ unless app_home.nil? or app_home.empty?
51
+ app_path = File.join(app_home, "bin", "jjtree.bat")
52
+ end
53
+ else
54
+ app_path = `which jjtree`.chomp
55
+ end
56
+ end
57
+
58
+ # Set the static class generation flag.
59
+ # true_or_false:: string value (true or false). Default = true.
60
+ def static(true_or_false)
61
+ if (true_or_false != 'true' && true_or_false != 'false')
62
+ puts "JJTreeTask Error: static must be string value ('true' or 'false')"
63
+ return
64
+ end
65
+ @static = true_or_false.to_s
66
+ end
67
+
68
+ # Set the output filename.
69
+ # filename:: string name of output file. Default = input filename with .jj suffix.
70
+ def output_file(filename)
71
+ @output_file = filename
72
+ end
73
+
74
+ # Set the output directory.
75
+ # pathname:: string path of output directory. Default = current directory.
76
+ def output_dir(pathname)
77
+ @output_dir = pathname
78
+ end
79
+
80
+ # Generate javacc grammar file based on JJTree grammar description file.
81
+ # grammar:: grammar description file (.jjt)
82
+ def generate_from(grammar)
83
+ puts "Generating JavaCC grammar from: #{grammar}"
84
+
85
+ # Note: jjtree help states that args can be supplied using either of
86
+ # 2 forms:
87
+ # -OPTION=value
88
+ # -OPTION:value
89
+ #
90
+ # So far, I get errors (and jjtree doesn't recognize) options
91
+ # passed with '='.
92
+ #
93
+ # Use form -OPTION: instead.
94
+ options = []
95
+ options << "-STATIC:#{@static}" unless @static.empty?
96
+ options << "-OUTPUT_FILE:#{@output_file}" unless @output_file.empty?
97
+ options << "-OUTPUT_DIRECTORY:#{@output_dir}" unless @output_dir.empty?
98
+
99
+ cmd_line = options.join(' ') + " #{grammar}"
100
+
101
+ begin
102
+ execute( cmd_line, false )
103
+ rescue Exception => e
104
+ puts "!!! Errors occured during parsing of JJTree grammar."
105
+ puts e.message
106
+ exit
107
+ end
108
+ end # generate
109
+ end # class JJTreeTask
@@ -0,0 +1,48 @@
1
+ ##############################################################################
2
+ # File:: ocraTask.rb
3
+ # Purpose:: Run OCRA against a ruby source tree
4
+ #
5
+ # Author:: Jeff McAffee 10/29/2009
6
+ # Copyright:: Copyright (c) 2009 kTech Systems LLC. All rights reserved.
7
+ # Website:: http://ktechsystems.com
8
+ ##############################################################################
9
+
10
+
11
+ =begin
12
+ ocra.rb command line:
13
+ ruby.exe -S ocra.rb SCRIPT
14
+ =end
15
+
16
+ require 'ktutils/os'
17
+
18
+ require_relative 'clapp'
19
+
20
+ # Implements programmatic control of the OCRA application.
21
+ class OcraTask < CLApp
22
+ include FileUtils
23
+
24
+ if Ktutils::OS.windows?
25
+ APP_PATH = "N:/Ruby/bin/ruby.exe"
26
+ else
27
+ APP_PATH = `which ruby`.chomp
28
+ end
29
+
30
+ # Constructor
31
+ def initialize()
32
+ super( APP_PATH ) # Call parent constructor.
33
+ end # initialize
34
+
35
+ # Generate executable application from a ruby script.Compile setup script.
36
+ # script:: Script to be compiled
37
+ def compile(script)
38
+ puts "Compiling script: #{script}"
39
+
40
+ cmdLine = "ocra.rb --windows #{script}"
41
+
42
+ begin
43
+ execute( cmdLine, false )
44
+ rescue
45
+ puts "!!! Errors occured during compilation of setup script."
46
+ end
47
+ end # compile
48
+ end # class OcraTask
@@ -0,0 +1,62 @@
1
+ ######################################################################################
2
+ #
3
+ # tex2rtf.rb
4
+ #
5
+ # Jeff McAffee 10/25/08
6
+ #
7
+ # Purpose: Implements tex2rtf functionality for rake usage
8
+ #
9
+ ######################################################################################
10
+
11
+ =begin
12
+ tex2rtf command line:
13
+ m:\tex2rtf\tex2rtf.exe easydocs.tex easydocshelp.html -checkcurleybraces -checksyntax -html
14
+ =end
15
+
16
+ require_relative 'clapp'
17
+ # Implements programmatic control of the Tex2Rtf application.
18
+
19
+ class Tex2Rtf < CLApp
20
+ include FileUtils
21
+
22
+ APP_PATH = "M:/Tex2RTF/tex2rtf.exe"
23
+
24
+
25
+ # Constructor
26
+ def initialize()
27
+ super( APP_PATH ) # Call parent constructor.
28
+ end # initialize
29
+
30
+
31
+ # Generate help files.
32
+ # srcPath:: Source file [.tex]. Path must use forward slashes.
33
+ # destPath:: Destination file. Path must use forward slashes.
34
+ def generateHelpFiles(srcPath, destPath)
35
+ srcDir = File.dirname( File.expand_path( srcPath ) )
36
+ srcFile = File.basename( srcPath )
37
+ destPath = File.expand_path( destPath )
38
+ destDir = File.dirname( destPath )
39
+
40
+ puts "srcDir: #{srcDir}"
41
+ puts "srcPath: #{srcPath}"
42
+ puts "destDir: #{destDir}"
43
+ puts "destPath: #{destPath}"
44
+
45
+ if( !File.exists?( destDir ) ) # Create the destination dir if it doesn't exits.
46
+ File.makedirs( destDir, true )
47
+ end
48
+
49
+ cmdLine = "#{srcFile} #{destPath} -checkcurleybraces -checksyntax -html"
50
+
51
+ curDir = pwd
52
+ cd( srcDir )
53
+ begin
54
+ execute( cmdLine, false )
55
+ rescue
56
+ # do nothing
57
+ end
58
+ cd( curDir )
59
+ end # generateHelpFiles
60
+
61
+
62
+ end # class Tex2Rtf
@@ -0,0 +1,5 @@
1
+ module RakeUtils
2
+ VERSION = "0.1.0" unless constants.include?("VERSION")
3
+ APPNAME = "RakeUtils" unless constants.include?("APPNAME")
4
+ COPYRIGHT = "Copyright (c) 2014, kTech Systems LLC. All rights reserved" unless constants.include?("COPYRIGHT")
5
+ end
@@ -0,0 +1,85 @@
1
+ ######################################################################################
2
+ #
3
+ # versioninc.rb
4
+ #
5
+ # Jeff McAffee 11/02/08
6
+ #
7
+ # Purpose: Version Incrementer class. Used to increment version text in version files (*.ver)
8
+ #
9
+ ######################################################################################
10
+
11
+ # Implements version incrementation support.
12
+
13
+ class VersionIncrementer
14
+ include FileUtils
15
+
16
+ # If optional filename is supplied, load the version from the file.
17
+ def initialize(filename=nil)
18
+ @version = [0,0,0]
19
+ read(filename) unless filename.nil?
20
+ end # initialize
21
+
22
+
23
+ def version()
24
+ @version.join(".")
25
+ end
26
+
27
+
28
+ def incMajor( filename )
29
+ read( filename )
30
+ @version[0] = @version[0] + 1
31
+ write( filename )
32
+ end # incMajor
33
+
34
+ def incMinor( filename )
35
+ read( filename )
36
+ @version[1] = @version[1] + 1
37
+ write( filename )
38
+ end # incMinor
39
+
40
+ def incBuild( filename )
41
+ read( filename )
42
+ @version[2] = @version[2] + 1
43
+ write( filename )
44
+ end # incBuild
45
+
46
+
47
+ def writeSetupIni(filename)
48
+ version = @version.join(".")
49
+ open(filename, 'w') do |f|
50
+ f << "[Info]\n"
51
+ f << "VerInfo=#{version}\n"
52
+ end
53
+
54
+ end # writeSetupIni
55
+
56
+
57
+ private
58
+ def write(filename)
59
+ version = @version.join(".")
60
+ open(filename, 'w') { |f| f << version }
61
+
62
+ end #write
63
+
64
+
65
+ def read(filename)
66
+ filepath = filename
67
+
68
+ version = ""
69
+ open(filepath) { |f| version = f.gets(nil) }
70
+ version.strip!
71
+ version.chomp!
72
+
73
+ aVersion = version.split( "." )
74
+ if( aVersion.length != 3 )
75
+ puts "ERROR: Version string must be 3 components. Bad string: #{version}"
76
+ return
77
+ end
78
+
79
+ aVersion.each_index do |i|
80
+ @version[i] = aVersion[i].to_i
81
+ end
82
+ end
83
+
84
+
85
+ end # class VersionIncrementer
@@ -0,0 +1,63 @@
1
+ ######################################################################################
2
+ #
3
+ # zipTask.rb
4
+ #
5
+ # Jeff McAffee 10/30/08
6
+ #
7
+ # Purpose: Implements 7Zip functionality for rake usage
8
+ #
9
+ ######################################################################################
10
+
11
+ =begin
12
+ tex2rtf command line:
13
+ m:\7Zip\7za.exe -tzip u ARCHIVENAME SOURCEDIR/FILENAME
14
+ =end
15
+
16
+ require_relative 'clapp'
17
+
18
+ # Implements programmatic control of the 7Zip application.
19
+
20
+ class ZipTask < CLApp
21
+ include FileUtils
22
+
23
+ APP_PATH = "M:/7Zip/7za.exe"
24
+
25
+
26
+ # Constructor
27
+ def initialize()
28
+ super( APP_PATH ) # Call parent constructor.
29
+ end # initialize
30
+
31
+
32
+ # Compress all files within a directory.
33
+ # srcPath:: Source directory. Path must use forward slashes.
34
+ # archivePath:: Destination file. Path must use forward slashes.
35
+ def compress(srcPath, archivePath)
36
+ srcDir = File.dirname( File.expand_path( srcPath ) )
37
+ srcFile = File.basename( srcPath )
38
+ archivePath = File.expand_path( archivePath )
39
+ destDir = File.dirname( archivePath )
40
+
41
+ puts "srcDir: #{srcDir}"
42
+ puts "srcPath: #{srcPath}"
43
+ puts "destDir: #{destDir}"
44
+ puts "archivePath: #{archivePath}"
45
+
46
+ if( !File.exists?( destDir ) ) # Create the destination dir if it doesn't exits.
47
+ File.makedirs( destDir, true )
48
+ end
49
+
50
+ cmdLine = "-tzip u #{archivePath} #{srcPath}"
51
+
52
+ curDir = pwd
53
+ cd( srcDir )
54
+ begin
55
+ execute( cmdLine, false )
56
+ rescue
57
+ # do nothing
58
+ end
59
+ cd( curDir )
60
+ end # compress
61
+
62
+
63
+ end # class ZipTask
data/lib/rakeutils.rb ADDED
@@ -0,0 +1,35 @@
1
+ ###############################################################################
2
+ # File: rakeutils.rb
3
+ # Purpose: rakeutils master include file
4
+ #
5
+ # Author: Jeff McAffee 10/25/2008
6
+ # Copyright: Copyright (c) 2008, Jeff McAffee
7
+ # All rights reserved. See LICENSE.txt for details.
8
+ # Website: http://JeffMcAffee.com
9
+ ##############################################################################
10
+ require 'rakeutils/version'
11
+
12
+ module RakeUtils
13
+
14
+ end
15
+
16
+ require 'logger'
17
+
18
+ require 'rakeutils/clapp'
19
+ require 'rakeutils/filegentask'
20
+ require 'rakeutils/innotask'
21
+ require 'rakeutils/javacctask'
22
+ require 'rakeutils/jjtreetask'
23
+ require 'rakeutils/ocratask'
24
+ require 'rakeutils/text2rtf'
25
+ require 'rakeutils/versioninc'
26
+ require 'rakeutils/ziptask'
27
+
28
+ #require 'find'
29
+ #
30
+ #class_files = File.join( File.dirname(__FILE__), 'rakeutils', '*.rb')
31
+ #$: << File.join( File.dirname(__FILE__), 'rakeutils') # Add directory to the include file array
32
+ #Dir.glob(class_files) do | class_file |
33
+ # require class_file[/\w+\.rb$/]
34
+ #end
35
+
data/rakefile.rb ADDED
@@ -0,0 +1,15 @@
1
+ ##############################################################################
2
+ # File: rakefile.rb
3
+ # Purpose: Build tasks for rakeutils gem
4
+ #
5
+ # Author: Jeff McAffee 05/02/2010
6
+ # Copyright: Copyright (c) 2010, Jeff McAffee
7
+ # All rights reserved. See LICENSE.txt for details.
8
+ # Website: http://JeffMcAffee.com
9
+ ##############################################################################
10
+
11
+ require "bundler/gem_tasks"
12
+ require 'rake/clean'
13
+
14
+ CLEAN.include("pkg")
15
+ CLOBBER.include("pkg")
data/rakeutils.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rakeutils/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.platform = Gem::Platform::RUBY
8
+ spec.name = "rakeutils"
9
+ spec.version = RakeUtils::VERSION
10
+ spec.authors = ["Jeff McAffee"]
11
+ spec.email = ["jeff@ktechsystems.com"]
12
+ spec.description = %q{Rake task classes for 3rd party apps}
13
+ spec.summary = spec.description
14
+ spec.homepage = "https://github.com/jmcaffee/rakeutils"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake"
24
+ #spec.add_runtime_dependency "win32ole"
25
+ #spec.add_runtime_dependency "ktcommon"
26
+ spec.add_runtime_dependency "ktutils"
27
+ end
@@ -0,0 +1,29 @@
1
+ require 'rakeutils/innotask'
2
+
3
+ describe InnoTask do
4
+
5
+ context '#new' do
6
+
7
+ it "raises an exception if Inno Setup is not installed" do
8
+ InnoTask
9
+ .any_instance
10
+ .should_receive(:find_app)
11
+ .twice
12
+ .and_return ""
13
+
14
+ expect { InnoTask.new }.to raise_error
15
+ end
16
+
17
+ it "doesn't raise an exception if Inno Setup is installed" do
18
+ # Note: the file/directory has to exist or the ctor will fail anyway.
19
+ InnoTask
20
+ .any_instance
21
+ .should_receive(:find_app)
22
+ .twice
23
+ .and_return "/tmp"
24
+
25
+ expect { InnoTask.new }.not_to raise_error
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'rakeutils/javacctask'
2
+
3
+ describe JavaCCTask do
4
+
5
+ context '#new' do
6
+
7
+ it "raises an exception if JavaCC is not installed" do
8
+ JavaCCTask
9
+ .any_instance
10
+ .should_receive(:find_app)
11
+ .twice
12
+ .and_return ""
13
+
14
+ expect { JavaCCTask.new }.to raise_error
15
+ end
16
+
17
+ it "doesn't raise an exception if JavaCC is installed" do
18
+ # Note: the file/directory has to exist or the ctor will fail anyway.
19
+ JavaCCTask
20
+ .any_instance
21
+ .should_receive(:find_app)
22
+ .twice
23
+ .and_return "/tmp"
24
+
25
+ expect { JavaCCTask.new }.not_to raise_error
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'rakeutils/jjtreetask'
2
+
3
+ describe JJTreeTask do
4
+
5
+ context '#new' do
6
+
7
+ it "raises an exception if JJTree is not installed" do
8
+ JJTreeTask
9
+ .any_instance
10
+ .should_receive(:find_app)
11
+ .twice
12
+ .and_return ""
13
+
14
+ expect { JJTreeTask.new }.to raise_error
15
+ end
16
+
17
+ it "doesn't raise an exception if JJTree is installed" do
18
+ # Note: the file/directory has to exist or the ctor will fail anyway.
19
+ JJTreeTask
20
+ .any_instance
21
+ .should_receive(:find_app)
22
+ .twice
23
+ .and_return "/tmp"
24
+
25
+ expect { JJTreeTask.new }.not_to raise_error
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,109 @@
1
+ require 'fakefs/spec_helpers'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+
44
+ # Allow use of the old style 'any_instance' doubling.
45
+ mocks.syntax = :should
46
+ end
47
+
48
+ # Include FakeFS whenever a test is tagged fakefs: true
49
+ # Example:
50
+ # describe "some test", fakefs: true do
51
+ # ...
52
+ # end
53
+ #
54
+ config.include FakeFS::SpecHelpers, fakefs: true
55
+
56
+ # The settings below are suggested to provide a good initial experience
57
+ # with RSpec, but feel free to customize to your heart's content.
58
+ =begin
59
+ # These two settings work together to allow you to limit a spec run
60
+ # to individual examples or groups you care about by tagging them with
61
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
62
+ # get run.
63
+ config.filter_run :focus
64
+ config.run_all_when_everything_filtered = true
65
+
66
+ # Limits the available syntax to the non-monkey patched syntax that is
67
+ # recommended. For more details, see:
68
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
69
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
70
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
71
+ config.disable_monkey_patching!
72
+
73
+ # This setting enables warnings. It's recommended, but in some cases may
74
+ # be too noisy due to issues in dependencies.
75
+ config.warnings = true
76
+
77
+ # Many RSpec users commonly either run the entire suite or an individual
78
+ # file, and it's useful to allow more verbose output when running an
79
+ # individual spec file.
80
+ if config.files_to_run.one?
81
+ # Use the documentation formatter for detailed output,
82
+ # unless a formatter has already been configured
83
+ # (e.g. via a command-line flag).
84
+ config.default_formatter = 'doc'
85
+ end
86
+
87
+ # Print the 10 slowest examples and example groups at the
88
+ # end of the spec run, to help surface which specs are running
89
+ # particularly slow.
90
+ config.profile_examples = 10
91
+
92
+ # Run specs in random order to surface order dependencies. If you find an
93
+ # order dependency and want to debug it, you can fix the order by providing
94
+ # the seed, which is printed after each run.
95
+ # --seed 1234
96
+ config.order = :random
97
+
98
+ # Seed global randomization in this process using the `--seed` CLI option.
99
+ # Setting this allows you to use `--seed` to deterministically reproduce
100
+ # test failures related to randomization by passing the same `--seed` value
101
+ # as the one that triggered the failure.
102
+ Kernel.srand config.seed
103
+ =end
104
+ end
105
+
106
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
107
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
108
+
109
+
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rakeutils
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff McAffee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: ktutils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Rake task classes for 3rd party apps
56
+ email:
57
+ - jeff@ktechsystems.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - lib/rakeutils.rb
68
+ - lib/rakeutils/clapp.rb
69
+ - lib/rakeutils/filegentask.rb
70
+ - lib/rakeutils/innotask.rb
71
+ - lib/rakeutils/javacctask.rb
72
+ - lib/rakeutils/jjtreetask.rb
73
+ - lib/rakeutils/ocratask.rb
74
+ - lib/rakeutils/tex2rtf.rb
75
+ - lib/rakeutils/version.rb
76
+ - lib/rakeutils/versioninc.rb
77
+ - lib/rakeutils/ziptask.rb
78
+ - rakefile.rb
79
+ - rakeutils.gemspec
80
+ - spec/lib/rakeutils/inno_task_spec.rb
81
+ - spec/lib/rakeutils/javacctask_spec.rb
82
+ - spec/lib/rakeutils/jjtree_task_spec.rb
83
+ - spec/spec_helper.rb
84
+ homepage: https://github.com/jmcaffee/rakeutils
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.3.0
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Rake task classes for 3rd party apps
108
+ test_files:
109
+ - spec/lib/rakeutils/inno_task_spec.rb
110
+ - spec/lib/rakeutils/javacctask_spec.rb
111
+ - spec/lib/rakeutils/jjtree_task_spec.rb
112
+ - spec/spec_helper.rb
113
+ has_rdoc: