Class: BigKeeper::PodfileDetector
- Inherits:
-
Object
- Object
- BigKeeper::PodfileDetector
- Defined in:
- lib/big_keeper/util/podfile_detector.rb
Instance Attribute Summary collapse
-
#main_path ⇒ Object
Returns the value of attribute main_path.
-
#module_list ⇒ Object
Returns the value of attribute module_list.
Class Method Summary collapse
Instance Method Summary collapse
- #chose_version(cur_version, temp_version) ⇒ Object
- #deal_lock_file(main_path, deal_list) ⇒ Object
- #deal_podfile_line(sentence) ⇒ Object
- #deal_podfile_line_forCurrent(sentence) ⇒ Object
- #get_current_module_list ⇒ Object
-
#get_lock_podname(sentence) ⇒ Object
获得pod名称.
-
#get_lock_version(sentence) ⇒ Object
获得pod版本号.
- #get_pod_name(sentence) ⇒ Object
- #get_unlock_pod_list ⇒ Object
-
#initialize(main_path, module_list) ⇒ PodfileDetector
constructor
A new instance of PodfileDetector.
Constructor Details
#initialize(main_path, module_list) ⇒ PodfileDetector
Returns a new instance of PodfileDetector.
14 15 16 17 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 14 def initialize(main_path, module_list) @module_list = module_list @main_path = main_path end |
Instance Attribute Details
#main_path ⇒ Object
Returns the value of attribute main_path.
9 10 11 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 9 def main_path @main_path end |
#module_list ⇒ Object
Returns the value of attribute module_list.
9 10 11 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 9 def module_list @module_list end |
Class Method Details
.get_pod_model(sentence) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 94 def self.get_pod_model(sentence) if sentence.include?('pod ') pod_model = PodfileModel.new(sentence) return pod_model end end |
Instance Method Details
#chose_version(cur_version, temp_version) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 120 def chose_version(cur_version,temp_version) # p "cur:#{cur_version},temp:#{temp_version}" cur_list = cur_version.split('.') temp_list = temp_version.split('.') temp_list << 0.to_s if temp_list.size == 2 if cur_list[0] >= temp_list[0] if cur_list[1] >= temp_list[1] if cur_list[2] > temp_list[2] return cur_version end return temp_version end return temp_version end return temp_version end |
#deal_lock_file(main_path, deal_list) ⇒ Object
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 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 68 def deal_lock_file(main_path, deal_list) $result = {} podfile_lock_lines = File.readlines("#{main_path}/Podfile.lock") Logger.highlight("Analyzing Podfile.lock...") unless podfile_lock_lines.size.zero? podfile_lock_lines.select do |sentence| if sentence.include?('DEPENDENCIES') #指定范围解析 Dependencies 之前 break end temp_sentence = sentence.strip pod_name = get_lock_podname(temp_sentence) if deal_list.include?(pod_name) current_version = $result[pod_name] temp_version = get_lock_version(temp_sentence) if temp_version != nil if current_version != nil $result[pod_name] = chose_version(current_version, temp_version) else $result[pod_name] = temp_version end end end end return $result end |
#deal_podfile_line(sentence) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 53 def deal_podfile_line(sentence) return unless !sentence.strip.start_with?("#") if sentence.strip.include?('pod ') pod_model = PodfileModel.new(sentence) if !pod_model.name.empty? && pod_model.configurations != '[\'Debug\']' && pod_model.path == nil && pod_model.tag == nil $unlock_pod_list << pod_model.name unless @module_list.include?(pod_model.name) end pod_model end end |
#deal_podfile_line_forCurrent(sentence) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 30 def deal_podfile_line_forCurrent(sentence) return unless !sentence.strip.start_with?("#") if sentence.strip.include?('pod ') pod_model = PodfileModel.new(sentence) if !pod_model.name.empty? && pod_model.path != nil && pod_model.tag == nil $current_module_list << pod_model.name if @module_list.include?(pod_model.name) end pod_model end end |
#get_current_module_list ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 20 def get_current_module_list $current_module_list = [] podfile_lines = File.readlines("#{@main_path}/Podfile") Logger.highlight("Analyzing Podfile...") unless podfile_lines.size.zero? podfile_lines.collect do |sentence| deal_podfile_line_forCurrent(sentence) end $current_module_list end |
#get_lock_podname(sentence) ⇒ Object
获得pod名称
109 110 111 112 113 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 109 def get_lock_podname(sentence) #获得pod名称 match_result = /(\d+.){1,2}\d+/.match(sentence.delete('- :~>=')) pod_name = match_result.pre_match unless match_result == nil return pod_name.delete('()') unless pod_name == nil end |
#get_lock_version(sentence) ⇒ Object
获得pod版本号
115 116 117 118 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 115 def get_lock_version(sentence)#获得pod版本号 match_result = /(\d+.){1,2}\d+/.match(sentence) return match_result[0] unless match_result == nil end |
#get_pod_name(sentence) ⇒ Object
101 102 103 104 105 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 101 def get_pod_name(sentence) pod_model = deal_podfile_line(sentence) pod_name = pod_model.name if pod_model != nil && pod_model.configurations.nil @unlock_pod_list << pod_name unless @module_list.include pod_name end |
#get_unlock_pod_list ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/big_keeper/util/podfile_detector.rb', line 44 def get_unlock_pod_list podfile_lines = File.readlines("#{@main_path}/Podfile") Logger.highlight("Analyzing Podfile...") unless podfile_lines.size.zero? podfile_lines.collect do |sentence| deal_podfile_line(sentence) unless sentence =~(/(\d+.){1,2}\d+/) end $unlock_pod_list end |