Sha256: af9e3cd67e7c9a060d5c1801cdc3795dfb1924c101bca3b650524119f6dbe63b
Contents?: true
Size: 1.26 KB
Versions: 8
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true require "refinements/strings" module Git module Lint module Commits # Automatically detects and loads system. class Loader using ::Refinements::Strings SYSTEMS = { circle_ci: Systems::CircleCI.new, git_hub_action: Systems::GitHubAction.new, netlify_ci: Systems::NetlifyCI.new, local: Systems::Local.new }.freeze def initialize systems: SYSTEMS, container: Container @systems = systems @container = container end def call message = "Invalid repository. Are you within a Git repository?" fail Errors::Base, message unless repository.exist? load_system.call end private attr_reader :systems, :container def load_system if key? "CIRCLECI" then systems.fetch :circle_ci elsif key? "GITHUB_ACTIONS" then systems.fetch :git_hub_action elsif key? "NETLIFY" then systems.fetch :netlify_ci else systems.fetch :local end end def key?(key) = environment.fetch(key, "false").to_bool def repository = container[__method__] def environment = container[__method__] end end end end
Version data entries
8 entries across 8 versions & 1 rubygems