Module: HoundConfig

Extended by:
HoundConfig
Included in:
HoundConfig
Defined in:
lib/hound/hound_config.rb

Constant Summary collapse

CONFIG_FILE_REPOSITORY =
"https://raw.githubusercontent.com/platanus/la-guia/master/"

Instance Method Summary collapse

Instance Method Details

#contentObject



6
7
8
# File 'lib/hound/hound_config.rb', line 6

def content
  @@content ||= load_content
end

#enabled_for?(linter_name) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
# File 'lib/hound/hound_config.rb', line 10

def enabled_for?(linter_name)
  # disabled if linter_name key does not exist in .hound.yml
  return false unless content.key?(linter_name)
  options = options_for(linter_name)
  # enabled if linter_name key exists and enabled key is not defined.
  return true unless options.keys.select { |k| k.downcase === "enabled" }.any?
  # enabled "enabled" or "Enabled" keys are true.
  !!options["enabled"] || !!options["Enabled"]
end

#options_for(linter_name) ⇒ Object



20
21
22
23
# File 'lib/hound/hound_config.rb', line 20

def options_for(linter_name)
  return content[linter_name] if content.respond_to?(:key?) && content.key?(linter_name)
  Hash.new
end

#rules_url_for(linter_name) ⇒ Object



25
26
27
28
# File 'lib/hound/hound_config.rb', line 25

def rules_url_for(linter_name)
  path_in_repo = options_for(linter_name)["config_file"].to_s
  HoundConfig::CONFIG_FILE_REPOSITORY + path_in_repo
end