2016-11-16 49 views

回答

0

如果您有一個其中包含thor依賴項的gemspec文件,您可以使用bundler的控制檯。

cat limarka.gemspec 

(...) 

Gem::Specification.new do |spec| 
    (...) 
    spec.add_development_dependency "bundler", "~> 1.12" 
    (...) 
    spec.add_dependency "thor" 
    (...) 
end 

當你鍵入bundle console它將所有的gem依賴加載到一個控制檯你:

$ bundle console 
Resolving dependencies... 

現在運行托爾的行動,你將需要創建一個包含的類的實例行動。 ask的行動是從Thor::Shell::Basic,所以這裏的代碼來稱呼它:

irb(main):001:0> city = Thor::Shell::Basic.new.ask "Type name of your city:" 
Type name of your city: João Pessoa 
=> "João Pessoa" 
irb(main):002:0> city 
=> "João Pessoa" 
irb(main):003:0> 
相關問題