Sha256: 8f79ac5270517841bda14bf8bad45e57bd5765c6166418ae7483930a6e2617ee

Contents?: true

Size: 902 Bytes

Versions: 12

Compression:

Stored size: 902 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,
          :git_hub_action,
          :netlify_ci,
          :local,
          :environment
        ]

        using ::Refinements::Strings

        def call
          message = "Invalid repository. Are you within a Git repository?"
          fail Errors::Base, message unless git.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

12 entries across 12 versions & 1 rubygems

Version Path
git-lint-6.2.1 lib/git/lint/commits/loader.rb
git-lint-6.2.0 lib/git/lint/commits/loader.rb
git-lint-6.1.0 lib/git/lint/commits/loader.rb
git-lint-6.0.2 lib/git/lint/commits/loader.rb
git-lint-6.0.1 lib/git/lint/commits/loader.rb
git-lint-6.0.0 lib/git/lint/commits/loader.rb
git-lint-5.3.0 lib/git/lint/commits/loader.rb
git-lint-5.2.0 lib/git/lint/commits/loader.rb
git-lint-5.1.2 lib/git/lint/commits/loader.rb
git-lint-5.1.1 lib/git/lint/commits/loader.rb
git-lint-5.1.0 lib/git/lint/commits/loader.rb
git-lint-5.0.0 lib/git/lint/commits/loader.rb