lib/gjp/archiver.rb in gjp-0.37.0 vs lib/gjp/archiver.rb in gjp-0.38.0
- old
+ new
@@ -1,11 +1,11 @@
# encoding: UTF-8
module Gjp
# generates file archives that accompany spec files
class Archiver
- include Logger
+ include Logging
def initialize(project)
@project = project
end
@@ -16,20 +16,22 @@
file_prefix = "#{@project.name}-kit"
file_suffix = ".tar.xz"
@project.take_snapshot "Kit archival started"
- destination_file = if full
- 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, file_prefix, file_suffix, :archive_kit)
- end
+ destination_file = (
+ if full
+ 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, file_prefix, file_suffix, :archive_kit)
+ end
+ )
@project.take_snapshot "Kit archive generated", :archive_kit
-
+
destination_file
end
# generates an archive for a project's package based on its file list
def archive_package(name)
@@ -64,11 +66,11 @@
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|
- File.expand_path(file) =~ /^#{File.expand_path(source_directory)}\//
+ File.expand_path(file) =~ /^#{File.expand_path(source_directory)}\//
end.map do |file|
Pathname.new(file).relative_path_from Pathname.new(source_directory)
end
@project.from_directory source_directory do
`tar -cJf #{destination_file} #{list.join(" ")}`
@@ -80,10 +82,10 @@
end
# removes any stale incremental files
def remove_stale_incremental(destination_dir, file_prefix, file_suffix)
Dir.entries(destination_dir)
- .select { |f| f =~ /^#{file_prefix}_([0-9]+)#{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