class Pod::Command::Reopen

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/pod/command/reopen.rb, line 12
def initialize(argv)
  @workspace = find_workspace_in(Pathname.pwd)
  super
end

Public Instance Methods

run() click to toggle source
# File lib/pod/command/reopen.rb, line 22
      def run
        ascript = <<~STR.strip_heredoc
          tell application "Xcode"
                  set docs to (document of every window)
                  repeat with doc in docs
                      if class of doc is workspace document then
                          set docPath to path of doc
                          if docPath begins with "#{@workspace}" then
                              log docPath
                              close doc
                              return
                          end if
                      end if
                  end repeat
          end tell
        STR
        `osascript -e '#{ascript}'`
        `open "#{@workspace}"`
      end
validate!() click to toggle source
Calls superclass method
# File lib/pod/command/reopen.rb, line 17
def validate!
  super
  raise Informative, 'No xcode workspace found' unless @workspace
end

Private Instance Methods

find_workspace_in(path) click to toggle source
# File lib/pod/command/reopen.rb, line 44
def find_workspace_in(path)
  path.children.find { |fn| fn.extname == '.xcworkspace' } || find_workspace_in_example(path)
end
find_workspace_in_example(path) click to toggle source
# File lib/pod/command/reopen.rb, line 48
def find_workspace_in_example(path)
  tofind = path + 'Example'
  find_workspace_in(tofind)
end