Sha256: 9a1c1e8ef73751406b57dd7e83df9b7ac827b6bd408b1a8a7fc2b0360d3a52ce

Contents?: true

Size: 474 Bytes

Versions: 6

Compression:

Stored size: 474 Bytes

Contents

module Pushfile
  module Util

    # Make sure the file name is valid
    def filename(name)
      # Replace space with underscore and downcase extension
      pre, dot, ext = name.rpartition('.')
      name = "#{pre.gsub(' ', '_')}.#{ext.downcase}"

      # Remove illegal characters
      # http://stackoverflow.com/questions/13517100/whats-the-difference-between-palpha-i-and-pl-i-in-ruby
      name = name.gsub(%r{[^\p{L}\-\_\.0-9]}, '')

      name
    end


  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pushfile-0.1.3 lib/pushfile/util.rb
pushfile-0.1.2 lib/pushfile/util.rb
pushfile-0.1.1 lib/pushfile/util.rb
pushfile-0.1.0 lib/pushfile/util.rb
pushfile-0.0.2 lib/pushfile/util.rb
pushfile-0.0.1 lib/pushfile/util.rb