Class: LgPodPlugin::LUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/lg_pod_plugin/l_util.rb

Class Method Summary collapse

Class Method Details

.aes_decrypt(key, data) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/lg_pod_plugin/l_util.rb', line 33

def self.aes_decrypt(key, data)
  de_cipher = OpenSSL::Cipher::Cipher.new("AES-128-CBC")
  de_cipher.decrypt
  de_cipher.key = [key].pack('H*')
  # de_cipher.iv = [iv].pack('H*');
  puts de_cipher.update([data].pack('H*')) << de_cipher.final
end

.unzip_file(zip_file, dest_dir) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lg_pod_plugin/l_util.rb', line 5

def self.unzip_file (zip_file, dest_dir)
  begin
    LgPodPlugin.log_green "正在解压`.zip`文件"
    Zip::File.open(zip_file) do |file|
      file.each do |f|
        file_path = File.join(dest_dir, f.name)
        FileUtils.mkdir_p(File.dirname(file_path))
        # next if file_path.include?("LICENSE")
        next if file_path.include?("Example")
        next if file_path.include?(".gitignore")
        next if file_path.include?("node_modules")
        next if file_path.include?("package.json")
        next if file_path.include?(".swiftlint.yml")
        next if file_path.include?("_Pods.xcodeproj")
        next if file_path.include?("package-lock.json")
        next if file_path.include?("README.md")
        next if file_path.include?("commitlint.config.js")
        file.extract(f, file_path)
      end
    end
    return true
  rescue => err
    LgPodPlugin.log_red "解压zip失败, error => #{err}"
    return false
  end

end