Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.1']
steps:
- name: checkout
uses: actions/checkout@v1
- uses: actions/setup-ruby@v1
with:
ruby-version: '2.x'
- name: report gemfile name
ruby-version: ${{ matrix.ruby-version }}
- name: report gemfile name ruby ${{ matrix.ruby-version }}
run: make gem
- name: test
run: make build test BUILD=local
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Rubocop

on: [pull_request]

jobs:
rubocop:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1


- name: Run rubocop
run: |
bundle install
bundle exec rubocop
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inherit_from: .rubocop_todo.yml
82 changes: 82 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-12-02 09:10:59 UTC using RuboCop version 1.39.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'docker_registry2.gemspec'

# Offense count: 5
Lint/UselessAssignment:
Exclude:
- 'lib/registry/registry.rb'
- 'test/test.rb'

# Offense count: 2
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/registry/registry.rb'

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 44

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 312

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 13

# Offense count: 6
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/MethodLength:
Max: 34

# Offense count: 1
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 14

# Offense count: 2
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'lib/registry/registry.rb'

# Offense count: 9
# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns.
# SupportedStyles: snake_case, camelCase
Naming/VariableName:
Exclude:
- 'lib/registry/registry.rb'

# Offense count: 3
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/docker_registry2.rb'
- 'lib/registry/blob.rb'
- 'lib/registry/registry.rb'

# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/registry/registry.rb'
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
9 changes: 5 additions & 4 deletions alpine_manifest_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require './lib/docker_registry2.rb'
# frozen_string_literal: true

require './lib/docker_registry2'

reg = DockerRegistry2.connect
man = reg.manifest 'library/alpine', 'latest'
puts "MANIFEST"
puts 'MANIFEST'
puts man
puts "HEADER"
puts 'HEADER'
puts man.headers

23 changes: 13 additions & 10 deletions docker_registry2.gemspec
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'registry/version'

Gem::Specification.new do |spec|
spec.name = 'docker_registry2'
spec.version = DockerRegistry2::VERSION
spec.authors = [
'Avi Deitcher https://github.com/deitch',
'Jonathan Hurter https://github.com/johnsudaar',
'Dmitry Fleytman https://github.com/dmitryfleytman',
'Grey Baker https://github.com/greysteil'
]
'Avi Deitcher https://github.com/deitch',
'Jonathan Hurter https://github.com/johnsudaar',
'Dmitry Fleytman https://github.com/dmitryfleytman',
'Grey Baker https://github.com/greysteil'
]
spec.summary = 'Docker v2 registry HTTP API client'
spec.description = 'Docker v2 registry HTTP API client with support for token authentication'
spec.homepage = 'https://github.com/deitch/docker_registry2'
spec.license = 'MIT'

spec.files = %w{README.md} + Dir.glob("*.gemspec") + Dir.glob("{lib}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
spec.files = %w[README.md] + Dir.glob('*.gemspec') + Dir.glob('{lib}/**/*', File::FNM_DOTMATCH).reject do |f|
File.directory?(f)
end
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

spec.add_development_dependency 'bundler'
Expand Down
7 changes: 4 additions & 3 deletions get-gem-name.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!ruby
# frozen_string_literal: true

require "rubygems"
require 'rubygems'

spec = Gem::Specification::load("docker_registry2.gemspec")
puts spec.name.to_s+'-'+spec.version.to_s+'.gem'
spec = Gem::Specification.load('docker_registry2.gemspec')
puts "#{spec.name}-#{spec.version}.gem"
19 changes: 10 additions & 9 deletions lib/docker_registry2.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
require File.dirname(__FILE__) + '/registry/version'
require File.dirname(__FILE__) + '/registry/registry'
require File.dirname(__FILE__) + '/registry/exceptions'
require File.dirname(__FILE__) + '/registry/manifest'
require File.dirname(__FILE__) + '/registry/blob'
# frozen_string_literal: true

require "#{File.dirname(__FILE__)}/registry/version"
require "#{File.dirname(__FILE__)}/registry/registry"
require "#{File.dirname(__FILE__)}/registry/exceptions"
require "#{File.dirname(__FILE__)}/registry/manifest"
require "#{File.dirname(__FILE__)}/registry/blob"

module DockerRegistry2
def self.connect(uri="https://registry.hub.docker.com",opts={})
@reg = DockerRegistry2::Registry.new(uri,opts)
def self.connect(uri = 'https://registry.hub.docker.com', opts = {})
@reg = DockerRegistry2::Registry.new(uri, opts)
end

def self.search(query = '')
Expand All @@ -18,7 +19,7 @@ def self.tags(repository)
@reg.tags(repository)
end

def self.manifest(repository,tag)
@reg.manifest(repository,tag)
def self.manifest(repository, tag)
@reg.manifest(repository, tag)
end
end
4 changes: 3 additions & 1 deletion lib/registry/blob.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

module DockerRegistry2
class Blob
attr_reader :body, :headers

def initialize(headers, body)
@headers = headers
@body = body
Expand Down
29 changes: 15 additions & 14 deletions lib/registry/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# frozen_string_literal: true

module DockerRegistry2
class Exception < RuntimeError

end
class RegistryAuthenticationException < Exception

class RegistryAuthenticationException < StandardError
end

class RegistryAuthorizationException < Exception
class RegistryAuthorizationException < StandardError
end

class RegistryUnknownException < Exception
class RegistryUnknownException < StandardError
end

class RegistrySSLException < Exception
class RegistrySSLException < StandardError
end

class RegistryVersionException < Exception
class RegistryVersionException < StandardError
end
class ReauthenticatedException < Exception

class ReauthenticatedException < StandardError
end
class UnknownRegistryException < Exception

class UnknownRegistryException < StandardError
end

class NotFound < Exception
class NotFound < StandardError
end

class InvalidMethod < Exception
class InvalidMethod < StandardError
end
end
end
6 changes: 2 additions & 4 deletions lib/registry/manifest.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module DockerRegistry2
# frozen_string_literal: true

module DockerRegistry2
class Manifest < Hash
attr_accessor :body, :headers
def initialize
super
end
end
end
Loading