Sha256: 84a43928465279dbec3d4e4d5d96c7a5c4e0574f2384d0ff1904b9eb3ba61e3b

Contents?: true

Size: 924 Bytes

Versions: 5

Compression:

Stored size: 924 Bytes

Contents

# encoding: utf-8
module LocalPac
  module Cli
    module Helper
      def pid(config = LocalPac.config)
        ::File.read(config.pid_file).chomp
      rescue Errno::ENOENT
        'Stale PID-file'
      end

      def set_log_level(requested_level)
        case requested_level.to_s.to_sym
        when :info
          LocalPac.ui_logger.level = ::Logger::INFO
        when :debug
          LocalPac.ui_logger.level = ::Logger::DEBUG
        else
          LocalPac.ui_logger.level = ::Logger::WARN
        end
      end

      def set_debug(request)
        if request
          LocalPac.ui_logger.info "Activating debug mode."

          require 'pry'
          require 'debugger'
        end
      rescue LoadError
        LocalPac.ui_logger.error "You tried to enable debug-mode, but either 'pry'- or 'debugger'-gem are not installed. Please fix that before using the debug-switch again."
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
local_pac-0.3.0 lib/local_pac/cli/helper.rb
local_pac-0.2.3 lib/local_pac/cli/helper.rb
local_pac-0.2.2 lib/local_pac/cli/helper.rb
local_pac-0.2.1 lib/local_pac/cli/helper.rb
local_pac-0.2.0 lib/local_pac/cli/helper.rb