Sha256: 8808a882a7906c0c200f80ed151add374ee89f16042035090554ed74a0bd736a

Contents?: true

Size: 385 Bytes

Versions: 1

Compression:

Stored size: 385 Bytes

Contents

class File
  # http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_276
  SAFE_CHARS = /[^a-zA-Z0-9._\-]/

  def self.safe_name(name)
    name.gsub('&', 'and'). # prittify & to and
      gsub(/\s/, '-'). # replace spaces with dashes
      gsub(SAFE_CHARS, '-'). # replace with portable characters
      gsub(/\-+/, '-') # limit - character to once
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby_core_extensions-0.0.1 lib/ruby_core_extensions/file.rb