Class: Applyrics::Project_iOS
- Inherits:
-
Object
- Object
- Applyrics::Project_iOS
- Defined in:
- lib/applyrics/project_ios.rb
Instance Method Summary collapse
-
#detected_languages ⇒ Object
Return a list of detected languages in the project.
-
#initialize(path) ⇒ Project_iOS
constructor
A new instance of Project_iOS.
- #platform_project_settings(name) ⇒ Object
- #rebuild_files ⇒ Object
Constructor Details
#initialize(path) ⇒ Project_iOS
Returns a new instance of Project_iOS.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/applyrics/project_ios.rb', line 5 def initialize(path) if path.to_s.length == 0 path = Dir["./*.xcworkspace"].first end if path.to_s.length == 0 path = Dir["./*.xcodeproj"].first end @path = path @platform_settings = nil end |
Instance Method Details
#detected_languages ⇒ Object
Return a list of detected languages in the project
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/applyrics/project_ios.rb', line 17 def detected_languages folder = self.platform_project_settings("SOURCE_ROOT") base_language = I18nData.language_code(self.platform_project_settings("DEVELOPMENT_LANGUAGE")).downcase lang_folders = Dir.glob(File.join(folder, "**", "*.lproj")) @langs = {} lang_folders.each do |lang_folder| lang = /([A-Za-z\-]*?)\.lproj/.match(lang_folder)[1] lang = (lang == "Base" ? base_language : lang) @langs[lang] = lang_folder end end |
#platform_project_settings(name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/applyrics/project_ios.rb', line 29 def platform_project_settings(name) if @platform_settings.nil? cmd = ["set -o pipefail && xcrun xcodebuild -showBuildSettings"] cmd << "-project '#{@path}'" @platform_settings = Command.execute(cmd, false) end result = @platform_settings.split("\n").find { |c| c.split(" = ").first.strip == name } return result.split(" = ").last end |
#rebuild_files ⇒ Object
40 41 42 43 |
# File 'lib/applyrics/project_ios.rb', line 40 def rebuild_files folder = self.platform_project_settings("SOURCE_ROOT") Applyrics::GenStrings.run("#{folder}", "#{folder}") end |