Class: Inch::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/inch/config.rb,
lib/inch/config/base.rb,
lib/inch/config/codebase.rb,
lib/inch/config/evaluation.rb

Overview

Stores the configuration for Inch

See Also:

  • config/defaultsconfig/defaults.rb

Defined Under Namespace

Classes: Base, Codebase, Evaluation

Class Method Summary collapse

Class Method Details

.base(&block) ⇒ Object


29
30
31
# File 'lib/inch/config.rb', line 29

def base(&block)
  Config::Base.new(:__base__).update(&block)
end

.codebase(language = :ruby) ⇒ Object


25
26
27
# File 'lib/inch/config.rb', line 25

def codebase(language = :ruby)
  instance(language).codebase
end

.for(language, path = nil) ⇒ Config::Base

Returns the Config object for a given language. Optionally parses a given path for inch.yml


37
38
39
40
41
# File 'lib/inch/config.rb', line 37

def for(language, path = nil)
  config = instance(language)
  config.codebase.update_via_yaml(path) if path
  config
end

.instance(language = :ruby) ⇒ Object


7
8
9
10
11
12
13
14
15
# File 'lib/inch/config.rb', line 7

def instance(language = :ruby)
  if (block = @blocks[language.to_s])
    config = Config::Base.new(language)
    config = config.update(&block)
    config
  else
    fail "Language not registered: #{language}"
  end
end

.namespace(language, submodule = nil) ⇒ Object


43
44
45
46
47
48
# File 'lib/inch/config.rb', line 43

def namespace(language, submodule = nil)
  name = language.to_s.split('_').map { |w| w.capitalize }.join
  const = ::Inch::Language.const_get(name)
  const = const.const_get(submodule) unless submodule.nil?
  const
end

.register(language, &block) ⇒ void

This method returns an undefined value.

Registers a configuration block for a given language.


20
21
22
23
# File 'lib/inch/config.rb', line 20

def register(language, &block)
  @blocks ||= {}
  @blocks[language.to_s] = block
end