Class: Souyuz::DetectValues
- Inherits:
-
Object
- Object
- Souyuz::DetectValues
- Defined in:
- lib/souyuz/detect_values.rb
Overview
This class detects all kinds of default values
Class Method Summary collapse
- .detect_assembly_name(doc_csproj) ⇒ Object
- .detect_info_plist ⇒ Object
- .detect_manifest(doc_csproj) ⇒ Object
- .detect_output_path(doc_csproj) ⇒ Object
- .detect_project ⇒ Object
-
.detect_solution ⇒ Object
Helper Methods.
-
.set_additional_default_values ⇒ Object
This is needed as these are more complex default values Returns the finished config object.
Class Method Details
.detect_assembly_name(doc_csproj) ⇒ Object
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/souyuz/detect_values.rb', line 107 def self.detect_assembly_name(doc_csproj) return if Souyuz.config[:assembly_name] if [ Platform::IOS, Platform::OSX ].include? Souyuz.config[:platform] Souyuz.config[:assembly_name] = doc_csproj.css('PropertyGroup > AssemblyName').text elsif Souyuz.config[:platform] == Platform::ANDROID doc = get_parser_handle Souyuz.config[:manifest_path] # explicitly for this call, no cache needed Souyuz.config[:assembly_name] = doc.xpath('string(//manifest/@package)') end end |
.detect_info_plist ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/souyuz/detect_values.rb', line 90 def self.detect_info_plist return if Souyuz.config[:plist_path] or Souyuz.config[:platform] != Platform::IOS itr = 0 query = '../Info.plist' begin files = Dir.glob(query) query = "*/#{query}" itr += 1 end until files.any? or itr > 1 plist_path = files.first # pick first file as solution UI.user_error! 'Not able to find Info.plist automatically, try to specify it via `plist_path` parameter.' unless plist_path Souyuz.config[:plist_path] = abs_project_path plist_path end |
.detect_manifest(doc_csproj) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/souyuz/detect_values.rb', line 83 def self.detect_manifest(doc_csproj) return if Souyuz.config[:manifest_path] or Souyuz.config[:platform] != Platform::ANDROID doc_node = doc_csproj.css('PropertyGroup > AndroidManifest') Souyuz.config[:manifest_path] = abs_project_path doc_node.text end |
.detect_output_path(doc_csproj) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/souyuz/detect_values.rb', line 70 def self.detect_output_path(doc_csproj) return if Souyuz.config[:output_path] configuration = Souyuz.config[:build_configuration] platform = Souyuz.config[:build_platform] doc_node = doc_csproj.xpath("/*[local-name()='Project']/*[local-name()='PropertyGroup'][translate(@*[local-name() = 'Condition'],'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = \" '$(configuration)|$(platform)' == '#{configuration.downcase}|#{platform.downcase}' \"]/*[local-name()='OutputPath']/text()") output_path = doc_node.text UI.user_error! 'Not able to find output path automatically, try to specify it via `output_path` parameter.' unless output_path Souyuz.config[:output_path] = abs_project_path output_path end |
.detect_project ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/souyuz/detect_values.rb', line 53 def self.detect_project return if Souyuz.config[:project_path] path = Souyuz.config[:solution_path] projects = Msbuild::SolutionParser.parse(path) .get_platform Souyuz.config[:platform] UI.user_error! "Not able to find any project in solution, that matches the platform `#{Souyuz.config[:platform]}`." unless projects.any? project = projects.first csproj = fix_path_relative project.project_path # get path relative to project root UI.user_error! 'Not able to find project file automatically, try to specify it via `project_path` parameter.' unless csproj Souyuz.config[:project_name] = project.project_name Souyuz.config[:project_path] = abs_path csproj end |
.detect_solution ⇒ Object
Helper Methods
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/souyuz/detect_values.rb', line 36 def self.detect_solution return if Souyuz.config[:solution_path] itr = 0 query = '*.sln' begin files = Dir.glob(query) query = "../#{query}" itr += 1 end until files.any? or itr > 3 sln = files.first # pick first file as solution UI.user_error! 'Not able to find solution file automatically, try to specify it via `solution_path` parameter.' unless sln Souyuz.config[:solution_path] = abs_path sln end |
.set_additional_default_values ⇒ Object
This is needed as these are more complex default values Returns the finished config object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/souyuz/detect_values.rb', line 9 def self.set_additional_default_values config = Souyuz.config # TODO detect_platform automatically for :platform config # set correct implicit build platform for android if config[:platform] == Platform::ANDROID config[:build_platform] = 'AnyCPU' end # Detect the project Souyuz.project = Msbuild::Project.new(config) detect_solution detect_project # we can only do that *after* we detected the solution doc_csproj = get_parser_handle config[:project_path] detect_output_path doc_csproj detect_manifest doc_csproj detect_info_plist detect_assembly_name doc_csproj # we can only do that for android *after* we detected the android manitfest return config end |