Class: Project::ProjectManager
- Inherits:
-
Object
- Object
- Project::ProjectManager
- Defined in:
- lib/core_blur/reference/project.rb
Class Method Summary collapse
- .add_local_yaml_ignore ⇒ Object
- .add_yaml ⇒ Object
- .yaml_reference ⇒ Object
- .yaml_resource ⇒ Object
- .yaml_resource_file(file_path) ⇒ Object
Class Method Details
.add_local_yaml_ignore ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/core_blur/reference/project.rb', line 71 def self.add_local_yaml_ignore gitignore = ".gitignore" podfile_local_yaml = MyConstants::PODFILE_LOCAL_YAML contain = false gitignore_path= "#{Dir.pwd}/#{gitignore}" if File.exist?(gitignore_path) line_array = IO.readlines(gitignore_path) line_array.each do |line| line = line.gsub(" ", "").gsub("\n", "") if line == podfile_local_yaml contain = true break end end end unless contain File.open(gitignore_path, 'a+') { |file| file.write(podfile_local_yaml) } end end |
.add_yaml ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/core_blur/reference/project.rb', line 46 def self.add_yaml podfile_local_yaml = MyConstants::PODFILE_LOCAL_YAML podfile_module_yaml = MyConstants::PODFILE_MODULE_YAML podfile_third_party_yaml = MyConstants::PODFILE_THIRD_PARTY_YAML project_manager = XCProject::XcodeprojManager.share_manager pods_project = project_manager.get_pods_project did_add = [] pods_project.main_group.children.each {|child| did_add << child.display_name } unless did_add.include?(podfile_local_yaml) path = "#{Dir.pwd}/#{podfile_local_yaml}" pods_project.new_file(path) end unless did_add.include?(podfile_module_yaml) path = "#{Dir.pwd}/#{podfile_module_yaml}" pods_project.new_file(path) end unless did_add.include?(podfile_third_party_yaml) path = "#{Dir.pwd}/#{podfile_third_party_yaml}" pods_project.new_file(path) end pods_project.sort(:groups_position => :below) pods_project.save end |
.yaml_reference ⇒ Object
41 42 43 44 45 |
# File 'lib/core_blur/reference/project.rb', line 41 def self.yaml_reference puts "yaml文件引用添加" self.add_yaml self.add_local_yaml_ignore end |
.yaml_resource ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/core_blur/reference/project.rb', line 5 def self.yaml_resource puts "yaml资源文件添加" project_manager = XCProject::XcodeprojManager.share_manager targets = project_manager.get_app_targets targets.each do |target_name| target_supporting = "Pods-#{target_name}" resource_shell = "Pods-#{target_name}-resources.sh" resource_shell_path = "#{Dir.pwd}/Pods/Target Support Files/#{target_supporting}/#{resource_shell}" self.yaml_resource_file(resource_shell_path) end end |
.yaml_resource_file(file_path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/core_blur/reference/project.rb', line 16 def self.yaml_resource_file(file_path) unless File.exist?(file_path) return end content = "" line_array = IO.readlines(file_path) line_array.each_with_index { |line, index| content += line next_line = index<line_array.size ? line_array[index+1] : "" if line.include?("if [[ \"$CONFIGURATION\"") and next_line.include?("install_resource") if File.exist?(MyConstants::PODFILE_LOCAL_YAML) content += " install_resource \"${SRCROOT}/#{MyConstants::PODFILE_LOCAL_YAML}\"\n" end if File.exist?(MyConstants::PODFILE_MODULE_YAML) content += " install_resource \"${SRCROOT}/#{MyConstants::PODFILE_MODULE_YAML}\"\n" end if File.exist?(MyConstants::PODFILE_THIRD_PARTY_YAML) content += " install_resource \"${SRCROOT}/#{MyConstants::PODFILE_THIRD_PARTY_YAML}\"\n" end end } File.open(file_path, 'w') { |file| file.write(content) } end |