diff --git a/.rubocop.yml b/.rubocop.yml index 8e5623a..419ea72 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -90,3 +90,320 @@ Style/Lambda: # Unclear why it's a good idea to give parameters semantically meaningless names Style/SingleLineBlockParams: Enabled: false + +Gemspec/AddRuntimeDependency: # new in 1.65 + Enabled: true +Gemspec/AttributeAssignment: # new in 1.77 + Enabled: true +Gemspec/DeprecatedAttributeAssignment: # new in 1.30 + Enabled: true +Gemspec/DevelopmentDependencies: # new in 1.44 + Enabled: true +Gemspec/RequireMFA: # new in 1.23 + Enabled: true +Layout/EmptyLinesAfterModuleInclusion: # new in 1.79 + Enabled: true +Layout/LineContinuationLeadingSpace: # new in 1.31 + Enabled: true +Layout/LineContinuationSpacing: # new in 1.31 + Enabled: true +Layout/LineEndStringConcatenationIndentation: # new in 1.18 + Enabled: true +Layout/SpaceBeforeBrackets: # new in 1.7 + Enabled: true +Lint/AmbiguousAssignment: # new in 1.7 + Enabled: true +Lint/AmbiguousOperatorPrecedence: # new in 1.21 + Enabled: true +Lint/AmbiguousRange: # new in 1.19 + Enabled: true +Lint/ArrayLiteralInRegexp: # new in 1.71 + Enabled: true +Lint/ConstantOverwrittenInRescue: # new in 1.31 + Enabled: true +Lint/ConstantReassignment: # new in 1.70 + Enabled: true +Lint/CopDirectiveSyntax: # new in 1.72 + Enabled: true +Lint/DataDefineOverride: # new in 1.85 + Enabled: true +Lint/DeprecatedConstants: # new in 1.8 + Enabled: true +Lint/DuplicateBranch: # new in 1.3 + Enabled: true +Lint/DuplicateMagicComment: # new in 1.37 + Enabled: true +Lint/DuplicateMatchPattern: # new in 1.50 + Enabled: true +Lint/DuplicateRegexpCharacterClassElement: # new in 1.1 + Enabled: true +Lint/DuplicateSetElement: # new in 1.67 + Enabled: true +Lint/EmptyBlock: # new in 1.1 + Enabled: true +Lint/EmptyClass: # new in 1.3 + Enabled: true +Lint/EmptyInPattern: # new in 1.16 + Enabled: true +Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69 + Enabled: true +Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21 + Enabled: true +Lint/ItWithoutArgumentsInBlock: # new in 1.59 + Enabled: true +Lint/LambdaWithoutLiteralBlock: # new in 1.8 + Enabled: true +Lint/LiteralAssignmentInCondition: # new in 1.58 + Enabled: true +Lint/MixedCaseRange: # new in 1.53 + Enabled: true +Lint/NoReturnInBeginEndBlocks: # new in 1.2 + Enabled: true +Lint/NonAtomicFileOperation: # new in 1.31 + Enabled: true +Lint/NumberedParameterAssignment: # new in 1.9 + Enabled: true +Lint/NumericOperationWithConstantResult: # new in 1.69 + Enabled: true +Lint/OrAssignmentToConstant: # new in 1.9 + Enabled: true +Lint/RedundantDirGlobSort: # new in 1.8 + Enabled: true +Lint/RedundantRegexpQuantifiers: # new in 1.53 + Enabled: true +Lint/RedundantTypeConversion: # new in 1.72 + Enabled: true +Lint/RefinementImportMethods: # new in 1.27 + Enabled: true +Lint/RequireRangeParentheses: # new in 1.32 + Enabled: true +Lint/RequireRelativeSelfPath: # new in 1.22 + Enabled: true +Lint/SharedMutableDefault: # new in 1.70 + Enabled: true +Lint/SuppressedExceptionInNumberConversion: # new in 1.72 + Enabled: true +Lint/SymbolConversion: # new in 1.9 + Enabled: true +Lint/ToEnumArguments: # new in 1.1 + Enabled: true +Lint/TripleQuotes: # new in 1.9 + Enabled: true +Lint/UnescapedBracketInRegexp: # new in 1.68 + Enabled: true +Lint/UnexpectedBlockArity: # new in 1.5 + Enabled: true +Lint/UnmodifiedReduceAccumulator: # new in 1.1 + Enabled: true +Lint/UnreachablePatternBranch: # new in 1.85 + Enabled: true +Lint/UselessConstantScoping: # new in 1.72 + Enabled: true +Lint/UselessDefaultValueArgument: # new in 1.76 + Enabled: true +Lint/UselessDefined: # new in 1.69 + Enabled: true +Lint/UselessNumericOperation: # new in 1.66 + Enabled: true +Lint/UselessOr: # new in 1.76 + Enabled: true +Lint/UselessRescue: # new in 1.43 + Enabled: true +Lint/UselessRuby2Keywords: # new in 1.23 + Enabled: true +Metrics/CollectionLiteralLength: # new in 1.47 + Enabled: true +Naming/BlockForwarding: # new in 1.24 + Enabled: true +Naming/PredicateMethod: # new in 1.76 + Enabled: true +Security/CompoundHash: # new in 1.28 + Enabled: true +Security/IoMethods: # new in 1.22 + Enabled: true +Style/AmbiguousEndlessMethodDefinition: # new in 1.68 + Enabled: true +Style/ArgumentsForwarding: # new in 1.1 + Enabled: true +Style/ArrayIntersect: # new in 1.40 + Enabled: true +Style/ArrayIntersectWithSingleElement: # new in 1.81 + Enabled: true +Style/BitwisePredicate: # new in 1.68 + Enabled: true +Style/CollectionCompact: # new in 1.2 + Enabled: true +Style/CollectionQuerying: # new in 1.77 + Enabled: true +Style/CombinableDefined: # new in 1.68 + Enabled: true +Style/ComparableBetween: # new in 1.74 + Enabled: true +Style/ComparableClamp: # new in 1.44 + Enabled: true +Style/ConcatArrayLiterals: # new in 1.41 + Enabled: true +Style/DataInheritance: # new in 1.49 + Enabled: true +Style/DigChain: # new in 1.69 + Enabled: true +Style/DirEmpty: # new in 1.48 + Enabled: true +Style/DocumentDynamicEvalDefinition: # new in 1.1 + Enabled: true +Style/EmptyClassDefinition: # new in 1.84 + Enabled: true +Style/EmptyHeredoc: # new in 1.32 + Enabled: true +Style/EmptyStringInsideInterpolation: # new in 1.76 + Enabled: true +Style/EndlessMethod: # new in 1.8 + Enabled: true +Style/EnvHome: # new in 1.29 + Enabled: true +Style/ExactRegexpMatch: # new in 1.51 + Enabled: true +Style/FetchEnvVar: # new in 1.28 + Enabled: true +Style/FileEmpty: # new in 1.48 + Enabled: true +Style/FileNull: # new in 1.69 + Enabled: true +Style/FileOpen: # new in 1.85 + Enabled: true +Style/FileRead: # new in 1.24 + Enabled: true +Style/FileTouch: # new in 1.69 + Enabled: true +Style/FileWrite: # new in 1.24 + Enabled: true +Style/HashConversion: # new in 1.10 + Enabled: true +Style/HashExcept: # new in 1.7 + Enabled: true +Style/HashFetchChain: # new in 1.75 + Enabled: true +Style/HashSlice: # new in 1.71 + Enabled: true +Style/IfWithBooleanLiteralBranches: # new in 1.9 + Enabled: true +Style/InPatternThen: # new in 1.16 + Enabled: true +Style/ItAssignment: # new in 1.70 + Enabled: true +Style/ItBlockParameter: # new in 1.75 + Enabled: true +Style/KeywordArgumentsMerging: # new in 1.68 + Enabled: true +Style/MagicCommentFormat: # new in 1.35 + Enabled: true +Style/MapCompactWithConditionalBlock: # new in 1.30 + Enabled: true +Style/MapIntoArray: # new in 1.63 + Enabled: true +Style/MapJoin: # new in 1.85 + Enabled: true +Style/MapToHash: # new in 1.24 + Enabled: true +Style/MapToSet: # new in 1.42 + Enabled: true +Style/MinMaxComparison: # new in 1.42 + Enabled: true +Style/ModuleMemberExistenceCheck: # new in 1.82 + Enabled: true +Style/MultilineInPatternThen: # new in 1.16 + Enabled: true +Style/NegatedIfElseCondition: # new in 1.2 + Enabled: true +Style/NegativeArrayIndex: # new in 1.84 + Enabled: true +Style/NestedFileDirname: # new in 1.26 + Enabled: true +Style/NilLambda: # new in 1.3 + Enabled: true +Style/NumberedParameters: # new in 1.22 + Enabled: true +Style/NumberedParametersLimit: # new in 1.22 + Enabled: true +Style/ObjectThen: # new in 1.28 + Enabled: true +Style/OneClassPerFile: # new in 1.85 + Enabled: true +Style/OpenStructUse: # new in 1.23 + Enabled: true +Style/OperatorMethodCall: # new in 1.37 + Enabled: true +Style/PartitionInsteadOfDoubleSelect: # new in 1.85 + Enabled: true +Style/PredicateWithKind: # new in 1.85 + Enabled: true +Style/QuotedSymbols: # new in 1.16 + Enabled: true +Style/ReduceToHash: # new in 1.85 + Enabled: true +Style/RedundantArgument: # new in 1.4 + Enabled: true +Style/RedundantArrayConstructor: # new in 1.52 + Enabled: true +Style/RedundantArrayFlatten: # new in 1.76 + Enabled: true +Style/RedundantConstantBase: # new in 1.40 + Enabled: true +Style/RedundantCurrentDirectoryInPath: # new in 1.53 + Enabled: true +Style/RedundantDoubleSplatHashBraces: # new in 1.41 + Enabled: true +Style/RedundantEach: # new in 1.38 + Enabled: true +Style/RedundantFilterChain: # new in 1.52 + Enabled: true +Style/RedundantFormat: # new in 1.72 + Enabled: true +Style/RedundantHeredocDelimiterQuotes: # new in 1.45 + Enabled: true +Style/RedundantInitialize: # new in 1.27 + Enabled: true +Style/RedundantInterpolationUnfreeze: # new in 1.66 + Enabled: true +Style/RedundantLineContinuation: # new in 1.49 + Enabled: true +Style/RedundantMinMaxBy: # new in 1.85 + Enabled: true +Style/RedundantRegexpArgument: # new in 1.53 + Enabled: true +Style/RedundantRegexpConstructor: # new in 1.52 + Enabled: true +Style/RedundantSelfAssignmentBranch: # new in 1.19 + Enabled: true +Style/RedundantStringEscape: # new in 1.37 + Enabled: true +Style/RedundantStructKeywordInit: # new in 1.85 + Enabled: true +Style/ReturnNilInPredicateMethodDefinition: # new in 1.53 + Enabled: true +Style/ReverseFind: # new in 1.84 + Enabled: true +Style/SafeNavigationChainLength: # new in 1.68 + Enabled: true +Style/SelectByKind: # new in 1.85 + Enabled: true +Style/SelectByRange: # new in 1.85 + Enabled: true +Style/SelectByRegexp: # new in 1.22 + Enabled: true +Style/SendWithLiteralMethodName: # new in 1.64 + Enabled: true +Style/SingleLineDoEndBlock: # new in 1.57 + Enabled: true +Style/StringChars: # new in 1.12 + Enabled: true +Style/SuperArguments: # new in 1.64 + Enabled: true +Style/SuperWithArgsParentheses: # new in 1.58 + Enabled: true +Style/SwapValues: # new in 1.1 + Enabled: true +Style/TallyMethod: # new in 1.85 + Enabled: true +Style/YAMLFileRead: # new in 1.53 + Enabled: true diff --git a/Dockerfile b/Dockerfile index 9ad3961..d8cb4eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ #FROM debian:bullseye-slim -FROM ruby:3.0 +FROM ruby:3.3-slim AS base USER root RUN apt-get update @@ -10,13 +10,34 @@ RUN groupadd -g 40054 alma && \ mkdir -p /opt/app && \ chown -R alma:alma /opt/app -# Run everything else as the alma user WORKDIR /opt/app -COPY --chown=alma Gemfile* ./ -RUN bundle install --system -COPY --chown=alma . . +FROM base AS development +USER root + +# Install system packages needed to build gems with C extensions. +RUN apt-get install -y --no-install-recommends \ + g++ \ + git \ + make + +USER alma + +RUN gem install bundler --version 4.0.9 +COPY --chown=alma:alma Gemfile* ./ +RUN bundle install +COPY --chown=alma:alma . . + +FROM base AS production + +# Copy the built codebase from the dev stage +COPY --from=development --chown=alma /opt/app /opt/app +COPY --from=development --chown=alma /usr/local/bundle /usr/local/bundle + +# Ensure the bundle is installed and the Gemfile.lock is synced. +RUN bundle config set frozen 'true' +RUN bundle install --local USER alma ENTRYPOINT ["/opt/app/bin/gobi"] #CMD ["help"] diff --git a/Gemfile b/Gemfile index 5e54e5a..43b8d2d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,5 @@ source 'https://rubygems.org' -gem 'aruba' gem 'date' gem 'getoptlong' gem 'mail' @@ -9,6 +8,6 @@ gem 'nokogiri' gem 'rake' gem 'rspec' gem 'rspec_junit_formatter' -gem 'rubocop', '~> 1.26.0', require: false +gem 'rubocop', '~> 1.85.0', require: false gem 'rubocop-checkstyle_formatter', require: false gem 'thor', '~> 1.1' diff --git a/Gemfile.lock b/Gemfile.lock index f2011db..046cca9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,74 +1,45 @@ GEM remote: https://rubygems.org/ specs: - aruba (2.0.0) - bundler (>= 1.17, < 3.0) - childprocess (>= 2.0, < 5.0) - contracts (>= 0.16.0, < 0.18.0) - cucumber (>= 4.0, < 8.0) - rspec-expectations (~> 3.4) - thor (~> 1.0) ast (2.4.3) - builder (3.2.4) - childprocess (4.1.0) - contracts (0.17) - cucumber (7.1.0) - builder (~> 3.2, >= 3.2.4) - cucumber-core (~> 10.1, >= 10.1.0) - cucumber-create-meta (~> 6.0, >= 6.0.1) - cucumber-cucumber-expressions (~> 14.0, >= 14.0.0) - cucumber-gherkin (~> 22.0, >= 22.0.0) - cucumber-html-formatter (~> 17.0, >= 17.0.0) - cucumber-messages (~> 17.1, >= 17.1.1) - cucumber-wire (~> 6.2, >= 6.2.0) - diff-lcs (~> 1.4, >= 1.4.4) - mime-types (~> 3.3, >= 3.3.1) - multi_test (~> 0.1, >= 0.1.2) - sys-uname (~> 1.2, >= 1.2.2) - cucumber-core (10.1.1) - cucumber-gherkin (~> 22.0, >= 22.0.0) - cucumber-messages (~> 17.1, >= 17.1.1) - cucumber-tag-expressions (~> 4.1, >= 4.1.0) - cucumber-create-meta (6.0.4) - cucumber-messages (~> 17.1, >= 17.1.1) - sys-uname (~> 1.2, >= 1.2.2) - cucumber-cucumber-expressions (14.0.0) - cucumber-gherkin (22.0.0) - cucumber-messages (~> 17.1, >= 17.1.1) - cucumber-html-formatter (17.0.0) - cucumber-messages (~> 17.1, >= 17.1.0) - cucumber-messages (17.1.1) - cucumber-tag-expressions (4.1.0) - cucumber-wire (6.2.1) - cucumber-core (~> 10.1, >= 10.1.0) - cucumber-cucumber-expressions (~> 14.0, >= 14.0.0) + bigdecimal (4.1.2) date (3.2.2) diff-lcs (1.5.0) - ffi (1.15.5) getoptlong (0.1.1) + hana (1.3.7) + json (2.20.0) + json_schemer (2.5.0) + bigdecimal + hana (~> 1.3) + regexp_parser (~> 2.0) + simpleidn (~> 0.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) mail (2.7.1) mini_mime (>= 0.1.1) marc (1.1.1) rexml scrub_rb (>= 1.0.1, < 2) unf - mime-types (3.4.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) + mcp (0.21.0) + json_schemer (>= 2.4) mini_mime (1.1.2) - multi_test (0.1.2) - nokogiri (1.13.3-x86_64-linux) + nokogiri (1.19.4-aarch64-linux-gnu) racc (~> 1.4) - parallel (1.27.0) - parser (3.3.10.0) + nokogiri (1.19.4-arm64-darwin) + racc (~> 1.4) + nokogiri (1.19.4-x86_64-linux-gnu) + racc (~> 1.4) + parallel (1.28.0) + parser (3.3.11.1) ast (~> 2.4.1) racc - prism (1.6.0) - racc (1.6.0) + prism (1.9.0) + racc (1.8.1) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.11.3) - rexml (3.2.5) + regexp_parser (2.12.0) + rexml (3.4.4) rspec (3.11.0) rspec-core (~> 3.11.0) rspec-expectations (~> 3.11.0) @@ -84,36 +55,40 @@ GEM rspec-support (3.11.0) rspec_junit_formatter (0.5.1) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.26.1) + rubocop (1.85.1) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + mcp (~> 0.6) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.16.0, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.48.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.1) parser (>= 3.3.7.2) - prism (~> 1.4) + prism (~> 1.7) rubocop-checkstyle_formatter (0.5.0) rubocop (>= 1.14.0) ruby-progressbar (1.13.0) scrub_rb (1.0.1) - sys-uname (1.2.2) - ffi (~> 1.1) - thor (1.2.1) + simpleidn (0.2.3) + thor (1.5.0) unf (0.1.4) unf_ext unf_ext (0.0.8) - unicode-display_width (2.6.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) PLATFORMS aarch64-linux + arm64-darwin-24 x86_64-linux DEPENDENCIES - aruba date getoptlong mail @@ -122,9 +97,9 @@ DEPENDENCIES rake rspec rspec_junit_formatter - rubocop (~> 1.26.0) + rubocop (~> 1.85.0) rubocop-checkstyle_formatter thor (~> 1.1) BUNDLED WITH - 2.2.33 + 4.0.9 diff --git a/docker-compose.yml b/docker-compose.yml index 7516827..f8f4926 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,6 @@ services: app: build: . command: watch --interval 600 - init: yes + init: true volumes: - ./:/opt/app:rw - -version: "3.8" diff --git a/lib/gobi.rb b/lib/gobi.rb index bb3df1b..aaa19a5 100644 --- a/lib/gobi.rb +++ b/lib/gobi.rb @@ -26,7 +26,7 @@ def self.set_dirs(directory = nil, outdir = nil, processed = nil) def self.watch!(directory = nil, outdir = nil, processed = nil, interval: 120) set_dirs(directory, outdir, processed) raise ArgumentError, "Watch directory '#{@input_dir}' is not a directory or symlink to a directory" \ - unless File.directory?(@input_dir) || \ + unless File.directory?(@input_dir) || (File.symlink?(@input_dir) && File.directory?(File.readlink(@input_dir))) raise ArgumentError, 'interval must be a positive integer' \ @@ -114,7 +114,7 @@ def self.get_output_filename(provider, fname) def self.new_file?(provider, fname) file = get_output_filename(provider, fname) outputfile = "#{@out_dir}/#{File.basename(file)}" - return true unless File.exist?(outputfile) + true unless File.exist?(outputfile) end # Rubocop warnings due to logging statements. disabling