Sha256: ca55e5c89521dc9d6acc955eff269c6c71ee6c67f077031f1c552cc7a520d2d1

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'ruby-progressbar'

module Hobo
  class << self

    attr_accessor :project_bar_cache

    def relaunch! env = {}
      Kernel.exec(env, 'hobo', '--skip-host-checks', *$HOBO_ARGV)
    end

    def in_project?
      !!Hobo.project_path
    end

    def progress file, increment, total, type, opts = {}
      opts = {
        :title => File.basename(file),
        :total => total,
        :format => "%t [%B] %p%% %e"
      }.merge(opts)

      # Hack to stop newline spam on windows
      opts[:length] = 79 if Gem::win_platform?

      @progress_bar_cache ||= {}

      if type == :reset
        type = :update
        @progress_bar_cache.delete file
      end

      @progress_bar_cache[file] ||= ProgressBar.create(opts)

      case type
        when :update
          @progress_bar_cache[file].progress += increment
        when :finished
          @progress_bar_cache[file].finish
      end

      return @progress_bar_cache[file]
    end

    def aws_credentials
      {
        :access_key_id => maybe(Hobo.user_config.aws.access_key_id) || ENV['AWS_ACCESS_KEY_ID'],
        :secret_access_key => maybe(Hobo.user_config.aws.secret_access_key) || ENV['AWS_SECRET_ACCESS_KEY']
      }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.9.pre.rc1 lib/hobo/util.rb
hobo-inviqa-0.0.9.pre.alpha lib/hobo/util.rb