albacore 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +17 -7
- data/VERSION +1 -1
- data/install_dependencies.rb +46 -0
- data/lib/albacore.rb +1 -0
- data/lib/albacore/command.rb +23 -0
- data/lib/albacore/expandtemplates.rb +19 -4
- data/lib/albacore/msbuild.rb +3 -0
- data/lib/albacore/mspectestrunner.rb +22 -8
- data/lib/albacore/nunittestrunner.rb +5 -4
- data/lib/albacore/sftp.rb +19 -3
- data/lib/albacore/ssh.rb +20 -3
- data/lib/albacore/xunittestrunner.rb +48 -0
- data/lib/albacore/zipdirectory.rb +33 -12
- data/lib/rake/assemblyinfotask.rb +9 -15
- data/lib/rake/commandtask.rb +16 -0
- data/lib/rake/expandtemplatestask.rb +8 -14
- data/lib/rake/msbuildtask.rb +10 -15
- data/lib/rake/mspectask.rb +16 -0
- data/lib/rake/ncoverconsoletask.rb +9 -15
- data/lib/rake/ncoverreporttask.rb +9 -15
- data/lib/rake/nunittask.rb +9 -15
- data/lib/rake/renametask.rb +11 -16
- data/lib/rake/sftptask.rb +8 -14
- data/lib/rake/sqlcmdtask.rb +9 -15
- data/lib/rake/sshtask.rb +8 -14
- data/lib/rake/support/albacoretask.rb +19 -0
- data/lib/rake/xunittask.rb +16 -0
- data/lib/rake/ziptask.rb +9 -14
- data/rakefile.rb +95 -11
- data/spec/command_spec.rb +23 -0
- data/spec/commandtask_spec.rb +31 -0
- data/spec/expandtemplates_spec.rb +52 -0
- data/spec/expandtemplatestask_spec.rb +1 -1
- data/spec/msbuild_spec.rb +5 -5
- data/spec/msbuildtask_spec.rb +1 -1
- data/spec/mspectask_spec.rb +31 -0
- data/spec/ncoverconsole_spec.rb +43 -43
- data/spec/ncoverconsoletask_spec.rb +1 -1
- data/spec/ncoverreport_spec.rb +51 -51
- data/spec/ncoverreporttask_spec.rb +1 -1
- data/spec/nunittask_spec.rb +1 -1
- data/spec/nunittestrunner_spec.rb +64 -0
- data/spec/patches/system_patch.rb +5 -1
- data/spec/renametask_spec.rb +1 -1
- data/spec/sftptask_spec.rb +1 -1
- data/spec/sqlcmd_spec.rb +39 -39
- data/spec/sqlcmdtask_spec.rb +1 -1
- data/spec/sshtask_spec.rb +1 -1
- data/spec/support/CodeCoverage/xunit/assemblies/TestSolution.XUnitTests.dll +0 -0
- data/spec/support/CodeCoverage/xunit/assemblies/TestSolution.dll +0 -0
- data/spec/support/CodeCoverage/xunit/assemblies/xunit.dll +0 -0
- data/spec/support/CodeCoverage/xunit/assemblies/xunit.xml +2306 -0
- data/spec/support/TestSolution/TestSolution.XUnitTests/Class1.cs +19 -0
- data/spec/support/TestSolution/TestSolution.XUnitTests/Properties/AssemblyInfo.cs +36 -0
- data/spec/support/TestSolution/TestSolution.XUnitTests/TestSolution.XUnitTests.csproj +69 -0
- data/spec/support/TestSolution/TestSolution.sln +6 -0
- data/spec/support/expandtemplates/datafiles/sample_with_include.yml +2 -0
- data/spec/support/expandtemplates/datafiles/template_specific_data_file_with_include.yml +5 -0
- data/spec/support/expandtemplates/datafiles/template_specific_include.yml +3 -0
- data/spec/support/expandtemplatestestdata.rb +8 -0
- data/spec/support/spec_helper.rb +2 -0
- data/spec/xunittask_spec.rb +31 -0
- data/spec/zip_spec.rb +3 -3
- data/spec/ziptask_spec.rb +2 -1
- metadata +42 -4
data/README.markdown
CHANGED
@@ -14,7 +14,9 @@ If you would like to install the current, stable release of Albacore, you can do
|
|
14
14
|
|
15
15
|
**Step 2:** Install the Albacore gem
|
16
16
|
|
17
|
-
> gem install
|
17
|
+
> gem install albacore
|
18
|
+
|
19
|
+
(note: as of v0.0.7, the "albacore" gem is spelled with a lowercase "a".)
|
18
20
|
|
19
21
|
## How To Manually Build And Install The Albacore Gem
|
20
22
|
|
@@ -34,15 +36,15 @@ In your local clone of Albacore, use the jeweler rake tasks to build the latest
|
|
34
36
|
>
|
35
37
|
> rake jeweler:build
|
36
38
|
|
37
|
-
this will produce an '
|
39
|
+
this will produce an 'albacore-#.#.#.gem' file in the 'pkg' folder, where '#.#.#' is the version number. For example 'albacore-0.0.7.gem'.
|
38
40
|
|
39
41
|
**Step 3:** Install the gem
|
40
42
|
|
41
43
|
After building the gem, you can install it from your local file system.
|
42
44
|
|
43
|
-
> gem install -l pkg
|
45
|
+
> gem install -l pkg/albacore-#.#.#.gem
|
44
46
|
|
45
|
-
where '#.#.#' is the version number of the gem. For example '
|
47
|
+
where '#.#.#' is the version number of the gem. For example 'albacore-0.0.7.gem'
|
46
48
|
|
47
49
|
## How To Use Albacore
|
48
50
|
|
@@ -53,18 +55,26 @@ After installing Albacore, you only need to
|
|
53
55
|
in your rakefile. This will allow you to use the tasks that Albacore includes.
|
54
56
|
|
55
57
|
desc "Run a sample build using the MSBuildTask"
|
56
|
-
|
57
|
-
msb.properties :configuration => :Debug
|
58
|
+
msbuildtask do |msb|
|
59
|
+
msb.properties = {:configuration => :Debug}
|
58
60
|
msb.targets [:Clean, :Build]
|
59
61
|
msb.solution = "spec/support/TestSolution/TestSolution.sln"
|
60
62
|
end
|
61
63
|
|
62
64
|
Beyond the simple example, check out the [Albacore Wiki](http://wiki.github.com/derickbailey/Albacore) for detailed instructions on how to use the built in tasks and their options.
|
63
65
|
|
66
|
+
## How To Contribute, Collaborate, Communicate
|
67
|
+
|
68
|
+
If you'd like to get involved with the Albacore framework, we have a discussion group over at google: **[AlbacoreDev](http://groups.google.com/group/albacoredev)**
|
69
|
+
|
70
|
+
Anyone can fork the main repository and submit patches, as well. And lastly, the [wiki](http://wiki.github.com/derickbailey/Albacore) and [issues list](http://github.com/derickbailey/Albacore/issues) are also open for additions, edits, and discussion.
|
71
|
+
|
64
72
|
## Contributors
|
65
73
|
|
66
74
|
Many thanks for contributions to Albacore are due:
|
67
75
|
|
68
|
-
* [Ben Hall](http://github.com/benhall): SSH, SFTP, ZipDirectory, Rename, YAML auto config, and other great additions
|
76
|
+
* [Ben Hall](http://github.com/benhall): SSH, SFTP, ZipDirectory, Rename, YAML auto config, Wiki pages, and other great additions
|
77
|
+
* [Steven Harman] (http://github.com/stevenharman): Finding some wicked bugs, patching nunit test runner, and working on the nant task
|
78
|
+
* [Brian Donahue] (http://github.com/briandonahue): Inspiration and initial code for the ExpandTemplates task
|
69
79
|
* [Sean Biefeld](http://github.com/seanbiefeld): MSpecTestRunner for NCoverConsole
|
70
80
|
* [Kevin Colyar](http://github.com/kevincolyar): Testing and updating of MSBuild to work with Cygwin
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/gem_runner'
|
3
|
+
require 'rubygems/exceptions'
|
4
|
+
|
5
|
+
#http://gist.github.com/236148
|
6
|
+
required_version = Gem::Requirement.new "> 1.8.3"
|
7
|
+
|
8
|
+
unless required_version.satisfied_by? Gem.ruby_version then
|
9
|
+
abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def install(lib)
|
13
|
+
begin
|
14
|
+
matches = Gem.source_index.find_name(lib)
|
15
|
+
if matches.empty?
|
16
|
+
puts "Installing #{lib}"
|
17
|
+
Gem::GemRunner.new.run ['install', lib]
|
18
|
+
else
|
19
|
+
puts "Found #{lib} gem - skipping"
|
20
|
+
end
|
21
|
+
rescue Gem::SystemExitException => e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_source(url)
|
26
|
+
begin
|
27
|
+
if Gem.sources.include?(url)
|
28
|
+
puts "Found #{url} gem source = skipping"
|
29
|
+
else
|
30
|
+
puts "Adding #{url} gem source."
|
31
|
+
Gem::GemRunner.new.run ['sources', '-a', url]
|
32
|
+
end
|
33
|
+
rescue Gem::SystemExitException => e
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
puts "Installing required dependencies"
|
38
|
+
add_source 'http://gemcutter.org'
|
39
|
+
install 'rake'
|
40
|
+
install 'net-ssh'
|
41
|
+
install 'net-sftp'
|
42
|
+
install 'rubyzip'
|
43
|
+
install 'jeweler'
|
44
|
+
install 'rspec'
|
45
|
+
install 'derickbailey-notamock'
|
46
|
+
install 'jekyll'
|
data/lib/albacore.rb
CHANGED
@@ -5,5 +5,6 @@ $: << File.expand_path(File.join(File.dirname(__FILE__), "rake"))
|
|
5
5
|
|
6
6
|
require 'logging'
|
7
7
|
|
8
|
+
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'rake/support/*.rb')).each {|f| require f }
|
8
9
|
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'rake/*.rb')).each {|f| require f }
|
9
10
|
Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'albacore/*.rb')).each {|f| require f }
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
|
3
|
+
class Command
|
4
|
+
include RunCommand
|
5
|
+
include YAMLConfig
|
6
|
+
include Logging
|
7
|
+
|
8
|
+
attr_accessor :parameters
|
9
|
+
|
10
|
+
def initialize()
|
11
|
+
super()
|
12
|
+
@require_valid_command=false
|
13
|
+
@path_to_command=''
|
14
|
+
@parameters = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute()
|
18
|
+
result = run_command "Command", @parameters.join(" ")
|
19
|
+
|
20
|
+
failure_message = 'Command Failed. See Build Log For Detail'
|
21
|
+
fail_with_message failure_message if !result
|
22
|
+
end
|
23
|
+
end
|
@@ -16,7 +16,7 @@ class ExpandTemplates
|
|
16
16
|
return if @data_file.nil?
|
17
17
|
return if @expand_files.empty?
|
18
18
|
|
19
|
-
config = read_config
|
19
|
+
config = read_config(@data_file)
|
20
20
|
@expand_files.each { |template_file, output_file|
|
21
21
|
file_config = get_config_for_file config, template_file
|
22
22
|
expand_template template_file, output_file, file_config
|
@@ -45,15 +45,30 @@ private
|
|
45
45
|
}
|
46
46
|
end
|
47
47
|
|
48
|
-
def read_config
|
49
|
-
YAML::load(File.open(
|
48
|
+
def read_config(file)
|
49
|
+
config = YAML::load(File.open(file, "r"))
|
50
|
+
if (config.include?("@include"))
|
51
|
+
include_file = File.join(File.dirname(file), config["@include"])
|
52
|
+
@logger.debug("Found @include directive. Loading additional data from #{include_file}")
|
53
|
+
config.reject!{|k,v| k == "@include"}
|
54
|
+
include_config = read_config(include_file)
|
55
|
+
config = deep_merge(include_config, config)
|
56
|
+
end
|
57
|
+
return config
|
58
|
+
end
|
59
|
+
|
60
|
+
def deep_merge(first, second)
|
61
|
+
# From: http://www.ruby-forum.com/topic/142809
|
62
|
+
# Author: Stefan Rusterholz
|
63
|
+
merger = proc { |key,v1,v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
|
64
|
+
first.merge(second, &merger)
|
50
65
|
end
|
51
66
|
|
52
67
|
def get_config_for_file(original_config, file)
|
53
68
|
filename = File.basename(file)
|
54
69
|
file_config = original_config[filename]
|
55
70
|
if file_config.nil?
|
56
|
-
@logger.debug "No config data found for #{filename}. Using
|
71
|
+
@logger.debug "No config data found for #{filename}. Using local data."
|
57
72
|
new_config = original_config
|
58
73
|
else
|
59
74
|
@logger.debug "Found config data for #{filename}."
|
data/lib/albacore/msbuild.rb
CHANGED
@@ -3,6 +3,7 @@ require 'albacore/support/albacore_helper'
|
|
3
3
|
class MSBuild
|
4
4
|
include RunCommand
|
5
5
|
include YAMLConfig
|
6
|
+
include Logging
|
6
7
|
|
7
8
|
attr_accessor :solution, :verbosity
|
8
9
|
|
@@ -13,6 +14,8 @@ class MSBuild
|
|
13
14
|
|
14
15
|
def build_path_to_command
|
15
16
|
win_dir = ENV['windir'] || ENV['WINDIR']
|
17
|
+
win_dir = 'C:/Windows' if win_dir.nil?
|
18
|
+
|
16
19
|
File.join(win_dir.dup, 'Microsoft.NET', 'Framework', 'v3.5', 'MSBuild.exe')
|
17
20
|
end
|
18
21
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'albacore/support/albacore_helper'
|
2
2
|
|
3
3
|
class MSpecTestRunner
|
4
|
-
|
4
|
+
include RunCommand
|
5
5
|
include YAMLConfig
|
6
6
|
|
7
|
-
attr_accessor :assemblies, :path_to_command, :html_output
|
7
|
+
attr_accessor :assemblies, :path_to_command, :html_output, :options
|
8
8
|
|
9
|
-
def initialize(path_to_command)
|
9
|
+
def initialize(path_to_command='')
|
10
10
|
super()
|
11
11
|
@path_to_command = path_to_command
|
12
12
|
@assemblies=[]
|
@@ -15,12 +15,26 @@ class MSpecTestRunner
|
|
15
15
|
def get_command_line
|
16
16
|
command = []
|
17
17
|
command << @path_to_command
|
18
|
-
command <<
|
19
|
-
|
18
|
+
command << get_command_parameters
|
19
|
+
cmd = command.join(" ")
|
20
|
+
@logger.debug "Build MSpec Test Runner Command Line: " + cmd
|
21
|
+
return cmd
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_command_parameters
|
25
|
+
command_params = []
|
26
|
+
command_params << build_assembly_list unless @assemblies.empty?
|
27
|
+
command_params << @options.join(" ") unless @options.nil?
|
28
|
+
command_params << build_html_output unless @html_output.nil?
|
29
|
+
command_params
|
30
|
+
end
|
31
|
+
|
32
|
+
def execute()
|
33
|
+
command_params = get_command_parameters
|
34
|
+
result = run_command "MSpec", command_params.join(" ")
|
20
35
|
|
21
|
-
|
22
|
-
|
23
|
-
cmdline
|
36
|
+
failure_message = 'MSpec Failed. See Build Log For Detail'
|
37
|
+
fail_with_message failure_message if !result
|
24
38
|
end
|
25
39
|
|
26
40
|
def build_assembly_list
|
@@ -4,7 +4,7 @@ class NUnitTestRunner
|
|
4
4
|
include RunCommand
|
5
5
|
include YAMLConfig
|
6
6
|
|
7
|
-
attr_accessor :assemblies, :options
|
7
|
+
attr_accessor :path_to_command, :assemblies, :options
|
8
8
|
|
9
9
|
def initialize(path_to_command='')
|
10
10
|
super()
|
@@ -14,7 +14,9 @@ class NUnitTestRunner
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def get_command_line
|
17
|
-
command_params =
|
17
|
+
command_params = []
|
18
|
+
command_params << @path_to_command
|
19
|
+
command_params << get_command_parameters
|
18
20
|
commandline = command_params.join(" ")
|
19
21
|
@logger.debug "Build NUnit Test Runner Command Line: " + commandline
|
20
22
|
commandline
|
@@ -22,7 +24,6 @@ class NUnitTestRunner
|
|
22
24
|
|
23
25
|
def get_command_parameters
|
24
26
|
command_params = []
|
25
|
-
command_params << @path_to_command
|
26
27
|
command_params << @assemblies.join(" ") unless @assemblies.nil?
|
27
28
|
command_params << @options.join(" ") unless @options.nil?
|
28
29
|
command_params
|
@@ -30,7 +31,7 @@ class NUnitTestRunner
|
|
30
31
|
|
31
32
|
def execute()
|
32
33
|
command_params = get_command_parameters
|
33
|
-
result = run_command "NUnit", command_params
|
34
|
+
result = run_command "NUnit", command_params.join(" ")
|
34
35
|
|
35
36
|
failure_message = 'NUnit Failed. See Build Log For Detail'
|
36
37
|
fail_with_message failure_message if !result
|
data/lib/albacore/sftp.rb
CHANGED
@@ -5,15 +5,26 @@ class Sftp
|
|
5
5
|
include YAMLConfig
|
6
6
|
include Logging
|
7
7
|
|
8
|
-
attr_accessor :server, :username, :password, :upload_files
|
9
|
-
|
8
|
+
attr_accessor :server, :username, :password, :upload_files, :port, :key, :debug
|
9
|
+
|
10
10
|
def initialize
|
11
11
|
super()
|
12
12
|
@upload_files = {}
|
13
13
|
end
|
14
14
|
|
15
|
+
def get_connection_options
|
16
|
+
options = {}
|
17
|
+
options[:verbose] = :debug if @debug == true
|
18
|
+
options[:password] = @password if @password
|
19
|
+
options[:port] = @port if @port
|
20
|
+
options[:keys] = [@key] if @key
|
21
|
+
options
|
22
|
+
end
|
23
|
+
|
15
24
|
def upload()
|
16
|
-
|
25
|
+
warn_about_key if @key
|
26
|
+
|
27
|
+
Net::SFTP.start(@server, @username, get_connection_options) do |sftp|
|
17
28
|
@logger.debug "Starting File Upload"
|
18
29
|
@upload_files.each {|local_file, remote_file|
|
19
30
|
@logger.debug "Uploading #{local_file} to #{remote_file}"
|
@@ -21,4 +32,9 @@ class Sftp
|
|
21
32
|
}
|
22
33
|
end
|
23
34
|
end
|
35
|
+
|
36
|
+
def warn_about_key()
|
37
|
+
info.debug 'When using a key, you need an SSH-Agent running to manage the keys.'
|
38
|
+
info.debug 'On Windows, a recommended agent is called Pageant, downloadable from the Putty site.'
|
39
|
+
end
|
24
40
|
end
|
data/lib/albacore/ssh.rb
CHANGED
@@ -5,15 +5,26 @@ class Ssh
|
|
5
5
|
include YAMLConfig
|
6
6
|
include Logging
|
7
7
|
|
8
|
-
attr_accessor :server, :username, :password, :commands
|
9
|
-
|
8
|
+
attr_accessor :server, :username, :password, :commands, :port, :key, :debug
|
9
|
+
|
10
10
|
def initialize
|
11
11
|
super()
|
12
12
|
@commands = []
|
13
13
|
end
|
14
|
+
|
15
|
+
def get_connection_options
|
16
|
+
options = {}
|
17
|
+
options[:verbose] = :debug if @debug == true
|
18
|
+
options[:password] = @password if @password
|
19
|
+
options[:port] = @port if @port
|
20
|
+
options[:keys] = [@key] if @key
|
21
|
+
options
|
22
|
+
end
|
14
23
|
|
15
24
|
def execute()
|
16
|
-
|
25
|
+
warn_about_key if @key
|
26
|
+
|
27
|
+
Net::SSH.start(@server, @username, get_connection_options) do |ssh|
|
17
28
|
@commands.each{|cmd|
|
18
29
|
@logger.info "Executing remote command: #{cmd}"
|
19
30
|
output = ssh.exec!(cmd)
|
@@ -22,4 +33,10 @@ class Ssh
|
|
22
33
|
}
|
23
34
|
end
|
24
35
|
end
|
36
|
+
|
37
|
+
def warn_about_key()
|
38
|
+
info.debug 'When using a key, you need an SSH-Agent running to manage the keys.'
|
39
|
+
info.debug 'On Windows, a recommended agent is called Pageant, downloadable from the Putty site.'
|
40
|
+
end
|
41
|
+
|
25
42
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'albacore/support/albacore_helper'
|
2
|
+
|
3
|
+
class XUnitTestRunner
|
4
|
+
include RunCommand
|
5
|
+
include YAMLConfig
|
6
|
+
|
7
|
+
attr_accessor :assemblies, :path_to_command, :html_output, :options
|
8
|
+
|
9
|
+
def initialize(path_to_command='')
|
10
|
+
super()
|
11
|
+
@path_to_command = path_to_command
|
12
|
+
@assemblies=[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_command_line
|
16
|
+
command = []
|
17
|
+
command << @path_to_command
|
18
|
+
command << get_command_parameters
|
19
|
+
|
20
|
+
cmd = command.join(" ")
|
21
|
+
@logger.debug "Build XUnit Test Runner Command Line: " + cmd
|
22
|
+
return cmd
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_command_parameters
|
26
|
+
command_params = []
|
27
|
+
command_params << build_assembly_list unless @assemblies.empty?
|
28
|
+
command_params << @options.join(" ") unless @options.nil?
|
29
|
+
command_params << build_html_output unless @html_output.nil?
|
30
|
+
command_params
|
31
|
+
end
|
32
|
+
|
33
|
+
def execute()
|
34
|
+
command_params = get_command_parameters
|
35
|
+
result = run_command "XUnit", command_params.join(" ")
|
36
|
+
|
37
|
+
failure_message = 'XUnit Failed. See Build Log For Detail'
|
38
|
+
fail_with_message failure_message if !result
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_assembly_list
|
42
|
+
@assemblies.map{|asm| "\"#{asm}\""}.join(" ")
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_html_output
|
46
|
+
"/html #{@html_output}"
|
47
|
+
end
|
48
|
+
end
|
@@ -5,19 +5,22 @@ include Zip
|
|
5
5
|
|
6
6
|
class ZipDirectory
|
7
7
|
include YAMLConfig
|
8
|
-
|
9
|
-
|
10
|
-
attr_accessor :additional_files
|
11
|
-
attr_accessor :
|
8
|
+
include Failure
|
9
|
+
|
10
|
+
attr_accessor :directories_to_zip, :additional_files
|
11
|
+
attr_accessor :output_path, :output_file
|
12
|
+
attr_accessor :flatten_zip
|
12
13
|
|
13
14
|
def initialize
|
14
15
|
super()
|
16
|
+
@flatten_zip = true
|
15
17
|
end
|
16
18
|
|
17
19
|
def package()
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
fail_with_message 'Output File cannot be empty' if @output_file.nil?
|
21
|
+
return if @output_file.nil?
|
22
|
+
|
23
|
+
clean_directories_names
|
21
24
|
remove zip_name
|
22
25
|
|
23
26
|
ZipFile.open(zip_name, 'w') do |zipfile|
|
@@ -26,6 +29,11 @@ class ZipDirectory
|
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
32
|
+
def clean_directories_names
|
33
|
+
return if @directories_to_zip.nil?
|
34
|
+
@directories_to_zip.each { |d| d.sub!(%r[/$],'')}
|
35
|
+
end
|
36
|
+
|
29
37
|
def remove(filename)
|
30
38
|
FileUtils.rm filename, :force=>true
|
31
39
|
end
|
@@ -35,20 +43,33 @@ class ZipDirectory
|
|
35
43
|
end
|
36
44
|
|
37
45
|
def zip_name()
|
38
|
-
|
46
|
+
@output_path = set_output_path
|
47
|
+
File.join(@output_path, @output_file)
|
48
|
+
end
|
49
|
+
|
50
|
+
def set_output_path()
|
51
|
+
path = ''
|
52
|
+
path = @directories_to_zip.first unless @directories_to_zip.nil?
|
53
|
+
path = @output_path unless @output_path.nil?
|
54
|
+
return path
|
39
55
|
end
|
56
|
+
|
40
57
|
|
41
58
|
def zip_directory(zipfile)
|
42
|
-
|
43
|
-
|
44
|
-
|
59
|
+
return if @directories_to_zip.nil?
|
60
|
+
@directories_to_zip.each do |d|
|
61
|
+
Dir["#{d}/**/**"].reject{|f| reject_file(f)}.each do |file_path|
|
62
|
+
file_name = file_path
|
63
|
+
file_name = file_path.sub(d + '/','') if @flatten_zip
|
64
|
+
zipfile.add(file_name, file_path)
|
65
|
+
end
|
45
66
|
end
|
46
67
|
end
|
47
68
|
|
48
69
|
def zip_additional(zipfile)
|
49
70
|
return if @additional_files.nil?
|
50
71
|
@additional_files.reject{|f| reject_file(f)}.each do |file_path|
|
51
|
-
file_name = file_path
|
72
|
+
file_name = file_path.split('/').last if @flatten_zip
|
52
73
|
zipfile.add(file_name, file_path)
|
53
74
|
end
|
54
75
|
end
|