lib/fig/repository.rb in fig-0.1.65 vs lib/fig/repository.rb in fig-0.1.67

- old
+ new

@@ -1,21 +1,22 @@ require 'set' require 'socket' require 'sys/admin' require 'tmpdir' -require 'fig/atexit' +require 'fig' +require 'fig/at_exit' require 'fig/command' require 'fig/logging' -require 'fig/notfounderror' -require 'fig/packagecache' -require 'fig/packagedescriptor' +require 'fig/not_found_error' +require 'fig/package_cache' +require 'fig/package_descriptor' require 'fig/parser' -require 'fig/repositoryerror' +require 'fig/repository_error' require 'fig/statement/archive' require 'fig/statement/resource' -require 'fig/urlaccesserror' +require 'fig/url_access_error' module Fig; end # Overall management of a repository. Handles local operations itself; # defers remote operations to others. @@ -32,20 +33,16 @@ def initialize( os, local_repository_directory, application_config, remote_repository_user, - update, - update_if_missing, check_include_versions ) @operating_system = os @local_repository_directory = local_repository_directory @application_config = application_config @remote_repository_user = remote_repository_user - @update = update - @update_if_missing = update_if_missing @parser = Fig::Parser.new(application_config, check_include_versions) initialize_local_repository() reset_cached_data() @@ -158,14 +155,18 @@ FileUtils.rm_rf(temp_dir) return true end - def updating? - return @update || @update_if_missing + def update_unconditionally() + @update_condition = :unconditionally end + def update_if_missing() + @update_condition = :if_missing + end + private PACKAGE_FILE_IN_REPO = '.fig' def initialize_local_repository() @@ -288,13 +289,13 @@ def remote_repository_url() return @application_config.remote_repository_url() end def should_update?(descriptor) - return true if @update + return true if @update_condition == :unconditionally - return @update_if_missing && package_missing?(descriptor) + return @update_condition == :if_missing && package_missing?(descriptor) end def read_local_package(descriptor) directory = local_dir_for_package(descriptor) return read_package_from_directory(directory, descriptor) @@ -310,12 +311,11 @@ delete_local_package(descriptor) raise Fig::RepositoryError.new rescue StandardError => exception - Fig::Logging.debug exception - Fig::Logging.fatal 'Install failed, cleaning up.' + Fig::Logging.fatal %Q<Install failed, cleaning up: #{exception}> delete_local_package(descriptor) raise Fig::RepositoryError.new ensure @@ -491,10 +491,10 @@ %q<#>, %Q<# Time: #{now} (epoch: #{now.to_i()})>, %Q<# User: #{Sys::Admin.get_login()}>, %Q<# Host: #{Socket.gethostname()}>, %Q<# Args: "#{ARGV.join %q[", "]}">, - %Q<# Fig: v#{Fig::Command.get_version()}>, + %Q<# Fig: v#{Fig::VERSION}>, asset_summary, %Q<\n>, ].flatten() end