class ToTarXz
#¶ ↑
require 'totarxz/constants.rb'
#¶ ↑
#¶ ↑
require 'totarxz/version/version.rb'
#¶ ↑
Constants
- BE_VERBOSE
#¶ ↑
BE_VERBOSE
¶ ↑Whether to be verbose by default or whether we will not be verbose.
#¶ ↑
- TAR_BZ2_EXTENSION
#¶ ↑
TAR_BZ2_EXTENSION
¶ ↑#¶ ↑
- TAR_XZ_EXTENSION
#¶ ↑
TAR_XZ_EXTENSION
¶ ↑#¶ ↑
- VERSION
#¶ ↑
ToTarXz
¶ ↑#¶ ↑
Public Class Methods
[](i)
click to toggle source
new( package_this_target = nil, be_verbose = BE_VERBOSE, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
The first argument is the target to become a .tar.xz archive.
#¶ ↑
# File lib/totarxz/totarxz.rb, line 30 def initialize( package_this_target = nil, be_verbose = BE_VERBOSE, run_already = true, &block ) @be_verbose = be_verbose # default reset # This must come after @be_verbose was set. be_verbose if be_verbose # Be silent not before calling sanitize_data(). set_package_this_target( package_this_target ) case run_already # ======================================================================= # # === --help # ======================================================================= # when /^-?-?help$/i show_help_then_exit # ======================================================================= # # === --date # ======================================================================= # when /^-?-?date$/, 'TODAY','DATE','WITH_DATE' @repackage_archive_to_todays_date = true run_already = true end # ======================================================================= # # === Handle blocks next # # Intercept blocks here. Handle :be_verbose as argument, but also # certain keys in a Hash, since as of June 2020. # ======================================================================= # if block_given? yielded = yield case yielded when :be_silent @be_verbose = false when :be_verbose @be_verbose = true else if yielded.is_a? Hash # ================================================================= # # === :use_this_archive_name => "htop-2.2.0" # ================================================================= # if yielded.has_key? :use_this_archive_name set_tar_xz_name(yielded.delete(:use_this_archive_name)) end end end end run if run_already end
Public Instance Methods
abort_then_exit()
click to toggle source
be_silent?()
click to toggle source
be_verbose?()
click to toggle source
build_cmd_string()
click to toggle source
determine_tar_xz_name( i = input?.delete('/')+ TAR_XZ_EXTENSION )
click to toggle source
extract_to_this_directory?()
click to toggle source
location?()
click to toggle source
mv(old, new)
click to toggle source
package_this_target?()
click to toggle source
rename?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/totarxz/totarxz.rb, line 86 def reset if @be_verbose @cmd = 'tar cJvf ' # v stands for verbosity here. else @cmd = 'tar cJf ' # v stands for verbosity here. end # ======================================================================= # # === @cmd # ======================================================================= # @cmd = @cmd.dup # ======================================================================= # # === @archive_type # ======================================================================= # @archive_type = '.tar.xz' # ======================================================================= # # === @repackage_archive_to_todays_date # ======================================================================= # @repackage_archive_to_todays_date = false # ======================================================================= # # === @orig_stdout # ======================================================================= # @orig_stdout = nil end
run()
click to toggle source
run_cmd()
click to toggle source
#¶ ↑
run_cmd
¶ ↑
#¶ ↑
# File lib/totarxz/totarxz.rb, line 249 def run_cmd e @cmd system @cmd # ======================================================================= # # Next, we will apply a mv-action if we repackage to another name. # ======================================================================= # if rename? new_name = File.basename(archive?).sub(/\.tar\.xz$/, '')+'-'+ today?+@archive_type opn; e 'Next renaming the archive to `'+sfancy(new_name)+'`.' mv(archive?, new_name) end $stdout = @orig_stdout unless be_verbose? # Restore stdout again. end
Also aliased as: create_tarxz_package
set_cmd(i)
click to toggle source
set_package_this_target( i = nil )
click to toggle source
#¶ ↑
set_package_this_target
¶ ↑
This method will be called from within initialize().
#¶ ↑
# File lib/totarxz/totarxz.rb, line 153 def set_package_this_target( i = nil ) if i.is_a? Array and !i.empty? i = i.join(' ').strip end if i and i.end_with?('*') # In this case continue. elsif i.nil? or !File.exist?(i.to_s) abort_then_exit end case i # ======================================================================= # # === --help # ======================================================================= # when /^-?-?help$/i show_help_then_exit end i = i.to_s.dup unless i.end_with? '*' i << '/' unless i.end_with? '/' end i.gsub!(/\.tar\.xz$/, '') if i.include? '.tar.xz' i.gsub!(/\.tar\.bz2$/, '') if i.include? '.tar.bt2' @package_this_target = i # ======================================================================= # # Now we can determine the .tar.xz name. # ======================================================================= # determine_tar_xz_name end
set_tar_xz_name(i)
click to toggle source
show_help()
click to toggle source
show_help_then_exit()
click to toggle source
silence()
click to toggle source