Module: GemEnforcer::Setup

Defined in:
lib/gem_enforcer/setup.rb,
lib/gem_enforcer/setup/behavior.rb,
lib/gem_enforcer/setup/validate.rb,
lib/gem_enforcer/setup/helper/retrieval.rb,
lib/gem_enforcer/setup/helper/on_failure.rb,
lib/gem_enforcer/setup/helper/version_enforcer.rb

Defined Under Namespace

Modules: Helper Classes: Behavior, Validate

Class Method Summary collapse

Class Method Details

.config_ymlObject



44
45
46
47
48
49
50
51
52
# File 'lib/gem_enforcer/setup.rb', line 44

def config_yml
  @read_config_yml ||= begin
    path = GemEnforcer.configuration.yml_config_path
    file = File.read(path)
    erb = ERB.new(file)

    YAML.load(erb.result)
  end
end

.errorsObject



25
26
27
# File 'lib/gem_enforcer/setup.rb', line 25

def errors
  @errors ||= []
end

.execute!Object



37
38
39
40
41
42
# File 'lib/gem_enforcer/setup.rb', line 37

def execute!
  if validate_yml!

  else
  end
end

.run_validations!Object



33
34
35
# File 'lib/gem_enforcer/setup.rb', line 33

def run_validations!
  validations.each { _1.run_validation! }
end

.validate_yml!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gem_enforcer/setup.rb', line 10

def validate_yml!
  @errors = config_yml["gems"].map do |name, |
    validator = Validate.new(name: name, **)
    validations << validator

    validator.error_status unless validator.valid_config?
  end.flatten.compact
  return true if errors.empty?

  log_level = config_yml.dig("invalid_config", "log_level") || "error"
  behavior = config_yml.dig("invalid_config", "behavior") || "exit"

  false
end

.validationsObject



29
30
31
# File 'lib/gem_enforcer/setup.rb', line 29

def validations
  @validations ||= []
end