[英]Custom output with capistrano 3
我需要更改由sshkit格式化程序生成的輸出,並且無法安裝其他gems,但可以調整capistrano 3的配置。 首先,我嘗試僅創建新的Formatter(我只是復制粘貼漂亮的Formatter,並進行了一些輸出更改)。 像這樣https://gist.github.com/Dariusp/3e455fdb78b9f8636289而不是在deploy.rb文件中set :format, :improvedformatter
。 並添加
require_relative 'lib/improved_formatter'
到Capfile。 但是我總是收到錯誤消息“ 不應直接使用抽象格式化程序,也許您想要SSHKit :: Formatter :: BlackHole ”,就像我嘗試直接使用抽象格式化程序一樣。 如果我嘗試擴展PrettyFormater,我將得到PrettyFormatter輸出,而不進行任何更改。 似乎總是執行父類方法。 有沒有辦法在我的capistrano配置中創建和設置自定義格式器?
當我想覆蓋漂亮的格式化程序時,遇到了完全相同的問題。 問題是我還需要定義“ <<”運算符,因為它在基類中被定義為別名,並且別名不被繼承。
在deploy.rb中:
set :format, :myformatter
在Capfile中:
require 'lib/sshkit/formatters/myformatter'
在lib / sshkit / formatters / myformatter.rb中:
module SSHKit
module Formatter
class MyFormatter < Pretty
def <<(obj)
write(obj)
end
def write(obj)
...
end
end
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.