Class: ModifyUntil
- Inherits:
-
Object
- Object
- ModifyUntil
- Defined in:
- lib/modify_until.rb
Class Method Summary collapse
-
.find_max_ver(path, fwk) ⇒ Object
查找最大版本号.
- .modify_fwk_commit(fwk, src_commit, fwk_commit) ⇒ Object
-
.modify_fwk_file_line(file, src_commit, fwk_commit) ⇒ Object
修改文件.
-
.modify_src_commit(src, commit) ⇒ Object
开始修改源码仓库.
-
.modify_src_file_line(file, commit) ⇒ Object
修改文件.
Instance Method Summary collapse
-
#initialize ⇒ ModifyUntil
constructor
A new instance of ModifyUntil.
Constructor Details
#initialize ⇒ ModifyUntil
Returns a new instance of ModifyUntil.
5 6 7 |
# File 'lib/modify_until.rb', line 5 def initialize end |
Class Method Details
.find_max_ver(path, fwk) ⇒ Object
查找最大版本号
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/modify_until.rb', line 10 def self.find_max_ver(path,fwk) pn = Pathname.new(path) + fwk maxVer = "0.0.0" if pn.directory? pn.each_entry { |verDir| next if verDir.basename.to_s[0] == ?. if maxVer.compare_by_fields(verDir.basename.to_s) == -1 maxVer = verDir.basename.to_s end } end if maxVer != "0.0.0" return pn + maxVer + "#{fwk}.podspec" end return nil end |
.modify_fwk_commit(fwk, src_commit, fwk_commit) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/modify_until.rb', line 68 def self.modify_fwk_commit(fwk,src_commit,fwk_commit) path = Config.Bin_Spec_Path pn = find_max_ver(path,fwk) if pn.file? modify_fwk_file_line(pn.to_s,src_commit,fwk_commit) return pn.to_s else return nil end end |
.modify_fwk_file_line(file, src_commit, fwk_commit) ⇒ Object
修改文件
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/modify_until.rb', line 51 def self.modify_fwk_file_line(file,src_commit,fwk_commit) p 'start modify file ...' + file src_url = Config.Source_Repo_Url bin_url = Config.Bin_Repo_Url IO.write(file, File.open(file) do |f| f.read.gsub(/.*s.source.*#{src_url}.*/, " s.source = \{ :git => \'#{src_url}\', :commit => \"#{src_commit}\"\}") end ) IO.write(file, File.open(file) do |f| f.read.gsub(/.*s.source.*#{bin_url}.*/, " s.source = \{ :git => \'#{bin_url}\', :commit => \"#{fwk_commit}\"\}") end ) end |
.modify_src_commit(src, commit) ⇒ Object
开始修改源码仓库
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/modify_until.rb', line 39 def self.modify_src_commit(src,commit) path = Config.Source_Spec_Path pn = find_max_ver(path,src) if pn.file? modify_src_file_line(pn.to_s,commit) return pn.to_s else return nil end end |
.modify_src_file_line(file, commit) ⇒ Object
修改文件
28 29 30 31 32 33 34 35 |
# File 'lib/modify_until.rb', line 28 def self.modify_src_file_line(file,commit) p 'start modify file ...' + file IO.write(file, File.open(file) do |f| f.read.gsub(/:commit => "(.*)"/, ":commit => \"#{commit}\"") end ) end |