我想为我的rubocop自定义警察编写规范.这个宝石有这里定义的方便助手.我想要它.怎么实现什么?
我试过使用Gem.find_files,这使我能够要求该gem中的任何文件,但只能在lib目录下.
例如:
# this requires ...gems/rubocop-0.29.1/lib/rubocop/formatter/formatter_set.rb
require Gem.find_files('rubocop/formatter/formatter_set.rb').first
# but I need ...gems/rubocop-0.29.1/spec/support/cop_helper.rb
Run Code Online (Sandbox Code Playgroud)
以下描述了我需要它的原因.我有spec/rubocop/my_custom_cop_spec.rb
require 'spec_helper'
require ? # What I should I write?
RSpec.describe RuboCop::Cop::Style::MyCustomCop do
it 'some test' do
inspect_source(cop, 'method(arg1, arg2)') # This helper I want to use from rubocop spec helpers
end
end
Run Code Online (Sandbox Code Playgroud)
当我尝试普通要求时:
require 'rubocop/spec/support/cop_helper'
Run Code Online (Sandbox Code Playgroud)
我收到错误:
/home/user/.gem/ruby/2.0.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274
:in `require': cannot load such file -- rubocop/spec/support/cop_helper
Run Code Online (Sandbox Code Playgroud) 我想获得预定义的用户输入.
echo 'Enter value: ';
# here write some 'default value'
$value = fgets(STDIN);
Run Code Online (Sandbox Code Playgroud)
那么用户得到提示,他就可以编辑输入.
Enter value: default value # Here we can backslash and write new one.
Run Code Online (Sandbox Code Playgroud)
怎么实现?
我想问一下关于 Keepass 自动输入的问题。
我想开始在自动类型中使用附加属性。
command: eval "$(ssh-agent -s)" && ssh-add
and use it in keepas like:
{COMMAND}{PASSWORD}{ENTER}
Run Code Online (Sandbox Code Playgroud)
在这种情况下你能帮我吗?我在 Linux 上使用 KeePassXC。
谢谢你的支持。