Class: Luna::Binary::Refresh

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#binary_pathObject

Returns the value of attribute binary_path.



8
9
10
# File 'lib/luna/binary/refresh.rb', line 8

def binary_path
  @binary_path
end

#request_result_hashObject

Returns the value of attribute request_result_hash.



9
10
11
# File 'lib/luna/binary/refresh.rb', line 9

def request_result_hash
  @request_result_hash
end

Instance Method Details

#createNeedFrameworkMapperObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/luna/binary/refresh.rb', line 62

def createNeedFrameworkMapper
    spec_repo_binary = {}
    Pod::UserInterface.puts "二进制repo地址 : #{CBin.config.binary_repo_url}".yellow
    Luna::Binary::Common.instance.use_framework_list.each { |item|
        if spec_repo_binary[item] == nil && item["/"] == nil
            name = item.split('/').first
            spec_repo_binary[name] = lockfile.version(name).version
        end
    }    
    return spec_repo_binary
end

#lockfileObject



47
48
49
# File 'lib/luna/binary/refresh.rb', line 47

def lockfile 
    return Luna::Binary::Common.instance.lockfile
end

#runObject



11
12
13
14
15
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
41
42
43
44
45
# File 'lib/luna/binary/refresh.rb', line 11

def run 
    spec_repo_binary = createNeedFrameworkMapper
    rootPath = "#{Luna::Binary::Common.instance.tempLunaUploaderPath}/refresh"
    Luna::Binary::Common.instance.deleteDirectory("#{rootPath}")
    system "mkdir -p #{rootPath};"
    failList = []
    spec_repo_binary.each { |k,v|
        if request_result_hash[k] != nil && request_result_hash[k].include?(v)
            begin
                pathArr = Dir.glob("#{binary_path}/**/#{k.sub("-","_")}.framework")
                if pathArr != nil
                    Pod::UserInterface.puts "#{pathArr.first} #{k}".yellow
                    srcPath = File.dirname(pathArr.first)
                    system "cp -r #{srcPath} #{rootPath};"
                    File.rename("#{rootPath}/#{File.basename(srcPath)}", "#{rootPath}/#{k}")
                    zipCommand = "cd #{rootPath};zip -r #{k}.zip #{k}"
                    p zipCommand
                    system zipCommand
                    Luna::Binary::Delete.new(k,v).deleteBinaryFramework
                    command = "cd #{rootPath};curl #{CBin.config.binary_upload_url} -F \"name=#{k}\" -F \"version=#{v}\" -F \"annotate=#{k}_#{v}_log\" -F \"file=@#{k}.zip\""
                    p command 
                    system command
                end 
            rescue => exception
                p exception
                failList << "#{k} #{exception}"
            else
                
            end
        else   
          failList << "name: #{k}"
        end 
    } 
    p "exception:#{failList}"
end