Module: Avm::Git::AutoCommit::Rules

Defined in:
lib/avm/git/auto_commit/rules.rb,
lib/avm/git/auto_commit/rules/new.rb,
lib/avm/git/auto_commit/rules/nth.rb,
lib/avm/git/auto_commit/rules/base.rb,
lib/avm/git/auto_commit/rules/last.rb,
lib/avm/git/auto_commit/rules/manual.rb,
lib/avm/git/auto_commit/rules/unique.rb

Defined Under Namespace

Classes: Base, Last, Manual, New, Nth, Unique

Constant Summary collapse

RULES_CLASSES =
%w[last manual new nth unique]
.map { |key| ::Avm::Git::AutoCommit::Rules.const_get(key.camelcase) }

Class Method Summary collapse

Class Method Details

.parse(string) ⇒ Object



15
16
17
18
19
20
# File 'lib/avm/git/auto_commit/rules.rb', line 15

def parse(string)
  parts = string.split(':')

  klass = rule_class_by_key(parts.shift)
  klass.new(*parts)
end

.rule_class_by_key(key) ⇒ Object



22
23
24
25
26
# File 'lib/avm/git/auto_commit/rules.rb', line 22

def rule_class_by_key(key)
  RULES_CLASSES.find { |klass| klass.keys.include?(key) } ||
    raise("Rule not find with key \"#{key}\" (Available: " +
      RULES_CLASSES.flat_map(&:keys).join(', ') + ')')
end