Class: FunCi::Setup::ProjectConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_ci/setup/project_config.rb

Constant Summary collapse

REQUIRED_SCRIPTS =
%w[lint.sh build.sh fast.sh slow.sh].freeze

Instance Method Summary collapse

Constructor Details

#initialize(project_root) ⇒ ProjectConfig

Returns a new instance of ProjectConfig.



8
9
10
11
# File 'lib/fun_ci/setup/project_config.rb', line 8

def initialize(project_root)
  @project_root = project_root
  @fun_ci_dir = File.join(project_root, ".fun-ci")
end

Instance Method Details

#folder_exists?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/fun_ci/setup/project_config.rb', line 13

def folder_exists?
  Dir.exist?(@fun_ci_dir)
end

#script_path(stage) ⇒ Object



37
38
39
# File 'lib/fun_ci/setup/project_config.rb', line 37

def script_path(stage)
  File.join(@fun_ci_dir, "#{stage}.sh")
end

#validateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fun_ci/setup/project_config.rb', line 17

def validate
  errors = []

  unless folder_exists?
    errors << "No .fun-ci/ folder found in #{@project_root}"
    return errors
  end

  REQUIRED_SCRIPTS.each do |script|
    path = File.join(@fun_ci_dir, script)
    if !File.exist?(path)
      errors << ".fun-ci/#{script} is not found"
    elsif !File.executable?(path)
      errors << ".fun-ci/#{script} is not executable"
    end
  end

  errors
end