class PodsOrz::PodfileIO

Attributes

http_host[RW]
main_path[RW]
remote_binary_directory[RW]
total_pod_models[RW]
total_sentences[RW]
usable_sentences[RW]

Public Class Methods

new(main_path) click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 11
def initialize(main_path)
        @main_path = main_path
        @http_host = "http://192.168.6.127:8899"
        @remote_binary_directory = "binary_pod"
        @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
        self.parse_podfile_orz
end

Public Instance Methods

filter_binary_pod_models() click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 19
def filter_binary_pod_models()
        filter_result_models = []

        filter_strings = ["sourceVendorPods", "subspecPods", "ztPods"]

        result_lines = []

        switch_flag = false
        filter_strings.each do |f_str|
                @total_sentences.each do |line|
                        if line.include? f_str
                                switch_flag = true
                        end

                        result_lines << line if switch_flag

                        if line.include? "正则匹配注释#{f_str}"
                                switch_flag = false
                                break
                        end
                end
        end

        result_lines.each do |line|
                podfile_model = PodsOrz::PodfileModel.validate_podfile_sentence_instance(line)
                filter_result_models << podfile_model unless podfile_model.nil?
        end

        filter_result_models
end
get_podfile_pod_branch(pod) click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 64
def get_podfile_pod_branch(pod)
        branch = ""
        @total_pod_models.each do |model|
                if model.name == pod
                        branch = model.branch
                        break
                end
        end
        
        branch = "" if branch.nil?

        branch
end
get_podfile_pod_version(pod) click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 50
def get_podfile_pod_version(pod)
        pod_version = ""
        @total_pod_models.each do |model|
                if model.name == pod
                        pod_version = model.version
                        break
                end
        end

        pod_version = "" if pod_version.nil?

        pod_version
end
load_config_binary_pod(pod_name_list) click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 317
def load_config_binary_pod(pod_name_list)
        pod_name_list.each do |podname|
                @total_pod_models.map { |model|
                        if model.name.start_with? podname.to_s
                                model.podspec = "#{@http_host}/#{remote_binary_directory}/#{model.name}/#{model.version}/#{model.name}.podspec" unless model.version.nil?
                        end
                }
        end
end
load_config_local_pod(pod_name_list) click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 105
def load_config_local_pod(pod_name_list)
        pod_name_list.each do |podname|
                @total_pod_models.map { |model|
                        if model.name.start_with? podname.to_s
                                model.path = "../#{@orzconfig_parse.file_devpods_name}/" + podname.to_s
                        end
                }
        end
end
output_local_binary_sentence(binary_pods_list) click to toggle source

binary output

# File lib/podsorz/core/PodFile/podfile_io.rb, line 272
def output_local_binary_sentence(binary_pods_list)
        return if binary_pods_list.empty?

        load_config_binary_pod(binary_pods_list)
        
        cocoas_podfile_path = File.expand_path("Podfile", @main_path)

        output_pod_list = @total_pod_models.reject { |model| 
                podspec = model.podspec
                podspec.to_s.empty?
        }

        File.open(cocoas_podfile_path, "w+") {|io|
                Logger.highlight("Podfile binary podspec completed!")

                @usable_sentences.map! do |sentence|
                        output_pod_list.each do |model|
                                filter_str = "\'#{model.name}\'"
                                if sentence.include? filter_str
                                        splite_list = sentence.split(filter_str)
                                        sentence = splite_list[0].to_s + filter_str + ", :podspec => " + "\'#{model.podspec.to_s}\'"
                                        if model.configurations
                                                sentence = sentence + ", :configurations => " + model.configurations.to_s
                                        end
                                        
                                        if model.modular_headers
                                                sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
                                        end

                                        if model.subspecs
                                                sentence = sentence + ", :subspecs => " + model.subspecs.to_s
                                        end

                                        sentence = sentence + "\n"
                                        puts(sentence)
                                end
                        end

                        io.write(sentence + "\n")

                        sentence
                end
        }
end
output_local_total_sentence() click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 176
def output_local_total_sentence
        cocoas_podfile_path = File.expand_path("Podfile", @main_path)

        output_pod_list = @total_pod_models.reject { |model| 
                path = model.path
                path.to_s.empty?
        }

        File.open(cocoas_podfile_path, "w+") {|io|
                Logger.highlight("Local Podfile edite completed!")

                @usable_sentences.each do |sentence|
                        output_pod_list.each do |model|
                                filter_str = "\'#{model.name}\'"
                                if sentence.include? filter_str
                                        splite_list = sentence.split(filter_str)
                                        sentence = splite_list[0].to_s + filter_str + ", :path => " + "\'#{model.path.to_s}\'"
                                        if model.configurations
                                                sentence = sentence + ", :configurations => " + model.configurations.to_s
                                        end
                                        
                                        if model.modular_headers
                                                sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
                                        end

                                        if model.subspecs
                                                sentence = sentence + ", :subspecs => " + model.subspecs.to_s
                                        end                                                      

                                        sentence = sentence + "\n"
                                        puts(sentence)
                                end
                        end

                        io.write(sentence + "\n")
                end
        }
end
output_orz_total_sentence(pod_name_list, branch_name) click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 116
def output_orz_total_sentence(pod_name_list, branch_name)
        pod_name_list.each do |podname|
                @total_pod_models.map { |model|
                        if model.name.start_with? podname.to_s
                                # 替换为config参数
                                model.git = "#{@orzconfig_parse.remote_url_sourcecode}/" + podname.to_s + ".git"
                                model.branch = branch_name.to_s
                        end
                }
        end

        cocoas_podfile_path = File.expand_path("Podfile_orz.rb", @main_path)

        output_pod_list = @total_pod_models.reject { |model|
                pod_name = model.name
                !pod_name_list.include? pod_name
        }

        File.open(cocoas_podfile_path, "w+") {|io|
                Logger.highlight("Remote Podfile_orz.rb edite completed!")

                @total_sentences.each do |sentence|
                        sentence_content = sentence.strip.chomp.to_s

                        is_sentence_comtent_empty = sentence_content.empty?
                        is_sentence_comtent_size_zero = sentence_content.size.zero?

                        unless is_sentence_comtent_empty || is_sentence_comtent_size_zero
                                unless sentence_content.start_with?("#")

                                        output_pod_list.each do |model|
                                                filter_str = "\'#{model.name}\'"
                                                if sentence.include? filter_str
                                                        splite_list = sentence.split(filter_str)
                                                        sentence = splite_list[0].to_s + filter_str + ", :git => " + "\'#{model.git}\'" + ", :branch => " + "\'#{model.branch}\'"
                                                        if model.configurations
                                                                sentence = sentence + ", :configurations => " + model.configurations.to_s
                                                        end
                                                        
                                                        if model.modular_headers
                                                                sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
                                                        end

                                                        if model.subspecs
                                                                sentence = sentence + ", :subspecs => " + model.subspecs.to_s
                                                        end

                                                        puts(sentence.chomp + "\n")
                                                end

                                        end
                                end
                        end
                        io.write(sentence.chomp + "\n")
                end
        }

end
output_publish_total_sentence(pod_hash) click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 215
def output_publish_total_sentence(pod_hash)
        pod_hash.each { |pod_name, version|
                @total_pod_models.map { |model|
                        if model.name.start_with? pod_name.to_s
                                model.version = version
                        end
                }
        }

        cocoas_podfile_path = File.expand_path("Podfile_orz.rb", @main_path)

        output_pod_list = @total_pod_models.reject { |model|
                pod_name = model.name
                !pod_hash.include? pod_name
        }

        File.open(cocoas_podfile_path, "w+") {|io|
                Logger.highlight("Remote Podfile_orz.rb edite completed!")

                @total_sentences.each do |sentence|
                        sentence_content = sentence.strip.chomp.to_s
                        
                        is_sentence_comtent_empty = sentence_content.empty?
                        is_sentence_comtent_size_zero = sentence_content.size.zero?

                        unless is_sentence_comtent_empty || is_sentence_comtent_size_zero
                                unless sentence_content.start_with?("#")

                                        output_pod_list.each do |model|
                                                filter_str = "\'#{model.name}\'"
                                                if sentence.include? filter_str
                                                        splite_list = sentence.split(filter_str)
                                                        sentence = splite_list[0].to_s + filter_str + ", \'#{model.version}\'"
                                                        if model.configurations
                                                                sentence = sentence + ", :configurations => " + model.configurations.to_s
                                                        end
                                                        if model.modular_headers
                                                                sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
                                                        end
                                                        if model.subspecs
                                                                sentence = sentence + ", :subspecs => " + model.subspecs.to_s
                                                        end

                                                        puts(sentence.chomp + "\n")
                                                end

                                        end
                                end
                        end

                        io.write(sentence.chomp + "\n")
                end
        }
end
parse_podfile_orz() click to toggle source
# File lib/podsorz/core/PodFile/podfile_io.rb, line 78
def parse_podfile_orz
        orz_file_path = File.expand_path("Podfile_orz.rb", @main_path)

        @total_sentences = []
        @usable_sentences = []
        @total_pod_models = []

        File.open(orz_file_path, "r") { |io|  
                @total_sentences = io.readlines

                @total_sentences.each { |orz_line|
                        orz_line_content = orz_line.strip.chomp
                        unless orz_line_content.empty? || orz_line_content.size.zero?
                                unless orz_line_content.start_with?("#")
                                        @usable_sentences << orz_line

                                        if orz_line_content.start_with?("pod ")
                                                podfile_model = PodsOrz::PodfileModel.new(orz_line_content)
                                                @total_pod_models << podfile_model
                                        end
                                end 
                        end
                }
        }
        
end