Sha256: d0561dbf5f59fa131e07b4a9b9054521aa013d5b81312f8435b8bba4d99a4e76

Contents?: true

Size: 1.98 KB

Versions: 3

Compression:

Stored size: 1.98 KB

Contents

# base module that has the statis methods that this gem is using
module CapistranoMulticonfigParallel
  ENV_KEY_JOB_ID = 'multi_cap_job_id'
  GITFLOW_TAG_STAGING_TASK = 'gitflow:tag_staging'
  GITFLOW_CALCULATE_TAG_TASK = 'gitflow:calculate_tag'
  GITFLOW_VERIFY_UPTODATE_TASK = 'gitflow:verify_up_to_date'

  class << self
    attr_accessor :logger, :original_args, :config, :config_keys
    include CapistranoMulticonfigParallel::Configuration
    include CapistranoMulticonfigParallel::GemHelper

    def configuration
      @config ||= fetch_configuration
      @config
    end

    def configuration_flags
      default_internal_config.each_with_object({}) do |array_item, hash|
        key = array_item[0].to_s
        value = get_prop_config(key, configuration)
        hash[key] = value.is_a?(Array) ? value.join(',') : value
        hash
      end.except('application_dependencies')
    end

    def enable_logging
      enable_file_logging
      set_celluloid_exception_handling
    end

    def job_id
      original_args_hash.fetch(CapistranoMulticonfigParallel::ENV_KEY_JOB_ID, nil)
    end

    def original_args_hash
      multi_fetch_argv((original_args || ARGV).dup)
    end

    def capistrano_version
      find_loaded_gem_property('capistrano', 'version')
    end

    def capistrano_version_2?
      capistrano_version.blank? ? false : verify_gem_version(capistrano_version, '3.0', operator: '<')
    end

  private

    def set_celluloid_exception_handling
      Celluloid.logger = logger
      Celluloid.task_class = defined?(Celluloid::TaskThread) ? Celluloid::TaskThread : Celluloid::Task::Threaded
      Celluloid.exception_handler do |ex|
        unless ex.is_a?(Interrupt)
          rescue_error(ex, 'stderr')
        end
      end
    end

    def enable_file_logging
      if configuration.multi_debug.to_s.downcase == 'true'
        enable_main_log_file
        self.logger = ::Logger.new(main_log_file)
      else
        self.logger ||= ::Logger.new(DevNull.new)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano_multiconfig_parallel-1.7.2 lib/capistrano_multiconfig_parallel/base.rb
capistrano_multiconfig_parallel-1.7.1 lib/capistrano_multiconfig_parallel/base.rb
capistrano_multiconfig_parallel-1.7.0 lib/capistrano_multiconfig_parallel/base.rb