【发布时间】:2013-02-23 18:38:14
【问题描述】:
简单的问题;所以我在 capistrano 中的 deploy.rb 脚本看起来像这样,我可以在其中轻松使用 capture 功能:
namespace :mycompany do
def some_function()
mylog = capture("some_command")
end
desc <<-DESC
some task description
DESC
task :some_task do
mylog = capture("some_command")
end
end
但是,如果我在一个类中使用该方法,像这样:
namespace :mycompany do
class SomeClass
def self.some_static_method()
mylog = capture("some_command")
end
end
end
惨败:
/config/deploy.rb:120:in `some_static_method': undefined method `capture' for #<Class:0x000000026234f8>::SomeClass (NameError)
那该怎么做呢?这种方法似乎不是静态的 :( 它在里面(capistrano 来源):
module Capistrano
class Configuration
module Actions
module Inspect
# Executes the given command on the first server targetted by the
# current task, collects it's stdout into a string, and returns the
# string. The command is invoked via #invoke_command.
def capture(command, options={})
...
【问题讨论】:
标签: ruby deployment capistrano