Class: Aigcm::StyleGuide

Inherits:
Object
  • Object
show all
Defined in:
lib/aigcm/style_guide.rb

Constant Summary collapse

LINE_MAX =
72
DEFAULT_GUIDE =
ERB.new(
  File.read(__FILE__)
  .split("__END__")
  .last
  .strip
).result

Class Method Summary collapse

Class Method Details

.load(dir, custom_path = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/aigcm/style_guide.rb', line 13

def self.load(dir, custom_path = nil)
  # If a custom path is provided, use it
  if custom_path
    return load_from_file(custom_path)
  end

  # Check for COMMITS.md in the repository root
  config_file = File.join(dir, "COMMITS.md")
  return load_from_file(config_file) if File.exist?(config_file)

  # Fallback to the default style guide
  DEFAULT_GUIDE
rescue StandardError => e
  puts "Warning: Error reading style guide: #{e.message}"
  DEFAULT_GUIDE
end