class PodsOrz::OrzEnvDetector
Public Instance Methods
check_directory(directoryPath)
click to toggle source
# File lib/podsorz/core/Config/orz_env_detector.rb, line 6 def check_directory(directoryPath) is_directory = File.directory?(directoryPath) Logger.error("Detect failure, directory path error: #{directoryPath}") unless is_directory is_directory end
copy_content_from_podfile(directoryPath)
click to toggle source
# File lib/podsorz/core/Config/orz_env_detector.rb, line 34 def copy_content_from_podfile(directoryPath) podfile_path = File.expand_path("Podfile", directoryPath) total_sentences = [] File.open(podfile_path, "r") { |io| total_sentences = io.readlines } dest_path = File.expand_path("Podfile_orz.rb", directoryPath) File.open(dest_path, "w+") {|io| total_sentences.each do |sentence| io.write(sentence) end } end
detect_PodsOrzConfig(directoryPath)
click to toggle source
# File lib/podsorz/core/Config/orz_env_detector.rb, line 50 def detect_PodsOrzConfig(directoryPath) orzconfig_path = File.expand_path("PodsOrzConfig.rb", directoryPath) orzconfig_result = File.exist?(orzconfig_path) generate_default_config(orzconfig_path) unless orzconfig_result end
detect_podfile(directoryPath)
click to toggle source
# File lib/podsorz/core/Config/orz_env_detector.rb, line 13 def detect_podfile(directoryPath) podfile_path = File.expand_path("Podfile", directoryPath) result = File.exist?(podfile_path) unless result Logger.warning("Podfile not exist, create empty Podfile") IO.popen("cd #{directoryPath};pod init") end end
detect_podfile_orz(directoryPath)
click to toggle source
# File lib/podsorz/core/Config/orz_env_detector.rb, line 22 def detect_podfile_orz(directoryPath) podfile_path = File.expand_path("Podfile_orz.rb", directoryPath) result = File.exist?(podfile_path) unless result Logger.error("Podfile_orz.rb not exist,auto generate one which content is copy from origin Podfile") IO.popen("cd #{directoryPath};touch Podfile_orz.rb") copy_content_from_podfile(directoryPath) end result end
generate_default_config(file_path)
click to toggle source
# File lib/podsorz/core/Config/orz_env_detector.rb, line 57 def generate_default_config(file_path) Logger.warning("PodsOrzConfig not exist, generate default config") file_name = File.basename(file_path) directory = File.dirname(file_path) IO.popen("cd #{directory};touch #{file_name}") { |io| templet_config_path = File.expand_path("./orz_config_templet.rb", File.dirname(__FILE__)) File.open(templet_config_path, "r") { |templet_file| File.open(file_path, "w+") { |file| templet_file.readlines.each {|line| puts line file.write(line) } } } } end