Module: Pod::Podfile::DSL
- Defined in:
- lib/cocoapods-binary-flutter/hook/podfile.rb
Instance Method Summary collapse
-
#install_all_lzflutter_pods(flutter_binary_path) ⇒ Object
安装.
-
#install_lzflutter_application_pod(flutter_binary_path) ⇒ Object
Install Flutter application pod.
-
#install_lzflutter_engine_pod(flutter_binary_path) ⇒ Object
安装flutter引擎.
-
#install_lzflutter_plugin_pods(flutter_binary_path) ⇒ Object
Install Flutter plugin pods.
-
#install_remote_flutter_binary(url = nil) ⇒ Object
下载.
Instance Method Details
#install_all_lzflutter_pods(flutter_binary_path) ⇒ Object
安装
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/cocoapods-binary-flutter/hook/podfile.rb', line 73 def install_all_lzflutter_pods(flutter_binary_path) # defined_in_file is a Pathname to the Podfile set by CocoaPods. pod_contents = File.read(defined_in_file) if pod_contents.include? 'flutter_post_install' puts "DELETE `flutter_post_install(installer)` to your Podfile `post_install` block to build Flutter plugins:\n\npost_install do |installer|\n flutter_post_install(installer)\nend\n" puts "\\e[33mDELETE `flutter_post_install(installer)` in Podfile `post_install` block Flutter产物依赖不需要flutter_post_install(installer) \e[0m" end install_lzflutter_engine_pod(flutter_binary_path) install_lzflutter_plugin_pods(flutter_binary_path) install_lzflutter_application_pod(flutter_binary_path) end |
#install_lzflutter_application_pod(flutter_binary_path) ⇒ Object
Install Flutter application pod.
121 122 123 |
# File 'lib/cocoapods-binary-flutter/hook/podfile.rb', line 121 def install_lzflutter_application_pod(flutter_binary_path) pod 'App', :path => File.join(flutter_binary_path, 'flutter'), :inhibit_warnings => true end |
#install_lzflutter_engine_pod(flutter_binary_path) ⇒ Object
安装flutter引擎
95 96 97 |
# File 'lib/cocoapods-binary-flutter/hook/podfile.rb', line 95 def install_lzflutter_engine_pod(flutter_binary_path) pod 'Flutter', :podspec => File.join(flutter_binary_path, 'flutter', 'Flutter.podspec'), :inhibit_warnings => true end |
#install_lzflutter_plugin_pods(flutter_binary_path) ⇒ Object
Install Flutter plugin pods.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/cocoapods-binary-flutter/hook/podfile.rb', line 100 def install_lzflutter_plugin_pods(flutter_binary_path) # Keep pod path relative so it can be checked into Podfile.lock. # Process will be run from project directory. registrantPath = File.join(flutter_binary_path, 'flutter', 'FlutterPluginRegistrant') if File.exist?(registrantPath) pod 'FlutterPluginRegistrant', :path => registrantPath, :inhibit_warnings => true end #插件目录 ios_plugins_directory_pathname = File.join(flutter_binary_path, 'plugins') #plugins遍历 Dir.foreach(ios_plugins_directory_pathname) do |item| next if item == '.' or item == '..' or File::directory?(File.join(ios_plugins_directory_pathname, item)) == false # do work on real items pod item, :path => File.join(ios_plugins_directory_pathname, item, 'ios'), :inhibit_warnings => true end end |
#install_remote_flutter_binary(url = nil) ⇒ Object
下载
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 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 |
# File 'lib/cocoapods-binary-flutter/hook/podfile.rb', line 16 def install_remote_flutter_binary(url = nil) #md5 md5 = Digest::MD5.new # =>#<Digest::MD5> md5 << url md5value = md5.hexdigest # => "78e73102..." flutter_f_home = Dir.home+'/Library/Caches/CocoaPods/Flutter/' flutter_binary_home = flutter_f_home+md5value flutter_binary_path = flutter_binary_home+'/binary' #创建目录 FileUtils.mkdir_p(flutter_binary_home) #清除超过30天的缓存 Dir.foreach(flutter_f_home) do |item| next if item == '.' or item == '..' or item == '.DS_Store' # do work on real items dirpath = flutter_f_home+item if File.directory?(dirpath) a = File.mtime(dirpath) t = Time.new if (t-a).round/60/60/24 > 30 FileUtils.remove_dir(dirpath) end end end #判断缓存 if File::directory?(flutter_binary_path) == false #下载 puts "开始下载 "+url uri = URI(url) download_file = open(flutter_binary_home+"/binary.zip", "wb") Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| request = Net::HTTP::Get.new uri.request_uri request.basic_auth 'zhiya_official', '202525631b169f4446103671d4ff0661' begin http.request(request) do |resp| resp.read_body { |segment| download_file.write(segment) } end ensure download_file.close end end #解压 puts "开始解压"+flutter_binary_home system("unzip", "-n", flutter_binary_home+'/binary.zip', "-d", flutter_binary_home) end #集成 install_all_lzflutter_pods(flutter_binary_path) end |