Class: Luna::Binary::Common

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/luna/binary/common/common.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommon

Returns a new instance of Common.



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

def initialize()
end

Instance Attribute Details

#lockfileObject

Returns the value of attribute lockfile.



16
17
18
# File 'lib/luna/binary/common/common.rb', line 16

def lockfile
  @lockfile
end

#podFilePathObject

Returns the value of attribute podFilePath.



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

def podFilePath
  @podFilePath
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#binary_path_armObject



61
62
63
# File 'lib/luna/binary/common/common.rb', line 61

def binary_path_arm
    return tempLunaUploaderPath + "/arm64"
end

#binary_path_mergedObject



57
58
59
# File 'lib/luna/binary/common/common.rb', line 57

def binary_path_merged
  return tempLunaUploaderPath + "/merged"
end

#binary_path_x86Object



65
66
67
# File 'lib/luna/binary/common/common.rb', line 65

def binary_path_x86
    return tempLunaUploaderPath + "/x86"
end

#command(c) ⇒ Object



74
75
76
77
# File 'lib/luna/binary/common/common.rb', line 74

def command(c)
  p c
  return system c
end

#createNeedFrameworkMapperObject



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/luna/binary/common/common.rb', line 106

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

#deleteDirectory(dirPath) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/luna/binary/common/common.rb', line 36

def deleteDirectory(dirPath)
    if File.directory?(dirPath)
      Dir.foreach(dirPath) do |subFile|
        if subFile != '.' and subFile != '..' 
          deleteDirectory(File.join(dirPath, subFile));
        end
      end
      Dir.rmdir(dirPath);
    else
      if File.exist?(dirPath)
        File.delete(dirPath);
      end
    end
end

#findLintPodspec(moduleName) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/luna/binary/common/common.rb', line 79

def findLintPodspec(moduleName)
  sets = Pod::Config.instance.sources_manager.search_by_name(moduleName)
  # p sets
  if sets.count == 1
      set = sets.first
  elsif sets.map(&:name).include?(moduleName)
      set = sets.find { |s| s.name == moduleName }
  else
      names = sets.map(&:name) * ', '
      # raise Informative, "More than one spec found for '#{moduleName}':\n#{names}"
  end  
  return set  
end

#repoPathObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/luna/binary/common/common.rb', line 21

def repoPath
    sources = Pod::Config.instance.sources_manager.all
    repoPath = nil
    sources.each { |item|
      if item.url == CBin.config.binary_repo_url
        repoPath = item.repo
      end
    }
    if repoPath == nil
      p '没找到repo路径'
      raise '没找到repo路径'  
    end
    return repoPath
end

#request_result_hashObject



97
98
99
100
101
102
103
104
# File 'lib/luna/binary/common/common.rb', line 97

def request_result_hash
    command = "curl #{CBin.config.binary_upload_url}"
    p command
    result = %x(#{command})
    request_result_hash = JSON.parse(result)
    p request_result_hash
    return request_result_hash
end

#tempLunaUploaderPathObject



51
52
53
54
55
# File 'lib/luna/binary/common/common.rb', line 51

def tempLunaUploaderPath
  result = `pwd`
  rootName = result.strip! + "/temp-luna-uploader"
  return rootName
end

#use_framework_listObject



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

def use_framework_list
  list = []
  File.open(Dir.pwd+"/Podfile", 'r:utf-8') do  |f|
      f.each_line do |item|
          if item[":dev_env_use_binary"]
              matchs = item.match(/\'(?<=').*?(?=')\'/)
              if matchs != nil
                  list << matchs[0].gsub("'", "")
              end
          end
      end
    end
  p "use_framework_list: #{list}"
  return list
end