Sha256: 30338c11f15c073a3503dfebe60cf1c265e3515c0d47e37a1adf0e2785f985a2

Contents?: true

Size: 951 Bytes

Versions: 11

Compression:

Stored size: 951 Bytes

Contents

# frozen_string_literal: true

require "refinements/string"

module Git
  module Lint
    module Commits
      # Automatically detects and loads host.
      class Loader
        include Import[
          :git,
          :environment,
          circle_ci: "hosts.circle_ci",
          git_hub_action: "hosts.git_hub_action",
          netlify_ci: "hosts.git_hub_action",
          local: "hosts.local"
        ]

        using Refinements::String

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

          host.call
        end

        private

        def host
          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

11 entries across 11 versions & 1 rubygems

Version Path
git-lint-8.8.0 lib/git/lint/commits/loader.rb
git-lint-8.7.0 lib/git/lint/commits/loader.rb
git-lint-8.6.0 lib/git/lint/commits/loader.rb
git-lint-8.5.0 lib/git/lint/commits/loader.rb
git-lint-8.4.0 lib/git/lint/commits/loader.rb
git-lint-8.3.0 lib/git/lint/commits/loader.rb
git-lint-8.2.0 lib/git/lint/commits/loader.rb
git-lint-8.1.0 lib/git/lint/commits/loader.rb
git-lint-8.0.0 lib/git/lint/commits/loader.rb
git-lint-7.5.0 lib/git/lint/commits/loader.rb
git-lint-7.3.0 lib/git/lint/commits/loader.rb