Class: DyCI::InstallCommand
- Inherits:
-
Object
- Object
- DyCI::InstallCommand
- Defined in:
- lib/dyci/commands/install_command.rb
Class Method Summary collapse
- .backup_clang ⇒ Object
- .clang_location ⇒ Object
- .install_app_code ⇒ Object
- .install_as_plugin ⇒ Object
- .install_as_proxy ⇒ Object
- .install_helper ⇒ Object
- .install_xcode_plugin(plugin_name) ⇒ Object
- .plugins_dir ⇒ Object
- .replace_clang ⇒ Object
- .root_path ⇒ Object
- .run(args) ⇒ Object
- .usage ⇒ Object
Class Method Details
.backup_clang ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/dyci/commands/install_command.rb', line 51 def backup_clang clang_path = clang_location clang_backup_path = "#{clang_path}.backup" unless File.exists? clang_backup_path puts "Create clang backup" puts "#{clang_path} => #{clang_backup_path}" %x[ sudo cp #{clang_path} #{clang_backup_path} ] end end |
.clang_location ⇒ Object
75 76 77 78 |
# File 'lib/dyci/commands/install_command.rb', line 75 def clang_location developer_path = %x[ xcode-select -print-path ].chomp "#{developer_path}/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" end |
.install_app_code ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dyci/commands/install_command.rb', line 39 def install_app_code app_code_path = "#{File.expand_path '~'}/Library/Preferences/appCode10" if Dir.exists? app_code_path puts "AppCode preferences was not found at path '#{app_code_path}'" return end app_code_plugin_path = "#{app_code_path}/tools/" FileUtils.mkdir_p app_code_plugin_path app_code_plugin = "#{self.root_path}/pligins/AppCode/DyCIPlugin.xml" FileUtils.cp app_code_plugin, app_code_plugin_path end |
.install_as_plugin ⇒ Object
29 30 31 32 |
# File 'lib/dyci/commands/install_command.rb', line 29 def install_as_plugin self.install_helper self.install_xcode_plugin 'DyCIFakeClang' end |
.install_as_proxy ⇒ Object
34 35 36 37 |
# File 'lib/dyci/commands/install_command.rb', line 34 def install_as_proxy self.install_helper self.replace_clang end |
.install_helper ⇒ Object
25 26 27 |
# File 'lib/dyci/commands/install_command.rb', line 25 def install_helper self.install_xcode_plugin 'DyCIHelper' end |
.install_xcode_plugin(plugin_name) ⇒ Object
70 71 72 73 |
# File 'lib/dyci/commands/install_command.rb', line 70 def install_xcode_plugin plugin_name puts "Install #{plugin_name}" FileUtils.cp_r "#{self.root_path}/lib/plugins/#{plugin_name}.xcplugin", "#{self.plugins_dir}/" end |
.plugins_dir ⇒ Object
80 81 82 83 84 85 |
# File 'lib/dyci/commands/install_command.rb', line 80 def plugins_dir user_dir = File.("~") plugins_dir = "#{user_dir}/Library/Application Support/Developer/Shared/Xcode/Plug-ins" FileUtils.mkdir_p plugins_dir plugins_dir end |
.replace_clang ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/dyci/commands/install_command.rb', line 61 def replace_clang self.backup_clang proxy_path = Gem.bin_path 'dyci-compiler', 'dyci-compiler' clang_path = clang_location puts "Replace clang with proxy script" puts "#{proxy_path} => #{clang_path}" %x[ sudo cp #{proxy_path} #{clang_path} ] end |
.root_path ⇒ Object
87 88 89 |
# File 'lib/dyci/commands/install_command.rb', line 87 def root_path File. "../../../..", __FILE__ end |
.run(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/dyci/commands/install_command.rb', line 6 def run args if args.count.zero? usage exit 0 end args.each do | arg | command = "install_#{arg}".to_sym if self.respond_to? command self.send command else puts "Unknown command '#{command}'" end end end |
.usage ⇒ Object
21 22 23 |
# File 'lib/dyci/commands/install_command.rb', line 21 def usage puts "print usage" end |