Class: Composer::Verify::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/composer/verify/name.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Name

Returns a new instance of Name.



5
6
7
8
# File 'lib/composer/verify/name.rb', line 5

def initialize(args)
  @config = args[:config]
  @logger = @config.logger
end

Instance Method Details

#verify(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/composer/verify/name.rb', line 10

def verify(args)
  name = args[:name]

  if name.length < 3
    raise InvalidName.new "'#{name}' must be at least 3 characters"
  elsif ! (name =~ /^[0-9a-z\-]+$/)
    raise InvalidName.new "'#{name}' contains invalid character. Only lowercase letter, numbers and dashes."
  end

  @logger.info "Application name '#{name}' is valid."
end