Class: Approvals::Namers::DefaultNamer

Inherits:
Object
  • Object
show all
Defined in:
lib/approvals/namers/default_namer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ DefaultNamer

Returns a new instance of DefaultNamer

Raises:

  • (ArgumentError)

6
7
8
9
# File 'lib/approvals/namers/default_namer.rb', line 6

def initialize(name = nil)
  raise ArgumentError.new("DefaultNamer: You must specify a name") if name.nil?
  @name = normalize(name)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


5
6
7
# File 'lib/approvals/namers/default_namer.rb', line 5

def name
  @name
end

Instance Method Details

#normalize(string) ⇒ Object


11
12
13
# File 'lib/approvals/namers/default_namer.rb', line 11

def normalize(string)
  string.strip.squeeze(" ").gsub(/[\ :-]+/, '_').gsub(/[\W]/, '').downcase
end

#output_dirObject


15
16
17
# File 'lib/approvals/namers/default_namer.rb', line 15

def output_dir
  @output_dir ||= Approvals.configuration.approvals_path
end