class XcodePlugin

Public Class Methods

find_plugins() click to toggle source
# File lib/xcode_plugin.rb, line 4
def self.find_plugins
  plugins_path = "#{Dir.home}/Library/Application Support/Developer/Shared/Xcode/Plug-ins/"

  unless Dir.exist?(plugins_path)
    puts "未找到 Plug-ins 目录"
    return []
  end

  Dir.entries(plugins_path).collect do |plugin_path|
    XcodePlugin.from_bundle("#{plugins_path}#{plugin_path}")
  end.compact.keep_if(&:valid?)
end
from_bundle(path) click to toggle source
# File lib/xcode_plugin.rb, line 17
def self.from_bundle(path)
  plugin = new(path)
  plugin.valid? ? plugin : nil
end

Public Instance Methods

add_uuid(uuid) click to toggle source
# File lib/xcode_plugin.rb, line 34
def add_uuid(uuid)
  return false if has_uuid?(uuid)

  defaults_write('DVTPlugInCompatibilityUUIDs', '-array-add', uuid)
  true
end
has_uuid?(uuid) click to toggle source
# File lib/xcode_plugin.rb, line 30
def has_uuid?(uuid)
  defaults_read('DVTPlugInCompatibilityUUIDs').include?(uuid)
end
to_s() click to toggle source
# File lib/xcode_plugin.rb, line 41
def to_s
  "#{path.split('/').last.sub(/\.xcplugin$/, '')} (#{version})"
end
valid?() click to toggle source
# File lib/xcode_plugin.rb, line 22
def valid?
  not_hidden = !path.split('/').last.start_with?('.')
  is_plugin = path.end_with?('.xcplugin')
  has_info = File.exist?(info_path)

  not_hidden && is_plugin && has_info
end