Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use theforeman-rubocop gemspec #18

Merged
merged 4 commits into from
Jul 31, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ jobs:
rubocop:
name: Rubocop
uses: theforeman/actions/.github/workflows/rubocop.yml@v0
with:
command: bundle exec rubocop --parallel --format github
25 changes: 4 additions & 21 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
require:
- rubocop-performance
inherit_gem:
theforeman-rubocop:
- strictest.yml

AllCops:
NewCops: enable

Layout/LineLength:
Enabled: false
TargetRubyVersion: 2.7

Metrics:
Enabled: false

Style/Documentation:
Enabled: false

Style/StringLiterals:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Gemspec/RequireMFA:
Enabled: false

Style/SymbolProc:
Enabled: false
7 changes: 2 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec

gem 'gettext', '>= 3.1.3', '< 4.0.0'
gem 'rake', '~> 13.1.0'

group :test do
gem 'rubocop', '~> 1.57.0'
gem 'rubocop-performance', '~> 1.5.2'
end

# load local gemfile
['Gemfile.local.rb', 'Gemfile.local'].map do |file_name|
local_gemfile = File.join(File.dirname(__FILE__), file_name)
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rake/testtask'
require 'bundler/gem_tasks'
require 'hammer_cli/i18n/find_task'
Expand Down
18 changes: 11 additions & 7 deletions hammer_cli_foreman_bootdisk.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('lib', __dir__)
require "hammer_cli_foreman_bootdisk/version"
require 'hammer_cli_foreman_bootdisk/version'

Gem::Specification.new do |s|
s.name = "hammer_cli_foreman_bootdisk"
s.name = 'hammer_cli_foreman_bootdisk'
s.version = HammerCLIForemanBootdisk.version.dup
s.platform = Gem::Platform::RUBY
s.authors = ["Dominic Cleal"]
s.email = "[email protected]"
s.homepage = "https://github.com/theforeman/hammer_cli_foreman_bootdisk"
s.license = "GPL-3.0+"
s.authors = ['Dominic Cleal']
s.email = '[email protected]'
s.homepage = 'https://github.com/theforeman/hammer_cli_foreman_bootdisk'
s.license = 'GPL-3.0+'

s.summary = 'Foreman boot disk commands for Hammer'
s.description = 'Foreman boot disk commands for Hammer CLI'

s.files = Dir['{config,lib,locale}/**/*', 'LICENSE', 'README*']
s.extra_rdoc_files = Dir['LICENSE', 'README*']
s.require_paths = ["lib"]
s.require_paths = ['lib']

s.add_dependency 'hammer_cli_foreman', '~> 3.10'
s.required_ruby_version = '>= 2.7', '< 4'

s.add_development_dependency 'theforeman-rubocop', '~> 0.1.0'
end
6 changes: 4 additions & 2 deletions lib/hammer_cli_foreman_bootdisk.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'hammer_cli_foreman'

module HammerCLIForemanBootdisk
Expand All @@ -9,8 +11,8 @@ def self.exception_handler_class
require 'hammer_cli_foreman_bootdisk/commands'
require 'hammer_cli_foreman_bootdisk/version'

HammerCLI::MainCommand.lazy_subcommand('bootdisk', _("Download boot disks"),
'HammerCLIForemanBootdisk::Bootdisk', 'hammer_cli_foreman_bootdisk/bootdisk')
HammerCLI::MainCommand.lazy_subcommand('bootdisk', _('Download boot disks'),
'HammerCLIForemanBootdisk::Bootdisk', 'hammer_cli_foreman_bootdisk/bootdisk')
rescue StandardError => e
handler = HammerCLIForeman::ExceptionHandler.new(context: {}, adapter: :base)
handler.handle_exception(e)
Expand Down
2 changes: 2 additions & 0 deletions lib/hammer_cli_foreman_bootdisk/bootdisk.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module HammerCLIForemanBootdisk
class Bootdisk < HammerCLIForeman::Command
resource :disks
Expand Down
10 changes: 7 additions & 3 deletions lib/hammer_cli_foreman_bootdisk/commands.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# frozen_string_literal: true

require 'tempfile'
require 'hammer_cli_foreman/commands'

module HammerCLIForemanBootdisk
class DownloadCommand < HammerCLIForeman::Command
option "--file", "PATH", _("File or device to write image to")
option "--force", :flag, _("Force writing to existing destination (device etc.)")
option "--sudo", :flag, _("Use sudo to write to device")
option '--file', 'PATH', _('File or device to write image to')
option '--force', :flag, _('Force writing to existing destination (device etc.)')
option '--sudo', :flag, _('Use sudo to write to device')

# rubocop:disable Layout/LineLength
def print_data(record)
server_filename = ::Regexp.last_match(1) if record.headers[:content_disposition].match?(/filename=["']?([^\s,;"']+)/)
file = options[HammerCLI.option_accessor_name('file')] || server_filename || 'bootdisk.iso'
Expand All @@ -26,6 +29,7 @@ def print_data(record)
end
print_message(success_message % file) if success_message
end
# rubocop:enable Layout/LineLength

def request_options
{ response: :raw }
Expand Down
2 changes: 2 additions & 0 deletions lib/hammer_cli_foreman_bootdisk/i18n.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'hammer_cli/i18n'

module HammerCLIForemanBootdisk
Expand Down
2 changes: 2 additions & 0 deletions lib/hammer_cli_foreman_bootdisk/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module HammerCLIForemanBootdisk
def self.version
@version ||= Gem::Version.new '0.4.1'
Expand Down