Class: KZ::KZGlobalHelper
- Inherits:
-
Object
- Object
- KZ::KZGlobalHelper
- Defined in:
- lib/cocoapods-kz/helpers/kz_global_helper.rb
Constant Summary collapse
- @@instance =
nil
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#disable_generate_framework ⇒ Object
Returns the value of attribute disable_generate_framework.
-
#generate_kz_pod_targets ⇒ Object
Returns the value of attribute generate_kz_pod_targets.
-
#kz_analyzer ⇒ Object
Returns the value of attribute kz_analyzer.
-
#kz_config_lock ⇒ Object
Returns the value of attribute kz_config_lock.
-
#kz_generator ⇒ Object
Returns the value of attribute kz_generator.
-
#kz_pod_config ⇒ Object
Returns the value of attribute kz_pod_config.
-
#kz_pod_enable ⇒ Object
Returns the value of attribute kz_pod_enable.
-
#specify_pod_mode ⇒ Object
Returns the value of attribute specify_pod_mode.
-
#specify_pod_names ⇒ Object
Returns the value of attribute specify_pod_names.
Class Method Summary collapse
Instance Method Summary collapse
- #analyze_special_parameters(use_code_tag, use_framework_tag, pod_names) ⇒ Object
- #have_flexLib_pod_target ⇒ Object
-
#initialize ⇒ KZGlobalHelper
constructor
A new instance of KZGlobalHelper.
- #kz_merge_swift_h_path ⇒ Object
- #pod_config_result_with_target(kz_pod_target) ⇒ Object
- #prepare ⇒ Object
- #write_lock_file ⇒ Object
Constructor Details
#initialize ⇒ KZGlobalHelper
Returns a new instance of KZGlobalHelper.
47 48 49 50 51 52 53 54 55 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 47 def initialize @kz_pod_enable = false @specify_pod_mode = :kz_pod_origin_mode @pods_config_cache = {} @debug = false @kz_config_lock = {} @disable_generate_framework = false @generate_kz_pod_targets = false end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
40 41 42 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 40 def debug @debug end |
#disable_generate_framework ⇒ Object
Returns the value of attribute disable_generate_framework.
42 43 44 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 42 def disable_generate_framework @disable_generate_framework end |
#generate_kz_pod_targets ⇒ Object
Returns the value of attribute generate_kz_pod_targets.
43 44 45 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 43 def generate_kz_pod_targets @generate_kz_pod_targets end |
#kz_analyzer ⇒ Object
Returns the value of attribute kz_analyzer.
36 37 38 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 36 def kz_analyzer @kz_analyzer end |
#kz_config_lock ⇒ Object
Returns the value of attribute kz_config_lock.
41 42 43 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 41 def kz_config_lock @kz_config_lock end |
#kz_generator ⇒ Object
Returns the value of attribute kz_generator.
37 38 39 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 37 def kz_generator @kz_generator end |
#kz_pod_config ⇒ Object
Returns the value of attribute kz_pod_config.
35 36 37 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 35 def kz_pod_config @kz_pod_config end |
#kz_pod_enable ⇒ Object
Returns the value of attribute kz_pod_enable.
34 35 36 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 34 def kz_pod_enable @kz_pod_enable end |
#specify_pod_mode ⇒ Object
Returns the value of attribute specify_pod_mode.
39 40 41 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 39 def specify_pod_mode @specify_pod_mode end |
#specify_pod_names ⇒ Object
Returns the value of attribute specify_pod_names.
38 39 40 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 38 def specify_pod_names @specify_pod_names end |
Class Method Details
.instance ⇒ Object
58 59 60 61 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 58 def self.instance FileUtils.mkdir_p(KZ_POD_CONFIG_ROOT) unless File.exist?(KZ_POD_CONFIG_ROOT) @@instance ||= new end |
Instance Method Details
#analyze_special_parameters(use_code_tag, use_framework_tag, pod_names) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 79 def analyze_special_parameters(use_code_tag, use_framework_tag, pod_names) specify_pod_names = [] if pod_names.count > 0 pod_names.each do |param| if param.include?(',') specify_pod_names.concat(param.split(",")) else specify_pod_names << param end end end @specify_pod_names = specify_pod_names if use_code_tag @specify_pod_mode = :kz_pod_code_mode elsif use_framework_tag @specify_pod_mode = :kz_pod_framework_mode end end |
#have_flexLib_pod_target ⇒ Object
110 111 112 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 110 def have_flexLib_pod_target @kz_analyzer.kz_pod_targets_with("FlexLib").count > 0 end |
#kz_merge_swift_h_path ⇒ Object
132 133 134 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 132 def kz_merge_swift_h_path KZ_POD_CONFIG_ROOT_STR + '/kz_merge_swift_h.rb' end |
#pod_config_result_with_target(kz_pod_target) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 98 def pod_config_result_with_target(kz_pod_target) return nil unless @kz_pod_enable return nil unless kz_pod_target && kz_pod_target.config_pod_mode == :kz_pod_framework_mode return @pods_config_cache[kz_pod_target.name] if @pods_config_cache.has_key?(kz_pod_target.name) result = KZFrameworkManager.validate_framework_and_get_result(kz_pod_target) @pods_config_cache[kz_pod_target.name] = result if result result end |
#prepare ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 63 def prepare if Pod::Config.instance.podfile && Pod::Config.instance.podfile.plugins.has_key?("cocoapods-kz") flex_compiler_de_path = KZ_POD_CONFIG_ROOT + 'FlexCompiler' FileUtils.rm(flex_compiler_de_path) if File.exist?(flex_compiler_de_path) FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/FlexCompiler', KZ_POD_CONFIG_ROOT) system("chmod +x #{flex_compiler_de_path}") FileUtils.cp_r(File.dirname(__FILE__) + '/../resources/kz_merge_swift_h.rb', KZ_MERGE_SWIFT_H_PATH) Pod::Config.instance.podfile.use_frameworks!(:linkage => :static) Pod::Config.instance.podfile.install!("cocoapods", :deterministic_uuids => false) else @kz_pod_enable = false @generate_kz_pod_targets = false end end |
#write_lock_file ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/cocoapods-kz/helpers/kz_global_helper.rb', line 114 def write_lock_file self.kz_analyzer.all_kz_pod_targets.values.each do |kz_pod_target| result = pod_config_result_with_target(kz_pod_target) @kz_config_lock[kz_pod_target.name] ||= {} @kz_config_lock[kz_pod_target.name]["dev_pod"] = kz_pod_target.is_dev_pod @kz_config_lock[kz_pod_target.name]["use_framework"] = (result != nil) @kz_config_lock[kz_pod_target.name]["version"] = kz_pod_target.version end if @kz_config_lock.count > 0 lock_file_content = JSON.pretty_generate(@kz_config_lock) File.open(KZ_LOCK_FILE_PATH, 'w') do |file| file.write(lock_file_content) end end end |