lib/codestatus.rb in codestatus-0.1.1 vs lib/codestatus.rb in codestatus-0.1.2
- old
+ new
@@ -1,23 +1,31 @@
require "codestatus/version"
require "codestatus/build_status"
require "codestatus/cli"
-require "codestatus/repository_resolver"
-require "codestatus/repository_resolver/user_defined_resolver"
-require "codestatus/repository_resolver/rubygems_resolver"
-require "codestatus/repository_resolver/npm_resolver"
-require "codestatus/package_repository"
-require "codestatus/package_repository/github_repository"
+require "codestatus/package_resolvers/base"
+require "codestatus/package_resolvers/rubygems_resolver"
+require "codestatus/package_resolvers/npm_resolver"
+require "codestatus/repositories/github_repository"
+require "codestatus/repositories/bitbucket_repository"
module Codestatus
- def self.status(registry:, package:)
- resolver = RepositoryResolver.new(registry: registry, package: package)
+ def self.status(repository: nil, registry: nil, package: nil)
+ if !repository && registry && package
+ repository = resolver(registry).resolve(package: package)
+ end
- package_repository = resolver.repository
-
- if package_repository
- package_repository.status
+ 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