Class: DYAutomate::Command::Pod
- Inherits:
-
DYAutomate::Command
- Object
- CLAide::Command
- DYAutomate::Command
- DYAutomate::Command::Pod
- Defined in:
- lib/DYAutomate/Command/pod.rb,
lib/DYAutomate/Command/Pod/push.rb,
lib/DYAutomate/Command/Pod/version.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#name ⇒ Object
lib名字.
-
#path ⇒ Object
当前路径.
-
#spec_name ⇒ Object
#查询结果lib信息.
-
#spec_path ⇒ Object
spec文件路径.
Attributes inherited from DYAutomate::Command
Instance Method Summary collapse
-
#dy_update_repo ⇒ Object
更新repo.
-
#existPodspec? ⇒ Boolean
podspec文件是否存在.
-
#file_line_match(path, reg) ⇒ Object
文本文件查找内容.
-
#file_line_match_replace(path, reg, newline) ⇒ Object
文本文件替换某一行中文本.
-
#get_spec_version ⇒ Object
查找spec中版本号.
- #get_version_big_new ⇒ Object
- #get_version_new ⇒ Object
-
#initialize(argv) ⇒ Pod
constructor
A new instance of Pod.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from DYAutomate::Command
#env_str, options, #pp, #repoName
Constructor Details
#initialize(argv) ⇒ Pod
Returns a new instance of Pod.
26 27 28 29 |
# File 'lib/DYAutomate/Command/pod.rb', line 26 def initialize(argv) @path = Dir.pwd super end |
Instance Attribute Details
#name ⇒ Object
lib名字
17 18 19 |
# File 'lib/DYAutomate/Command/pod.rb', line 17 def name @name end |
#path ⇒ Object
当前路径
19 20 21 |
# File 'lib/DYAutomate/Command/pod.rb', line 19 def path @path end |
#spec_name ⇒ Object
#查询结果lib信息
24 25 26 |
# File 'lib/DYAutomate/Command/pod.rb', line 24 def spec_name @spec_name end |
#spec_path ⇒ Object
spec文件路径
22 23 24 |
# File 'lib/DYAutomate/Command/pod.rb', line 22 def spec_path @spec_path end |
Instance Method Details
#dy_update_repo ⇒ Object
更新repo
144 145 146 147 148 149 150 151 152 153 |
# File 'lib/DYAutomate/Command/pod.rb', line 144 def dy_update_repo path = File.join(Dir.home,'.cocoapods/repos') excludeFiles = [".","..",".DS_Store",'master'] Dir.entries(path).each do |subDir| puts subDir unless excludeFiles.include?(subDir) system "#{@env_str} pod repo update #{subDir}" end end end |
#existPodspec? ⇒ Boolean
podspec文件是否存在
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/DYAutomate/Command/pod.rb', line 46 def existPodspec? exist = false Dir.entries(@path).each{ |d| if d.to_s =~ /.podspec/ exist = true @spec_path = File.join(@path,d.to_s) @spec_name = d.to_s @name = d.to_s.split('.')[0] break end } exist end |
#file_line_match(path, reg) ⇒ Object
文本文件查找内容
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/DYAutomate/Command/pod.rb', line 110 def file_line_match(path,reg) pp('file_line_match ...' + path ,1) targetLine = '' File.open(path,"r+") do |file| #r:utf-8表示以utf-8编码读取文件,要与当前代码文件的编码相同 file.each_line {|line| puts line if line =~ reg targetLine = line break end } end pp('file_line_match..end --' + targetLine,1) targetLine end |
#file_line_match_replace(path, reg, newline) ⇒ Object
文本文件替换某一行中文本
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/DYAutomate/Command/pod.rb', line 127 def file_line_match_replace(path,reg,newline) filePath = path #查找要替换的文本 targetLine = file_line_match(filePath,reg) #替换内容 content = File.read(filePath) newContent = content.gsub(targetLine, newline) #覆盖内容 File.open(filePath,"w+") do |file| #r:utf-8表示以utf-8编码读取文件,要与当前代码文件的编码相同 file.write(newContent) file.close end end |
#get_spec_version ⇒ Object
查找spec中版本号
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/DYAutomate/Command/pod.rb', line 61 def get_spec_version #查找文本 targetLine = file_line_match(@spec_path,/s.version *=/) match = targetLine.match(/'[\d].[\d]*.[\d]*'/) v = '' if match v = match.to_s.gsub(/'/,'') end v end |
#get_version_big_new ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/DYAutomate/Command/pod.rb', line 89 def get_version_big_new new_v = '' cur_v = get_spec_version pp(cur_v,1) if cur_v && cur_v.size > 0 new_v = cur_v.split('.').map.with_index{|x,i| if i == 1 x.to_i + 1 elsif i == 2 0 else x end }.join('.') end pp("get_version_big_new == #{new_v}",1) new_v end |
#get_version_new ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/DYAutomate/Command/pod.rb', line 72 def get_version_new new_v = '' cur_v = get_spec_version pp(cur_v,1) if cur_v && cur_v.size > 0 new_v = cur_v.split('.').map.with_index{|x,i| if i == 2 x.to_i + 1 else x end }.join('.') end pp("get_version_new == #{new_v}",1) new_v end |
#run ⇒ Object
41 42 43 |
# File 'lib/DYAutomate/Command/pod.rb', line 41 def run pp('pod run ...',1) end |
#validate! ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/DYAutomate/Command/pod.rb', line 31 def validate! super unless existPodspec? help! " error -- >!!! has no podspec file at #{@path}" else puts "find podspec" + "#{@spec_path}" end end |