Method: AssetsMapper::AssetsMapper.check_string

Defined in:
lib/assets_mapper_ext.rb

.check_string(input, allow_modification) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/assets_mapper_ext.rb', line 6

def check_string(input, allow_modification)
  if allow_modification
    remove_spacing(
      add_prefix(
        titleize(
          remove_non_alphanumeric input
        )
      )
    )
  elsif input.match('([0-9]+.+|[ \W]*)')
    error_msg = "Asset name: ".red + input.yellow + " violates Swift variable naming rules!!\n".red + \
    "Please consider to change it".red
    suggestion_msg = "If your want to allow #{"asset_mapper".green} to perform modification\n" \
    "You can set option --allow-modification"
    puts error_msg
    puts suggestion_msg
    abort
  else
    input
  end
end