Class: RakeDotNet::SevenZipCmd

Inherits:
Object
  • Object
show all
Defined in:
lib/rake_dotnet.rb

Instance Method Summary collapse

Constructor Details

#initialize(archive_name, opts = {}) {|_self| ... } ⇒ SevenZipCmd

Returns a new instance of SevenZipCmd.

Yields:

  • (_self)

Yield Parameters:



1058
1059
1060
1061
1062
1063
1064
1065
1066
# File 'lib/rake_dotnet.rb', line 1058

def initialize(archive_name, opts={})
	arch = ENV['PROCESSOR_ARCHITECTURE'] || 'AMD64'
	bin = arch == 'x86' ? '7za.exe' : '7z.exe'
	@exe = opts[:sevenzip] || File.expand_path(File.join(TOOLS_DIR, '7zip', arch, bin))
	@archive_name = File.expand_path(archive_name)
	@params = opts

	yield self if block_given?
end

Instance Method Details

#archive_nameObject



1091
1092
1093
# File 'lib/rake_dotnet.rb', line 1091

def archive_name
	"\"#{@archive_name}\""
end

#cmd_addObject



1068
1069
1070
# File 'lib/rake_dotnet.rb', line 1068

def cmd_add
	"#{exe} a #{archive_name} #{file_names}"
end

#cmd_extractObject



1077
1078
1079
# File 'lib/rake_dotnet.rb', line 1077

def cmd_extract
	"#{exe} x -y #{out_dir} #{archive_name} #{file_names}"
end

#exeObject



1108
1109
1110
# File 'lib/rake_dotnet.rb', line 1108

def exe
	"\"#{@exe}\""
end

#file_namesObject



1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
# File 'lib/rake_dotnet.rb', line 1095

def file_names
	fns = @params[:file_names]
	if fns.is_a? String
		"\"#{fns}\""
	elsif fns.is_a? Array
		list = ''
		fns.each do |fn|
			list += "\"#{File.expand_path(fn)}\" "
		end
		list.chop
	end
end

#out_dirObject



1086
1087
1088
1089
# File 'lib/rake_dotnet.rb', line 1086

def out_dir
	od = @params[:out_dir]
	"-o#{File.expand_path(od)}" unless @params[:out_dir].nil?
end

#run_addObject



1072
1073
1074
1075
# File 'lib/rake_dotnet.rb', line 1072

def run_add
	puts cmd_add if VERBOSE
	sh cmd_add
end

#run_extractObject



1081
1082
1083
1084
# File 'lib/rake_dotnet.rb', line 1081

def run_extract
	puts cmd_extract if VERBOSE
	sh cmd_extract
end