This repository has been archived by the owner on Jul 11, 2019. It is now read-only.
/
install.rb
70 lines (59 loc) · 1.76 KB
/
install.rb
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