class MapTool::Release
Usage
Attributes
content[RW]
podfile[RW]
pods[RW]
sender[RW]
Public Class Methods
new(argv)
click to toggle source
初始化
Calls superclass method
# File lib/maptool/release/release.rb, line 38 def initialize(argv) super self.podfile = argv.option('podfile') self.pods = argv.option('pods') self.sender = argv.option('sender') self.content = argv.option('content') self.pods = self.pods.split(",").reject {|i| i.empty? } if self.pods # default self.content = "@所有人 有更新吗?今天发版,请尽快确认 Tag。" unless self.content self.content << "\n\n" unless self.pods self.pods = ['DiDiHomePageMapManager', 'DiDiLocationMiddleware', 'DiDiMapBusiness', 'DMPoiService', 'OneKeyReport', 'ONEPassengerOrderMap', 'ONESelectAddressModule', 'ONESTakeCarPlaceBusiness', 'DiDiMap', 'DiDiLocation', 'MapAnalogNavigation', 'DMap', 'ONESOSOMap', 'DiMapKit'] end end
options()
click to toggle source
Calls superclass method
MapTool::Command::options
# File lib/maptool/release/release.rb, line 25 def self.options [['--sender', '发送者员工号,如D11221,必须是群内人员'], ['--podfile', '包含 pods 库的 Podfile 路径'], ['--pods', "pods 库,“,”分割。默认地图事业部的库"], ['--content', "内容,默认“@所有人 有更新吗?今天发版,请尽快确认 Tag。”"]] + super end
Public Instance Methods
gitPull()
click to toggle source
# File lib/maptool/release/release.rb, line 89 def gitPull puts "#{self.podfile} git pull".green Dir.chdir(File.dirname(self.podfile)) {| path | system("yjcocoa git pull") } end
run()
click to toggle source
# File lib/maptool/release/release.rb, line 74 def run if File.exist?(self.podfile) self.gitPull File.open(self.podfile, "r") { |file| while line = file.gets #标准输入流 result = check(line) self.content << "#{result}\n" if result end } self.send else puts "文件# {filePath} 不存在".red end end
send()
click to toggle source
# File lib/maptool/release/release.rb, line 110 def send params = {} params["token"] = 'y2uxndvkoweyndixmdaw' # 测试 chat206c428d46590571b24cb54b1318a040 # 发版 chat326235a84efbc799daaf5d72522cb8fd params["chatId"] = 'chat326235a84efbc799daaf5d72522cb8fd' params["retry"] = 'false' params["sender"] = self.sender params["content"] = self.content puts "\nsend 钉钉".green puts self.content # send base_path = 'http://api-kylin.intra.xiaojukeji.com/prod_feige_service' uri = URI.parse("#{base_path}/feige/sendDingGroup") req = Net::HTTP::Post.new(uri.path, {'Content-Type' => 'application/json'}) req.body = params.to_json res = Net::HTTP.new(uri.host, uri.port).start{|http| http.request(req) } # resbody resbody = JSON.parse(res.body) puts resbody if resbody["code"].to_s == "0" puts "send succeed: #{resbody['message']}".green else puts "send error: #{resbody['message']}".red end end
validate!()
click to toggle source
businrss
Calls superclass method
# File lib/maptool/release/release.rb, line 67 def validate! super puts "podfile 为空".red unless self.podfile puts "sender 为空".red unless self.sender self.banner! unless self.podfile && self.sender end
Private Instance Methods
check(line)
click to toggle source
# File lib/maptool/release/release.rb, line 96 def check (line) pods.each { |pod| if line.include?(pod) pods.delete(pod) line.split(',').each { |item| if item.include?("tag") return "#{pod}, #{item.chomp}" end } end } return nil end