Class: Pod::Command::X::XC::Open

Inherits:
Pod::Command::X::XC show all
Extended by:
Executable
Defined in:
lib/cocoapods-x/command/xcode/open.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Open

Returns a new instance of Open.



11
12
13
# File 'lib/cocoapods-x/command/xcode/open.rb', line 11

def initialize(argv)
    super
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cocoapods-x/command/xcode/open.rb', line 15

def run 
    urls_w = Dir[File.join(Dir.pwd, "*.xcworkspace")] 
    urls_p = Dir[File.join(Dir.pwd, "*.xcodeproj")]
    urls = urls_w + urls_p
    if urls_w.size == 1
        openxc(urls_w[0])
    elsif urls_p.size == 1
        openxc(urls_p[0])
    elsif urls.size > 0
        choices = urls.map { |l| File.basename(l) }
        begin
            index = UI.choose_from_array(choices, 'Which file do you want to open?')
            openxc(urls[index])
        rescue => exception
            UI.puts "[!] #{exception}".red
        end
    else
        openxc('/Applications/Xcode.app')
    end
end