Module: CodeManifest

Defined in:
lib/code_manifest.rb,
lib/code_manifest/rule.rb,
lib/code_manifest/version.rb,
lib/code_manifest/manifest.rb

Defined Under Namespace

Classes: Error, Manifest, Rule

Constant Summary collapse

MANIFEST_FILE =
'.code_manifest.yml'
KEY_PATTERN =
/[a-z_0-9]+/.freeze
VERSION =
'1.9.0'

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



15
16
17
# File 'lib/code_manifest.rb', line 15

def [](name)
  manifests[name.to_s]
end

.load_file(manifest_file) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/code_manifest.rb', line 24

def load_file(manifest_file)
  YAML.load_file(manifest_file, aliases: true).each_with_object({}) do |(name, patterns), collection|
    next unless name.match?(KEY_PATTERN)

    raise ArgumentError, "#{name} defined multiple times in #{manifest_file}" if collection.key?(name)

    collection[name] = Manifest.new(patterns.flatten)
  end
end

.root(start_path: Dir.pwd, reset: false) ⇒ Object



19
20
21
22
# File 'lib/code_manifest.rb', line 19

def root(start_path: Dir.pwd, reset: false)
  @root = nil if reset
  @root ||= find_root(start_path)
end