Class: Herb::Embedded::Config
- Inherits:
-
Object
- Object
- Herb::Embedded::Config
- Defined in:
- lib/herb/embedded/config.rb
Overview
Reads .herb.yml. The engine has no filesystem, so Ruby owns config
entirely. Uses the same nested schema as upstream @herb-tools/config
(only version, files.include/exclude, linter.fail_level, and
linter.rules.
Constant Summary collapse
- CONFIG_FILENAME =
".herb.yml"- DEFAULT_INCLUDE_GLOBS =
["**/*.html.erb", "**/*.herb"].freeze
- DEFAULT_EXCLUDE_GLOBS =
[].freeze
- DEFAULT_FAIL_LEVEL =
:error
Instance Attribute Summary collapse
-
#exclude_globs ⇒ Object
readonly
Returns the value of attribute exclude_globs.
-
#fail_level ⇒ Object
readonly
Returns the value of attribute fail_level.
-
#include_globs ⇒ Object
readonly
Returns the value of attribute include_globs.
-
#linter_version ⇒ Object
readonly
Returns the value of attribute linter_version.
Class Method Summary collapse
Instance Method Summary collapse
- #enabled_rule_names(all_rule_names) ⇒ Object
-
#initialize(data) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(data) ⇒ Config
Returns a new instance of Config.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/herb/embedded/config.rb', line 27 def initialize(data) files = data["files"] || {} linter = data["linter"] || {} @include_globs = files["include"] || DEFAULT_INCLUDE_GLOBS.dup @exclude_globs = files["exclude"] || DEFAULT_EXCLUDE_GLOBS.dup @fail_level = (linter["fail_level"] || DEFAULT_FAIL_LEVEL).to_sym @linter_version = data["version"] @disabled_rule_names = disabled_rule_names(linter["rules"]) end |
Instance Attribute Details
#exclude_globs ⇒ Object (readonly)
Returns the value of attribute exclude_globs.
18 19 20 |
# File 'lib/herb/embedded/config.rb', line 18 def exclude_globs @exclude_globs end |
#fail_level ⇒ Object (readonly)
Returns the value of attribute fail_level.
18 19 20 |
# File 'lib/herb/embedded/config.rb', line 18 def fail_level @fail_level end |
#include_globs ⇒ Object (readonly)
Returns the value of attribute include_globs.
18 19 20 |
# File 'lib/herb/embedded/config.rb', line 18 def include_globs @include_globs end |
#linter_version ⇒ Object (readonly)
Returns the value of attribute linter_version.
18 19 20 |
# File 'lib/herb/embedded/config.rb', line 18 def linter_version @linter_version end |
Class Method Details
.load(dir) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/herb/embedded/config.rb', line 20 def self.load(dir) path = File.join(dir, CONFIG_FILENAME) data = File.exist?(path) ? (YAML.load_file(path) || {}) : {} new(data) end |
Instance Method Details
#enabled_rule_names(all_rule_names) ⇒ Object
38 39 40 |
# File 'lib/herb/embedded/config.rb', line 38 def enabled_rule_names(all_rule_names) all_rule_names - @disabled_rule_names end |