【问题标题】:Custom output with capistrano 3使用 capistrano 3 自定义输出
【发布时间】:2015-06-16 12:22:21
【问题描述】:

我需要更改使用 sshkit 格式化程序生成的输出,并且我无法安装其他 gem,但我可以调整我的 capistrano 3 配置。起初我尝试创建新的格式化程序(我只是复制粘贴漂亮的格式化程序,并进行了一些输出更改)。像这样https://gist.github.com/Dariusp/3e455fdb78b9f8636289 比 deploy.rb 文件中的set :format, :improvedformatter。并添加

 require_relative 'lib/improved_formatter'

到 Capfile。 但我总是得到错误“抽象格式化程序不应该直接使用,也许你想要 SSHKit::Formatter::BlackHole”,就像我正在尝试直接使用抽象格式化程序一样。如果我尝试扩展 PrettyFormater,我会得到 PrettyFormatter 输出,而无需进行更改。它似乎总是执行父类方法。有什么方法可以在我的 capistrano 配置中创建和设置自定义格式化程序?

【问题讨论】:

    标签: capistrano3 sshkit


    【解决方案1】:

    当我想覆盖漂亮的格式化程序时,我遇到了完全相同的问题。 问题是我还需要定义“

    在 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多