Ai
4 Star 37 Fork 11

Gitee 极速下载/DevDocs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/freeCodeCamp/devdocs
克隆/下载
console.thor 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
Thibaut 提交于 2013-10-25 02:25 +08:00 . Going open source
require 'pry'
class ConsoleCLI < Thor
def self.to_s
'Console'
end
def initialize(*args)
trap('INT') { puts; exit } # exit on ^C
super
end
default_command :default
desc '', 'Start a REPL'
def default
Pry.start
end
desc 'docs', 'Start a REPL in the "Docs" module'
def docs
require 'docs'
Docs.pry
end
end
Pry::Commands.create_command 'test' do
description 'Run tests in the "test" directory'
group 'Testing'
banner <<-BANNER
Usage: test [<path>]
If <path> is a file, run it ("_test.rb" suffix is optional).
If <path> is a directory, run all test files inside it.
Default to all test files.
BANNER
def process
if pattern = args.first
pattern.prepend 'test/'
if File.directory?(pattern)
pattern << '/**/*_test.rb'
elsif File.extname(pattern).empty?
pattern << '*_test.rb'
end
else
pattern = 'test/**/*_test.rb'
end
paths = Dir.glob(pattern).map(&File.method(:expand_path))
if paths.empty?
output.puts 'No test files found.'
return
end
pid = fork do
begin
$LOAD_PATH.unshift 'test'
paths.each(&method(:require))
rescue Exception => e
_pry_.last_exception = e
run 'wtf?'
exit!
end
end
Process.wait(pid)
end
end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Ruby
1
https://gitee.com/mirrors/DevDocs.git
git@gitee.com:mirrors/DevDocs.git
mirrors
DevDocs
DevDocs
main

搜索帮助