Class: XcodePlugin

Inherits:
Bundle show all
Defined in:
lib/xcode_plugin.rb

Instance Attribute Summary

Attributes inherited from Bundle

#path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bundle

#bundle_identifier, #defaults_read, #defaults_write, #info_path, #initialize, #version

Constructor Details

This class inherits a constructor from Bundle

Class Method Details

.find_pluginsObject



4
5
6
7
8
9
10
11
12
13
14
15
# 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 "Couldn't find Plug-ins directory."
    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) ⇒ Object



17
18
19
20
# File 'lib/xcode_plugin.rb', line 17

def self.from_bundle(path)
  plugin = new(path)
  plugin.valid? ? plugin : nil
end

Instance Method Details

#add_uuid(uuid) ⇒ Object



34
35
36
37
38
39
# 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) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/xcode_plugin.rb', line 30

def has_uuid?(uuid)
  defaults_read('DVTPlugInCompatibilityUUIDs').include?(uuid)
end

#to_sObject



41
42
43
# File 'lib/xcode_plugin.rb', line 41

def to_s
  "#{path.split('/').last.sub(/\.xcplugin$/, '')} (#{version})"
end

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# 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