Sha256: 59a31f82d0b82514f0e897ce7f041ba586b1d1e7c7bf65605a4d9a1e0d82ae2f

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require 'bukin/version'
require 'bukin/cli'
require 'socket'

module Bukin
  class BukinError < StandardError; end
  class BukfileError < BukinError
    def self.not_symbol(group)
      BukfileError.new("The group name '#{group}' must be a Symbol")
    end

    def self.nested_groups
      BukfileError.new("Nesing 'group' statements is not supported")
    end
  end
  class InstallError < BukinError; end

  class VersionError < BukinError
    def initialize(name, bad_version, good_version)
      super("The resource #{name} (#{bad_version}) has an improper version. "\
            "It should be in the form of #{good_version}")
    end
  end

  class NoDownloadError < BukinError
    def initialize(name, version)
      super("The resource '#{name}' has no available downloads listed with "\
            "the version '#{version}'")
    end
  end

  class MissingProviderError < BukinError
    def initialize(resource)
      super("The #{resource[:type].to_s} '#{resource[:name]}' "\
            "is missing a provider")
    end
  end

  def self.get_json(url)
    JSON.parse(open(url).read)
  end

  def self.try_get_json(url)
    get_json(url)
  rescue OpenURI::HTTPError
    nil
  end

  def self.with_friendly_errors
    yield
  rescue BukinError => error
    abort error.message
  rescue SocketError => error
    abort "#{error.message}\nCheck that you have a stable connection and the service is online"
  rescue Errno::ENOENT => error
    abort error.message
  rescue Interrupt
    abort ''
  rescue Exception => error
    puts %Q(
      Oops, Bukin just crashed.  Please report this at http://bit.ly/bukin-issues
      Be sure to include as much information as possible such as your Bukfile,
      Bukfile.lock and the stack trace below.
    )
    raise error
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bukin-0.9.0 lib/bukin.rb