Class: MapTool::Release
- Defined in:
- lib/maptool/release/release.rb
Overview
Usage
Constant Summary
Constants inherited from Command
Instance Attribute Summary collapse
-
#content ⇒ Object
默认内容.
-
#podfile ⇒ Object
文件路径.
-
#pods ⇒ Object
pod 库.
-
#sender ⇒ Object
发送者员工号.
Class Method Summary collapse
Instance Method Summary collapse
- #gitPull ⇒ Object
-
#initialize(argv) ⇒ Release
constructor
初始化.
- #run ⇒ Object
- #send ⇒ Object
-
#validate! ⇒ Object
businrss.
Constructor Details
#initialize(argv) ⇒ Release
初始化
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# 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 |
Instance Attribute Details
#content ⇒ Object
默认内容
35 36 37 |
# File 'lib/maptool/release/release.rb', line 35 def content @content end |
#podfile ⇒ Object
文件路径
32 33 34 |
# File 'lib/maptool/release/release.rb', line 32 def podfile @podfile end |
#pods ⇒ Object
pod 库
33 34 35 |
# File 'lib/maptool/release/release.rb', line 33 def pods @pods end |
#sender ⇒ Object
发送者员工号
34 35 36 |
# File 'lib/maptool/release/release.rb', line 34 def sender @sender end |
Class Method Details
.options ⇒ Object
25 26 27 28 29 30 |
# File 'lib/maptool/release/release.rb', line 25 def self. [['--sender', '发送者员工号,如D11221,必须是群内人员'], ['--podfile', '包含 pods 库的 Podfile 路径'], ['--pods', "pods 库,“,”分割。默认地图事业部的库"], ['--content', "内容,默认“@所有人 有更新吗?今天发版,请尽快确认 Tag。”"]] + super end |
Instance Method Details
#gitPull ⇒ Object
89 90 91 92 93 94 |
# 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 ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# 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 ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# 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! ⇒ Object
businrss
67 68 69 70 71 72 |
# File 'lib/maptool/release/release.rb', line 67 def validate! super puts "podfile 为空".red unless self.podfile puts "sender 为空".red unless self.sender self. unless self.podfile && self.sender end |