小编Ast*_*ery的帖子

如何要求不在`lib`目录下的`gem`文件?

我想为我的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)

ruby rubygems rspec rubocop

7
推荐指数
2
解决办法
2730
查看次数

PHP-CLI如何写入用户输入?

我想获得预定义的用户输入.

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)

怎么实现?

php command-line-interface

5
推荐指数
1
解决办法
267
查看次数

如何在 KeepassXC 自动输入功能中使用用户定义的属性?

我想问一下关于 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。

谢谢你的支持。

linux keepass

2
推荐指数
1
解决办法
3420
查看次数

标签 统计

command-line-interface ×1

keepass ×1

linux ×1

php ×1

rspec ×1

rubocop ×1

ruby ×1

rubygems ×1