class Fame::XcodeProject

Handles the Xcode Project that is subject to localization

Constants

ACCEPTED_FILE_TYPES

All accepted Xcode project file types

Attributes

xcode_proj_path[RW]

Public Class Methods

new(xcode_proj_path) click to toggle source

Initializer @param xcode_proj_path A path to a .xcodeproj file whose contents should be localized.

# File lib/fame/xcode_project.rb, line 15
def initialize(xcode_proj_path)
  @xcode_proj_path = xcode_proj_path
  validate_xcodeproj_path!
end

Public Instance Methods

all_languages() click to toggle source

Determines all languages that are used in the current Xcode project. @return [Array<String>] An array of language codes, representing all languages used in the current Xcode project.

# File lib/fame/xcode_project.rb, line 24
def all_languages
  project_file = XCProjectFile.new(@xcode_proj_path)
  project_file.project["knownRegions"].select { |r| r != "Base" }
end

Private Instance Methods

validate_xcodeproj_path!() click to toggle source

Validates the xcodeproj path

# File lib/fame/xcode_project.rb, line 39
def validate_xcodeproj_path!
  raise "[XcodeProject] No project file provided" unless @xcode_proj_path
  raise "[XcodeProject] The provided file does not exist" unless File.exist? @xcode_proj_path
  raise "[XcodeProject] The provided file is not a valid Xcode project (#{ACCEPTED_FILE_TYPES.join(', ')})" unless ACCEPTED_FILE_TYPES.include? File.extname(@xcode_proj_path)
end