class PodsOrz::BinaryManager

Attributes

binary_builder[RW]
binary_repo[RW]
main_path[RW]
orzconfig_parse[RW]
podfile_io[RW]

Public Class Methods

new(main_path) click to toggle source
# File lib/podsorz/core/Binary/binary_manager.rb, line 9
def initialize(main_path)
        @main_path = main_path
        @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
        @podfile_io = PodsOrz::PodfileIO.new(main_path)

        @binary_repo = PodsOrz::BinaryRepo.new(main_path)
        @binary_repo.check_binary_repo_exist()

        @binary_builder = PodsOrz::BinaryBuilder.new(main_path, @podfile_io)
end

Public Instance Methods

check_podfile_exist_pods_list(pods_list) click to toggle source
# File lib/podsorz/core/Binary/binary_manager.rb, line 39
def check_podfile_exist_pods_list(pods_list)
        has_fault = false

        if pods_list.empty?
                Logger.error("check pods_list is empty")
                has_fault = true 
                return has_fault
        end

        fault_pods_list = []

        pods_list.each do |pod|
                total_pod_models = @podfile_io.total_pod_models

                find_result = false
                total_pod_models.each do |model|
                        if model.name.include? pod 
                                find_result = true
                                break
                        end
                end

                fault_pods_list << pod unless find_result
        end

        unless fault_pods_list.empty?
                Logger.error("project do not exist pod: \n")
                fault_pods_list.each do |pod|
                        puts("#{pod} \n")
                end
        end

        has_fault
end
package(package_list) click to toggle source

Package Command

# File lib/podsorz/core/Binary/binary_manager.rb, line 21
def package(package_list)

        #1.检测打包Pod是否项目中正在使用
        has_fault = check_podfile_exist_pods_list(package_list)
        exit() if has_fault

        #2 若源码Repo 未发布,则不进行二进制制作
        has_pod_repo = package_check_remote_exist_pod_repo(package_list)
        exit() unless has_pod_repo

        #3.检测打包Pod是否已经存在当前版本version的二进制静态库
        has_remote_binary = package_check_remote_exist_binary(package_list)
        exit() if has_remote_binary
        
        #4.开始进行源码打包工作
        start_build(package_list)
end
package_check_remote_exist_binary(pods_list) click to toggle source
# File lib/podsorz/core/Binary/binary_manager.rb, line 90
def package_check_remote_exist_binary(pods_list)
        result = false

        pods_list.each do |pod|
                pod_version = @podfile_io.get_podfile_pod_version(pod)

                unless pod_version.nil?
                        has_remote = @binary_repo.check_binary_pod_exist(pod, pod_version)

                        if has_remote
                                Logger.error("#{pod}:#{pod_version} exist remote binary static library, package action has been stop")
                                result = true
                                break
                        end
                end
        end

        result
end
package_check_remote_exist_pod_repo(pods_list) click to toggle source
# File lib/podsorz/core/Binary/binary_manager.rb, line 74
def package_check_remote_exist_pod_repo(pods_list)
        result = true

        pods_list.each do |pod|
                pod_version = @podfile_io.get_podfile_pod_version(pod)

                if pod_version.empty?
                        Logger.error("#{pod} donot have 'source code' publish version, package action has been stop")
                        result = false
                        break
                end
        end

        result
end
publish(pods_list) click to toggle source

Publish Command

# File lib/podsorz/core/Binary/binary_manager.rb, line 137
def publish(pods_list)
        is_publish_success = true

        if pods_list.empty?
                Logger.error("publish pods_list is empty")
                is_publish_success = false 
                exit() unless is_publish_success
        end

        pods_list.each {|pod|
                command = Thread.new do 
                        pod_version = @podfile_io.get_podfile_pod_version(pod)

                        dest_dir = @binary_builder.detect_version_directory(pod, pod_version)

                        each_result = @binary_repo.push_binary_remote(pod, dest_dir, pod_version, false)
                        unless each_result
                                is_publish_success = false 
                                Logger.error("#{pod}(#{pod_version}) publish failure!")
                        end
                        
                end

                command.join
        }
        
        exit() unless is_publish_success

        is_publish_success
end
show() click to toggle source

Show Command

# File lib/podsorz/core/Binary/binary_manager.rb, line 171
def show()
        
end
start_build(pods_list) click to toggle source
# File lib/podsorz/core/Binary/binary_manager.rb, line 110
def start_build(pods_list)
        is_build_success = true

        pods_list.each {|pod|
                Logger.separator
                Logger.default("【#{pod}】 start build binary...")
                Logger.separator

                command = Thread.new do 
                        each_result = @binary_builder.start_package_pod(pod)
                        unless each_result
                                is_build_success = false 
                                Logger.error("【#{pod}】package failure!")
                        else
                                Logger.highlight("【#{pod}】package success")
                        end
                end

                command.join
        }
        
        exit() unless is_build_success

        is_build_success
end