Sha256: 34f158fd596d372e8db0a307a3559d68b85c41416444375891f613bc0407da46

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require "codestatus/version"
require "codestatus/build_status"
require "codestatus/cli"
require "codestatus/package_resolvers/base"
require "codestatus/package_resolvers/rubygems_resolver"
require "codestatus/package_resolvers/npm_resolver"
require "codestatus/package_resolvers/repository_not_found_error"
require "codestatus/package_resolvers/package_not_found_error"
require "codestatus/repositories/base"
require "codestatus/repositories/github_repository"
require "codestatus/repositories/bitbucket_repository"

module Codestatus
  def self.status(repository: nil, registry: nil, package: nil)
    if !repository && registry && package
      begin
        repository = resolver(registry).resolve!(package)
      rescue PackageResolvers::PackageNotFoundError
        abort "#{package}: Package not found"
      rescue PackageResolvers::RepositoryNotFoundError
        abort "#{package}: Repository not found"
      end
    end

    if repository
      repository.status
    else
      BuildStatus.new(sha: nil, status: nil)
    end
  end

  def self.resolver(registry)
    case registry
    when /rubygems/
      PackageResolvers::RubygemsResolver
    when /npm/
      PackageResolvers::NpmResolver
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codestatus-0.1.3 lib/codestatus.rb