lib/gjp/archiver.rb in gjp-0.36.0 vs lib/gjp/archiver.rb in gjp-0.37.0
- old
+ new
@@ -11,21 +11,21 @@
# generates an archive for the kit package
def archive_kit(full)
destination_dir = File.join(@project.full_path, "output", "#{@project.name}-kit")
FileUtils.mkdir_p(destination_dir)
- destination_file_prefix = "#{@project.name}-kit"
- destination_file_suffix = ".tar.xz"
+ file_prefix = "#{@project.name}-kit"
+ file_suffix = ".tar.xz"
@project.take_snapshot "Kit archival started"
destination_file = if full
- remove_stale_incremental(destination_dir, destination_file_prefix, destination_file_suffix)
- archive_single("kit", File.join(destination_dir, destination_file_prefix + destination_file_suffix))
+ remove_stale_incremental(destination_dir, file_prefix, file_suffix)
+ archive_single("kit", File.join(destination_dir, file_prefix + file_suffix))
else
log.debug "doing incremental archive"
- archive_incremental("kit", destination_dir, destination_file_prefix, destination_file_suffix, :archive_kit)
+ archive_incremental("kit", destination_dir, file_prefix, file_suffix, :archive_kit)
end
@project.take_snapshot "Kit archive generated", :archive_kit
destination_file
@@ -50,19 +50,19 @@
destination_file
end
# archives a directory's changed contents since last time archive_incremental was called
# uses snapshots with tag_prefix to keep track of calls to this method
- # destination files will be destination_file_prefix_NNNN_destination_file_suffix
- def archive_incremental(source_directory, destination_dir, destination_file_prefix, destination_file_suffix, tag_prefix)
+ # destination files will be file_prefix_NNNN_file_suffix
+ def archive_incremental(source_directory, destination_dir, file_prefix, file_suffix, tag_prefix)
@project.from_directory do
latest_tag_count = @project.latest_tag_count(tag_prefix)
if latest_tag_count == 0
- archive_single(source_directory, File.join(destination_dir, destination_file_prefix + destination_file_suffix))
+ archive_single(source_directory, File.join(destination_dir, file_prefix + file_suffix))
else
- destination_file = File.join(destination_dir, "#{destination_file_prefix}_#{"%04d" % (latest_tag_count)}#{destination_file_suffix}")
+ destination_file = File.join(destination_dir, "#{file_prefix}_#{"%04d" % (latest_tag_count)}#{file_suffix}")
tag = @project.latest_tag(tag_prefix)
log.debug "creating #{destination_file} with files newer than #{tag}"
log.debug "files that changed since then: #{@project.git.changed_files_since(tag)}"
list = @project.git.changed_files_since(tag).select do |file|
@@ -78,12 +78,12 @@
end
end
end
# removes any stale incremental files
- def remove_stale_incremental(destination_dir, destination_file_prefix, destination_file_suffix)
+ def remove_stale_incremental(destination_dir, file_prefix, file_suffix)
Dir.entries(destination_dir)
- .select { |f| f =~ /^#{destination_file_prefix}_([0-9]+)#{destination_file_suffix}$/}
+ .select { |f| f =~ /^#{file_prefix}_([0-9]+)#{file_suffix}$/}
.each do |f|
log.debug "removing stale incremental archive #{f}"
File.delete(File.join(destination_dir, f))
end
end