Module: Codestatus

Defined in:
lib/codestatus.rb,
lib/codestatus/cli.rb,
lib/codestatus/version.rb,
lib/codestatus/build_status.rb,
lib/codestatus/repositories/base.rb,
lib/codestatus/package_resolvers/base.rb,
lib/codestatus/package_resolvers/npm_resolver.rb,
lib/codestatus/repositories/github_repository.rb,
lib/codestatus/repositories/bitbucket_repository.rb,
lib/codestatus/package_resolvers/rubygems_resolver.rb,
lib/codestatus/package_resolvers/package_not_found_error.rb,
lib/codestatus/package_resolvers/repository_not_found_error.rb

Defined Under Namespace

Modules: PackageResolvers, Repositories Classes: BuildStatus, CLI

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.resolver(registry) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/codestatus.rb', line 32

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

.status(repository: nil, registry: nil, package: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/codestatus.rb', line 14

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