Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 70 lines (59 sloc) 1.798 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
require 'rbconfig'
require 'fileutils'

module OS
  def OS.windows?
    (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
  end

  def OS.mac?
   (/darwin/ =~ RUBY_PLATFORM) != nil
  end

  def OS.unix?
    !OS.windows?
  end

  def OS.linux?
    OS.unix? and not OS.mac?
  end
end

@install_path = File.expand_path("~/Library/Application Support/Sublime Text 2/Packages/MavensMate")
@user_settings_path = File.expand_path("~/Library/Application Support/Sublime Text 2/Packages/User")

def install_package
  `git clone git://github.com/joeferraro/MavensMate-SublimeText.git '#{@install_path}'`
end

def install_user_settings
  #update_user_config if File.exist?("#{@user_settings_path}/mavensmate.sublime-settings"
  `cp '#{@install_path}/mavensmate.sublime-settings' '#{@user_settings_path}'` unless File.exist?("#{@user_settings_path}/mavensmate.sublime-settings")
end

# def update_user_config
# begin
# require 'json'
# json = File.read("#{@user_settings_path}/mavensmate.sublime-settings")
# existing_config = JSON.parse(json)
# json = File.read("#{@install_path}/mavensmate.sublime-settings")
# new_config = JSON.parse(json)
# new_config.each_pair do |k,v|
# next if existing_config.has_key?(k)
# existing_config[k] = v
# end
# updated_config = JSON.pretty_generate(existing_config)
# f = File.open("#{@user_settings_path}/mavensmate.sublime-settings","w")
# f.write(updated_config)
# f.close
# rescue Exception => e
# puts "error updating user config: " + e.message
# end
# end

def install
if OS.windows?
    #future functionality
elsif OS.mac?
    install_package
    install_user_settings
  elsif OS.linux?
#future functionality
end
end

def uninstall
`rm -rf '#{@install_path}'`
end

uninstall
install
Something went wrong with that request. Please try again.