class RunLoop::Strings

@!visibility private

A class for interacting with the strings tool

Attributes

path[R]

@!visibility private

Public Class Methods

new(path) click to toggle source

@!visibility private

# File lib/run_loop/strings.rb, line 11
    def initialize(path)
      @path = path

      if !Strings.valid_path?(path)
        raise ArgumentError,
%Q{File:

#{path}

must exist and not be a directory.
}
      end
    end

Private Class Methods

valid_path?(path) click to toggle source

@!visibility private

# File lib/run_loop/strings.rb, line 93
def self.valid_path?(path)
  File.exist?(path) && !File.directory?(path)
end

Public Instance Methods

inspect() click to toggle source

@!visibility private

# File lib/run_loop/strings.rb, line 31
def inspect
  to_s
end
server_id() click to toggle source

@!visibility private

@return [RunLoop::Version] A version instance or nil if the file

at path does not contain server version information.
# File lib/run_loop/strings.rb, line 55
def server_id
  regex = /LPSERVERID=[a-f0-9]{40}(-dirty)?/
  match = dump[regex, 0]

  if match
    match.split("=")[1]
  else
    nil
  end
end
server_version() click to toggle source

@!visibility private

@return [RunLoop::Version] A version instance or nil if the file

at path does not contain server version information.
# File lib/run_loop/strings.rb, line 39
def server_version
  regex = /CALABASH VERSION: (\d+\.\d+\.\d+(\.pre\d+)?)/
  match = dump[regex, 0]

  if match
    str = match.split(":")[1]
    RunLoop::Version.new(str)
  else
    nil
  end
end
to_s() click to toggle source

@!visibility private

# File lib/run_loop/strings.rb, line 26
def to_s
  "#<STRINGS: #{path}>"
end

Private Instance Methods

dump() click to toggle source

@!visibility private

# File lib/run_loop/strings.rb, line 69
    def dump
      args = ["strings", path]
      opts = { :log_cmd => true }

      hash = xcrun.run_command_in_context(args, opts)

      if hash[:exit_status] != 0
        raise RuntimeError,
%Q{Could not get strings info from file:

#{path}

#{args.join(" ")}

exited #{hash[:exit_status]} with the following output:

#{hash[:out]}
}
      end

      @dump = hash[:out]
    end
xcrun() click to toggle source

@!visibility private

# File lib/run_loop/strings.rb, line 98
def xcrun
  RunLoop::Xcrun.new
end