Class: LgPodPlugin::LPodInstaller
- Inherits:
-
Object
- Object
- LgPodPlugin::LPodInstaller
- Defined in:
- lib/lg_pod_plugin/installer/install.rb
Instance Attribute Summary collapse
-
#download_params ⇒ Object
Returns the value of attribute download_params.
Instance Method Summary collapse
- #copy_file_to_caches ⇒ Object
-
#initialize ⇒ LPodInstaller
constructor
A new instance of LPodInstaller.
- #install(pod) ⇒ Object
Constructor Details
#initialize ⇒ LPodInstaller
Returns a new instance of LPodInstaller.
16 17 |
# File 'lib/lg_pod_plugin/installer/install.rb', line 16 def initialize end |
Instance Attribute Details
#download_params ⇒ Object
Returns the value of attribute download_params.
11 12 13 |
# File 'lib/lg_pod_plugin/installer/install.rb', line 11 def download_params @download_params end |
Instance Method Details
#copy_file_to_caches ⇒ Object
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 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 |
# File 'lib/lg_pod_plugin/installer/install.rb', line 31 def copy_file_to_caches request = @downloader.send(:request) name = request.send(:name) params = Hash.new.merge!(request.params) = Hash.new.merge!(request.) commit = [:commit] ||= params[:commit] if request.lg_spec cache_podspec = request.lg_spec.spec else cache_podspec = LProject.shared.cache_specs[name] request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec end destination = self.download_params["destination"] cache_pod_spec_path = self.download_params["cache_pod_spec_path"] # podspec.json 不存在 unless cache_podspec local_spec_path = destination.glob("#{name}.podspec{,.json}").last if local_spec_path && File.exist?(local_spec_path) cache_podspec = Pod::Specification.from_file local_spec_path if cache_podspec LProject.shared.cache_specs[name] = cache_podspec LCache.write_spec cache_podspec, cache_pod_spec_path LCache.clean_pod_unused_files destination, cache_podspec end end request.lg_spec = LgPodPlugin::PodSpec.form_pod_spec cache_podspec if cache_podspec end # 判断缓存是否下载成功 if (destination && File.exist?(destination) && !Pathname(destination).children.empty?) && (cache_pod_spec_path && File.exist?(cache_pod_spec_path)) pod_is_exist = true else pod_is_exist = false end if pod_is_exist is_delete = request.params["is_delete"] ||= false LProject.shared.need_update_pods.delete(name) if is_delete request..delete(:branch) if commit request.[:commit] = commit if commit else git = [:git] return unless git cache_podspec = request.lg_spec.spec if request.lg_spec branch = [:branch] [:name] = name if name unless branch branch = self.request.params[:branch] if request.params[:branch] [:branch] = branch if branch end lg_pod_path = LFileManager.cache_workspace(LProject.shared.workspace) lg_pod_path.mkdir(0700) unless lg_pod_path.exist? [:path] = lg_pod_path FileUtils.chdir lg_pod_path git_clone = GitRepository.new() download_params = git_clone.download return unless download_params && File.exist?(download_params) FileUtils.chdir download_params if request.single_git LgPodPlugin::LCache.cache_pod(name, download_params, { :git => git }, cache_podspec, request.released_pod) else LgPodPlugin::LCache.cache_pod(name, download_params, request.get_cache_key_params, cache_podspec, request.released_pod) end FileUtils.chdir(LFileManager.download_director) FileUtils.rm_rf(download_params) request..delete(:branch) if commit request.[:commit] = commit if commit end end |
#install(pod) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/lg_pod_plugin/installer/install.rb', line 21 def install(pod) hash = pod. path = hash[:path] return nil if path @downloader = LDownloader.new(pod) self.download_params = @downloader.pre_download_pod return self.download_params end |