Class: Luna::Binary::Analysis

Inherits:
Object
  • Object
show all
Defined in:
lib/luna/binary/analysis.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAnalysis

Returns a new instance of Analysis.



18
19
20
# File 'lib/luna/binary/analysis.rb', line 18

def initialize
    validate!
end

Instance Attribute Details

#binary_pathObject

Returns the value of attribute binary_path.



15
16
17
# File 'lib/luna/binary/analysis.rb', line 15

def binary_path
  @binary_path
end

#need_uploadObject

Returns the value of attribute need_upload.



14
15
16
# File 'lib/luna/binary/analysis.rb', line 14

def need_upload
  @need_upload
end

Instance Method Details

#command(c) ⇒ Object



135
136
137
# File 'lib/luna/binary/analysis.rb', line 135

def command(c)
    return Common.instance.command(c)
end

#execUpload(items) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/luna/binary/analysis.rb', line 118

def execUpload(items)
    if need_upload != nil && need_upload == "upload"
        puts "-=-=-=-=-=-=-=-=-=-=-=-开始上传=-=-=-=-=-=-=-=-=-=-=-=-=-=".yellow
        items.each { |item|
            begin
                item.upload
            rescue => exception
                puts "异常上传过程中出现了:#{exception}".red
            else
                
            end
            
        }
        puts "-=-=-=-=-=-=-=-=-=-=-=-上传结束=-=-=-=-=-=-=-=-=-=-=-=-=-=".yellow
    end
end

#lockfileObject



29
30
31
# File 'lib/luna/binary/analysis.rb', line 29

def lockfile
    return Common.instance.lockfile
end

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/luna/binary/analysis.rb', line 33

def run
    failList = []
    successList = []
    
    dependenciesMapper = Common.instance.dependenciesMapper
    dedupingMapper = {}
    lockfile.pod_names.each { |item|
            moduleName = item.split('/').first
            if !moduleName["/"] && dedupingMapper[moduleName] == nil
                dedupingMapper[moduleName] = moduleName
                puts moduleName.yellow
                begin
                    uploader = Common.instance.upload_lockitem(dependenciesMapper, moduleName, binary_path)
                    if uploader != nil
                        successList << uploader
                    else
                        failList << "#{moduleName} 为空"
                    end
                    
                rescue => exception
                    failList << "#{moduleName} exception: #{exception}"
                ensure
                    
                end
            end
    }
    puts "-=-=-=-=-=-=-=-=-=-=-=-打印错误信息=-=-=-=-=-=-=-=-=-=-=-=-=-=".yellow if failList.length > 0
    puts "请查看下时候存在影响,如怀疑程序错误请联系作者".yellow if failList.length > 0
    failList.each{ |item|
        puts item.red
    }

    puts "-=-=-=-=-=-=-=-=-=-=-=-命令生成=-=-=-=-=-=-=-=-=-=-=-=-=-=".yellow
    hasInCocopodsSpec = []
    externalSpec = []
    local_spec = []
    failPrint = []

    successList.each { |item|
        if item.local_path
            local_spec << item
        elsif item.gitUrl.length > 0
            externalSpec << item
        else
            hasInCocopodsSpec << item
        end
    }
    hasInCocopodsSpec.each { |item|
        begin
            item.printPreUploadCommand
        rescue => exception
            failPrint << "#{item.podspecName} exception: #{exception}"
        ensure
            
        end   
    }
    externalSpec.each { |item|
        begin
            item.printPreUploadCommand
        rescue => exception
            failPrint << "#{item.podspecName} exception: #{exception}"
        ensure
            
        end 
    }

    local_spec.each { |item|
        begin
            item.printPreUploadCommand
        rescue => exception
            failPrint << "#{item.podspecName} exception: #{exception}"
        ensure
            
        end 
    }

    puts "-=-=-=-=-=-=-=-=-=-=-=-命令生成end=-=-=-=-=-=-=-=-=-=-=-=-=-=".yellow

    failPrint.each{ |item|
        puts item.red
    }

    execUpload(successList)
end

#validate!Object



22
23
24
25
26
27
# File 'lib/luna/binary/analysis.rb', line 22

def validate!
    arr = Dir.glob(Common.instance.podFilePath)
    if arr == nil 
        raise '当前路径下没有Podfile'
    end
end