Class: PodsOrz::PodfileIO
- Inherits:
-
Object
- Object
- PodsOrz::PodfileIO
- Defined in:
- lib/podsorz/core/PodFile/podfile_io.rb
Instance Attribute Summary collapse
-
#http_host ⇒ Object
Returns the value of attribute http_host.
-
#main_path ⇒ Object
Returns the value of attribute main_path.
-
#remote_binary_directory ⇒ Object
Returns the value of attribute remote_binary_directory.
-
#total_pod_models ⇒ Object
Returns the value of attribute total_pod_models.
-
#total_sentences ⇒ Object
Returns the value of attribute total_sentences.
-
#usable_sentences ⇒ Object
Returns the value of attribute usable_sentences.
Instance Method Summary collapse
- #filter_binary_pod_models ⇒ Object
- #get_podfile_pod_branch(pod) ⇒ Object
- #get_podfile_pod_version(pod) ⇒ Object
-
#initialize(main_path) ⇒ PodfileIO
constructor
A new instance of PodfileIO.
- #load_config_binary_pod(pod_name_list) ⇒ Object
- #load_config_local_pod(pod_name_list) ⇒ Object
-
#output_local_binary_sentence(binary_pods_list) ⇒ Object
binary output.
- #output_local_total_sentence ⇒ Object
- #output_orz_total_sentence(pod_name_list, branch_name) ⇒ Object
- #output_publish_total_sentence(pod_hash) ⇒ Object
- #parse_podfile_orz ⇒ Object
Constructor Details
#initialize(main_path) ⇒ PodfileIO
Returns a new instance of PodfileIO.
11 12 13 14 15 16 17 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 11 def initialize(main_path) @main_path = main_path @http_host = "http://192.168.6.127:8899" @remote_binary_directory = "binary_pod" @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path) self.parse_podfile_orz end |
Instance Attribute Details
#http_host ⇒ Object
Returns the value of attribute http_host.
9 10 11 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 9 def http_host @http_host end |
#main_path ⇒ Object
Returns the value of attribute main_path.
9 10 11 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 9 def main_path @main_path end |
#remote_binary_directory ⇒ Object
Returns the value of attribute remote_binary_directory.
9 10 11 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 9 def remote_binary_directory @remote_binary_directory end |
#total_pod_models ⇒ Object
Returns the value of attribute total_pod_models.
9 10 11 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 9 def total_pod_models @total_pod_models end |
#total_sentences ⇒ Object
Returns the value of attribute total_sentences.
9 10 11 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 9 def total_sentences @total_sentences end |
#usable_sentences ⇒ Object
Returns the value of attribute usable_sentences.
9 10 11 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 9 def usable_sentences @usable_sentences end |
Instance Method Details
#filter_binary_pod_models ⇒ Object
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 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 19 def filter_binary_pod_models() filter_result_models = [] filter_strings = ["sourceVendorPods", "subspecPods", @orzconfig_parse.file_package_filter_mark] result_lines = [] switch_flag = false filter_strings.each do |f_str| @total_sentences.each do |line| if line.include? f_str switch_flag = true end result_lines << line if switch_flag if line.include? "正则匹配注释#{f_str}" switch_flag = false break end end end result_lines.each do |line| podfile_model = PodsOrz::PodfileModel.validate_podfile_sentence_instance(line) filter_result_models << podfile_model unless podfile_model.nil? end filter_result_models end |
#get_podfile_pod_branch(pod) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 64 def get_podfile_pod_branch(pod) branch = "" @total_pod_models.each do |model| if model.name == pod branch = model.branch break end end branch = "" if branch.nil? branch end |
#get_podfile_pod_version(pod) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 50 def get_podfile_pod_version(pod) pod_version = "" @total_pod_models.each do |model| if model.name == pod pod_version = model.version break end end pod_version = "" if pod_version.nil? pod_version end |
#load_config_binary_pod(pod_name_list) ⇒ Object
317 318 319 320 321 322 323 324 325 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 317 def load_config_binary_pod(pod_name_list) pod_name_list.each do |podname| @total_pod_models.map { |model| if model.name.start_with? podname.to_s model.podspec = "#{@http_host}/#{remote_binary_directory}/#{model.name}/#{model.version}/#{model.name}.podspec" unless model.version.nil? end } end end |
#load_config_local_pod(pod_name_list) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 105 def load_config_local_pod(pod_name_list) pod_name_list.each do |podname| @total_pod_models.map { |model| if model.name.start_with? podname.to_s model.path = "../#{@orzconfig_parse.file_devpods_name}/" + podname.to_s end } end end |
#output_local_binary_sentence(binary_pods_list) ⇒ Object
binary output
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 272 def output_local_binary_sentence(binary_pods_list) return if binary_pods_list.empty? load_config_binary_pod(binary_pods_list) cocoas_podfile_path = File.("Podfile", @main_path) output_pod_list = @total_pod_models.reject { |model| podspec = model.podspec podspec.to_s.empty? } File.open(cocoas_podfile_path, "w+") {|io| Logger.highlight("Podfile binary podspec completed!") @usable_sentences.map! do |sentence| output_pod_list.each do |model| filter_str = "\'#{model.name}\'" if sentence.include? filter_str splite_list = sentence.split(filter_str) sentence = splite_list[0].to_s + filter_str + ", :podspec => " + "\'#{model.podspec.to_s}\'" if model.configurations sentence = sentence + ", :configurations => " + model.configurations.to_s end if model.modular_headers sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s end if model.subspecs sentence = sentence + ", :subspecs => " + model.subspecs.to_s end sentence = sentence + "\n" puts(sentence) end end io.write(sentence + "\n") sentence end } end |
#output_local_total_sentence ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 176 def output_local_total_sentence cocoas_podfile_path = File.("Podfile", @main_path) output_pod_list = @total_pod_models.reject { |model| path = model.path path.to_s.empty? } File.open(cocoas_podfile_path, "w+") {|io| Logger.highlight("Local Podfile edite completed!") @usable_sentences.each do |sentence| output_pod_list.each do |model| filter_str = "\'#{model.name}\'" if sentence.include? filter_str splite_list = sentence.split(filter_str) sentence = splite_list[0].to_s + filter_str + ", :path => " + "\'#{model.path.to_s}\'" if model.configurations sentence = sentence + ", :configurations => " + model.configurations.to_s end if model.modular_headers sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s end if model.subspecs sentence = sentence + ", :subspecs => " + model.subspecs.to_s end sentence = sentence + "\n" puts(sentence) end end io.write(sentence + "\n") end } end |
#output_orz_total_sentence(pod_name_list, branch_name) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 116 def output_orz_total_sentence(pod_name_list, branch_name) pod_name_list.each do |podname| @total_pod_models.map { |model| if model.name.start_with? podname.to_s # 替换为config参数 model.git = "#{@orzconfig_parse.remote_url_sourcecode}/" + podname.to_s + ".git" model.branch = branch_name.to_s end } end cocoas_podfile_path = File.("Podfile_orz.rb", @main_path) output_pod_list = @total_pod_models.reject { |model| pod_name = model.name !pod_name_list.include? pod_name } File.open(cocoas_podfile_path, "w+") {|io| Logger.highlight("Remote Podfile_orz.rb edite completed!") @total_sentences.each do |sentence| sentence_content = sentence.strip.chomp.to_s is_sentence_comtent_empty = sentence_content.empty? is_sentence_comtent_size_zero = sentence_content.size.zero? unless is_sentence_comtent_empty || is_sentence_comtent_size_zero unless sentence_content.start_with?("#") output_pod_list.each do |model| filter_str = "\'#{model.name}\'" if sentence.include? filter_str splite_list = sentence.split(filter_str) sentence = splite_list[0].to_s + filter_str + ", :git => " + "\'#{model.git}\'" + ", :branch => " + "\'#{model.branch}\'" if model.configurations sentence = sentence + ", :configurations => " + model.configurations.to_s end if model.modular_headers sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s end if model.subspecs sentence = sentence + ", :subspecs => " + model.subspecs.to_s end puts(sentence.chomp + "\n") end end end end io.write(sentence.chomp + "\n") end } end |
#output_publish_total_sentence(pod_hash) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 215 def output_publish_total_sentence(pod_hash) pod_hash.each { |pod_name, version| @total_pod_models.map { |model| if model.name.start_with? pod_name.to_s model.version = version end } } cocoas_podfile_path = File.("Podfile_orz.rb", @main_path) output_pod_list = @total_pod_models.reject { |model| pod_name = model.name !pod_hash.include? pod_name } File.open(cocoas_podfile_path, "w+") {|io| Logger.highlight("Remote Podfile_orz.rb edite completed!") @total_sentences.each do |sentence| sentence_content = sentence.strip.chomp.to_s is_sentence_comtent_empty = sentence_content.empty? is_sentence_comtent_size_zero = sentence_content.size.zero? unless is_sentence_comtent_empty || is_sentence_comtent_size_zero unless sentence_content.start_with?("#") output_pod_list.each do |model| filter_str = "\'#{model.name}\'" if sentence.include? filter_str splite_list = sentence.split(filter_str) sentence = splite_list[0].to_s + filter_str + ", \'#{model.version}\'" if model.configurations sentence = sentence + ", :configurations => " + model.configurations.to_s end if model.modular_headers sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s end if model.subspecs sentence = sentence + ", :subspecs => " + model.subspecs.to_s end puts(sentence.chomp + "\n") end end end end io.write(sentence.chomp + "\n") end } end |
#parse_podfile_orz ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/podsorz/core/PodFile/podfile_io.rb', line 78 def parse_podfile_orz orz_file_path = File.("Podfile_orz.rb", @main_path) @total_sentences = [] @usable_sentences = [] @total_pod_models = [] File.open(orz_file_path, "r") { |io| @total_sentences = io.readlines @total_sentences.each { |orz_line| orz_line_content = orz_line.strip.chomp unless orz_line_content.empty? || orz_line_content.size.zero? unless orz_line_content.start_with?("#") @usable_sentences << orz_line if orz_line_content.start_with?("pod ") podfile_model = PodsOrz::PodfileModel.new(orz_line_content) @total_pod_models << podfile_model end end end } } end |