Class: GkdPushPod::PodUpdaterFile
- Inherits:
-
Object
- Object
- GkdPushPod::PodUpdaterFile
- Defined in:
- lib/gkd_push_pod/pod_updater_file.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
Returns the value of attribute paths.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ PodUpdaterFile
constructor
A new instance of PodUpdaterFile.
Constructor Details
#initialize(path) ⇒ PodUpdaterFile
Returns a new instance of PodUpdaterFile.
8 9 10 11 12 13 14 15 16 |
# File 'lib/gkd_push_pod/pod_updater_file.rb', line 8 def initialize(path) _path = File.(path) return nil unless File.exist?(_path) pod_updater_path = PodUpdaterFile.find_podupdater_file_path(_path) if pod_updater_path self.paths = PodUpdaterFile.parser_podupdater_file(pod_updater_path) end end |
Instance Attribute Details
#paths ⇒ Object
Returns the value of attribute paths.
6 7 8 |
# File 'lib/gkd_push_pod/pod_updater_file.rb', line 6 def paths @paths end |
Class Method Details
.find_podupdater_file_path(path) ⇒ Object
18 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 49 50 |
# File 'lib/gkd_push_pod/pod_updater_file.rb', line 18 def self.find_podupdater_file_path(path) _path = File.(path) return nil unless File.exist?(_path) pod_updater_path = _path unless _path =~ /\/podUpdater$/ if File.directory?(_path) pod_updater_paths = Dir.glob("#{_path}/podUpdater") if pod_updater_paths.length == 0 pod_updater_path = nil elsif pod_updater_paths.length == 1 pod_updater_path = pod_updater_paths.first else UI.msg "目录下找到多个podUpdater文件!" pod_updater_paths.each_with_index do |elem, index| basename = File.basename(elem) UI.msg %(#{index}.#{basename} ) end puts "请指定您当前需要的操作的文件,输入它的序号:" i = gets.to_i case i when 0 .. (podfiles.length-1) pod_updater_path = podfiles[i.to_i] else UI.err "输入错误❌" pod_updater_path = nil end end end end pod_updater_path end |
.parser_podupdater_file(filePath) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/gkd_push_pod/pod_updater_file.rb', line 52 def self.parser_podupdater_file(filePath) if !filePath || !(filePath =~ /\/podUpdater$/) return nil end paths = [] File.open(filePath, "r") do |f| f.each_line do |line| if line.to_s =~ /["']path["']\s*,\s*["'](.*)["']/ paths << $1.to_s end end end paths end |