class Codeqa::Configuration

Constants

DOTFILE

Attributes

enabled_checker[R]
erb_engine[RW]

the default config file will setup all variables to some sane defaults

excludes[R]
rubocop_formatter_cops[R]

Public Instance Methods

default_config_path() click to toggle source
# File lib/codeqa/configuration.rb, line 22
def default_config_path
  Codeqa.root.join('config', 'default')
end
enabled_checker=(val) click to toggle source
# File lib/codeqa/configuration.rb, line 14
def enabled_checker=(val)
  @enabled_checker = Set[*val]
end
excluded?(file) click to toggle source

tests a given filepath if it should be excluded @param file File.join compatable filepath

@return [Boolean]

# File lib/codeqa/configuration.rb, line 43
def excluded?(file)
  file = File.join(Dir.pwd, file) unless file.start_with?('/')
  Codeqa.configuration.excludes.any?{ |pattern| match_path?(pattern, file) }
end
excludes=(val) click to toggle source
# File lib/codeqa/configuration.rb, line 10
def excludes=(val)
  @excludes = Set[*val]
end
home_config_path() click to toggle source
# File lib/codeqa/configuration.rb, line 26
def home_config_path
  home_dir_config = File.join(home_dir, DOTFILE)
  return home_dir_config if File.exist? home_dir_config
  false
end
project_config_path() click to toggle source
# File lib/codeqa/configuration.rb, line 32
def project_config_path
  project_root_config = File.join(project_root, DOTFILE)
  return project_root_config if File.exist? project_root_config
  false
end
rubocop_formatter_cops=(val) click to toggle source
# File lib/codeqa/configuration.rb, line 18
def rubocop_formatter_cops=(val)
  @rubocop_formatter_cops = Set[*val]
end

Private Instance Methods

git_root_till_home() click to toggle source

ascend from the current dir till I find a .git folder or reach home_dir

# File lib/codeqa/configuration.rb, line 61
def git_root_till_home
  Pathname.new(Dir.pwd).ascend do |dir_pathname|
    return dir_pathname if File.directory?("#{dir_pathname}/.git")
    return nil if dir_pathname.to_s == home_dir
  end
end
home_dir() click to toggle source
# File lib/codeqa/configuration.rb, line 52
def home_dir
  @home_dir ||= Dir.home
end
match_path?(pattern, path) click to toggle source
# File lib/codeqa/configuration.rb, line 68
def match_path?(pattern, path)
  case pattern
  when String
    basename = File.basename(path)
    pattern = File.join(project_root, pattern) unless pattern.start_with?('/')
    path == pattern || basename == pattern || File.fnmatch(pattern, path)
  when Regexp
    path =~ pattern
  end
end
project_root() click to toggle source
# File lib/codeqa/configuration.rb, line 56
def project_root
  @project_root ||= git_root_till_home
end