Class: Pod::X::Xcode::Open
- Inherits:
-
Object
- Object
- Pod::X::Xcode::Open
- Extended by:
- Executable
- Defined in:
- lib/cocoapods-x/extension/xcode/open.rb
Instance Method Summary collapse
-
#initialize ⇒ Open
constructor
A new instance of Open.
- #openxc!(url) ⇒ Object
- #run! ⇒ Object
Constructor Details
#initialize ⇒ Open
Returns a new instance of Open.
9 10 11 12 13 14 |
# File 'lib/cocoapods-x/extension/xcode/open.rb', line 9 def initialize @urls_w = Dir[File.join(Dir.pwd, "*.xcworkspace")] @urls_p = Dir[File.join(Dir.pwd, "*.xcodeproj")] @urls = @urls_w + @urls_p super end |
Instance Method Details
#openxc!(url) ⇒ Object
35 36 37 38 39 |
# File 'lib/cocoapods-x/extension/xcode/open.rb', line 35 def openxc! url UI.section('Pod::X '.magenta + "Opening #{File.basename(url)}.") do open! [url] end end |
#run! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cocoapods-x/extension/xcode/open.rb', line 16 def run! 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 '[!] Pod::X '.magenta + "#{exception}".red end else openxc!('/Applications/Xcode.app') end end |