Class: Pod::CacheProxySource::CacheProxySourceHelper
- Inherits:
-
Object
- Object
- Pod::CacheProxySource::CacheProxySourceHelper
- Defined in:
- lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb
Class Method Summary collapse
- .check_cache_proxy_source_conf_exists(source_name) ⇒ Object
- .create_cache_proxy_source_conf(source_name, url, user, password) ⇒ Object
- .get_all_cache_proxy_source_conf ⇒ Object
- .get_cache_proxy_root_dir ⇒ Object
- .get_cache_proxy_source_conf(cache_source_name) ⇒ Object
- .get_cache_proxy_source_conf_file_name ⇒ Object
- .get_cache_proxy_source_conf_path(source_name) ⇒ Object
- .get_cache_proxy_source_root_dir(source_name) ⇒ Object
- .init_cache_proxy_source(cache_source_name, cache_source_url, user, password) ⇒ Object
- .load_conf(source_name) ⇒ Object
- .remove_cache_proxy_source(cache_source_name) ⇒ Object
Class Method Details
.check_cache_proxy_source_conf_exists(source_name) ⇒ Object
30 31 32 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 30 def self.check_cache_proxy_source_conf_exists(source_name) File.exist?(get_cache_proxy_source_conf_path(source_name)) end |
.create_cache_proxy_source_conf(source_name, url, user, password) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 43 def self.create_cache_proxy_source_conf(source_name, url, user, password) path = get_cache_proxy_source_conf_path(source_name) info = { 'name' => source_name, 'url' => url, } info['user'] = user unless user.blank? info['password'] = password unless password.blank? conf = File.new(path, "wb") conf << info.to_yaml conf.close end |
.get_all_cache_proxy_source_conf ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 97 def self.get_all_cache_proxy_source_conf() return [] unless Dir.exist?(get_cache_proxy_root_dir()) confs = [] Find.find(get_cache_proxy_root_dir()) do |path| next unless File.file?(path) && path.end_with?(".cache_proxy_conf.yml") pn = Pathname.new(path) source_name = pn.dirname.basename next unless (conf = get_cache_proxy_source_conf(source_name)) confs << conf end confs end |
.get_cache_proxy_root_dir ⇒ Object
14 15 16 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 14 def self.get_cache_proxy_root_dir() "#{Pod::Config.instance.home_dir}/cache-proxy" end |
.get_cache_proxy_source_conf(cache_source_name) ⇒ Object
92 93 94 95 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 92 def self.get_cache_proxy_source_conf(cache_source_name) return nil unless (hash = load_conf(cache_source_name)) Pod::CacheProxySource.new(hash['name'], hash['url'], hash['user'], hash['password']) end |
.get_cache_proxy_source_conf_file_name ⇒ Object
22 23 24 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 22 def self.get_cache_proxy_source_conf_file_name() ".cache_proxy_conf.yml" end |
.get_cache_proxy_source_conf_path(source_name) ⇒ Object
26 27 28 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 26 def self.get_cache_proxy_source_conf_path(source_name) "#{get_cache_proxy_source_root_dir(source_name)}/#{get_cache_proxy_source_conf_file_name()}" end |
.get_cache_proxy_source_root_dir(source_name) ⇒ Object
18 19 20 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 18 def self.get_cache_proxy_source_root_dir(source_name) "#{Pod::Config.instance.home_dir}/cache-proxy/#{source_name}" end |
.init_cache_proxy_source(cache_source_name, cache_source_url, user, password) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 60 def self.init_cache_proxy_source(cache_source_name, cache_source_url, user, password) begin show_output = Pod::Config.instance.verbose? cache_source_root_path = "#{get_cache_proxy_source_root_dir(cache_source_name)}" FileUtils.rm_rf(cache_source_root_path) if Dir.exist?(cache_source_root_path) FileUtils.mkdir_p(cache_source_root_path) Pod::UI. "Generating source conf .....".yellow if show_output create_cache_proxy_source_conf(cache_source_name, cache_source_url, user, password) Pod::UI. "Successfully added repo #{cache_source_name}".green if show_output rescue Exception => e Pod::UI. "发生异常,清理文件 .....".yellow if show_output FileUtils.rm_rf(cache_source_root_path) if Dir.exist?(cache_source_root_path) Pod::UI. e..yellow if show_output Pod::UI. e.backtrace.inspect.yellow if show_output raise e end end |
.load_conf(source_name) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 34 def self.load_conf(source_name) path = get_cache_proxy_source_conf_path(source_name) if File.exist?(path) YAML.load_file(path) else nil end end |
.remove_cache_proxy_source(cache_source_name) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/cocoapods-cache-proxy/helper/cache_proxy_source_helper.rb', line 83 def self.remove_cache_proxy_source(cache_source_name) show_output = Pod::Config.instance.verbose? cache_source_root_path = "#{get_cache_proxy_source_root_dir(cache_source_name)}" FileUtils.rm_rf(cache_source_root_path) if Dir.exist?(cache_source_root_path) Pod::UI. "Successfully remove repo #{cache_source_name}".green if show_output end |