Sha256: 5feeec7ca02ed2f335eea460460c954107944b3263b0d0f8492d7428808f5829

Contents?: true

Size: 916 Bytes

Versions: 8

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

require "refinements/strings"

module Git
  module Lint
    module Commits
      # Automatically detects and loads system.
      class Loader
        include Systems::Import[
          :circle_ci,
          :git_hub_action,
          :netlify_ci,
          :local,
          :repository,
          :environment
        ]

        using ::Refinements::Strings

        def call
          message = "Invalid repository. Are you within a Git repository?"
          fail Errors::Base, message unless repository.exist?

          load_system.call
        end

        private

        def load_system
          if key? "CIRCLECI" then circle_ci
          elsif key? "GITHUB_ACTIONS" then git_hub_action
          elsif key? "NETLIFY" then netlify_ci
          else local
          end
        end

        def key?(key) = environment.fetch(key, "false").to_bool
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git-lint-4.6.0 lib/git/lint/commits/loader.rb
git-lint-4.5.0 lib/git/lint/commits/loader.rb
git-lint-4.4.0 lib/git/lint/commits/loader.rb
git-lint-4.3.0 lib/git/lint/commits/loader.rb
git-lint-4.2.0 lib/git/lint/commits/loader.rb
git-lint-4.1.0 lib/git/lint/commits/loader.rb
git-lint-4.0.1 lib/git/lint/commits/loader.rb
git-lint-4.0.0 lib/git/lint/commits/loader.rb