module SublimeDSL::Tools

Constants

FORBIDDEN_CHARS_MAP

Replacement for characters forbidden in Windows file names.

FORBIDDEN_RE

Regexp matching characters forbidden in Windows file names.

Public Class Methods

filename(text) click to toggle source

Returns an OS-compatible file name for text.

Maps forbidden characters in Windows file names to something visually close (even on OSX and Linux):

<>:"/|?*\  =>  ˂˃˸ʺ∕¦ʔ✶ʅ
# File lib/sublime_dsl/tools.rb, line 60
def self.filename(text)
  text.gsub(FORBIDDEN_RE, FORBIDDEN_CHARS_MAP)
end
os() click to toggle source

Returns the running OS: :Windows, :OSX or :Linux.

# File lib/sublime_dsl/tools.rb, line 24
def self.os
  @os ||=
    case RbConfig::CONFIG['host_os']
    when /mswin|mingw/
      :Windows
    when /darwin/
      :OSX
    else
      :Linux
    end
end
zip(dir, archive) click to toggle source

Zips the content of dir into file archive.

# File lib/sublime_dsl/tools.rb, line 16
def self.zip(dir, archive)
  dir = dir + '/' unless dir.end_with?('/')
  Zip::File.open(archive, Zip::File::CREATE) do |zipfile|
    Dir["#{dir}**/*"].each { |f| zipfile.add(f.sub(dir, ''), f) }
  end
end