【问题标题】:What are `files`, `executables`, `test_files`, and `require_paths` in gemspec file?gemspec 文件中的 `files`、`executables`、`test_files` 和 `require_paths` 是什么?
【发布时间】:2014-08-07 19:12:40
【问题描述】:

我不清楚.gemspec 文件中的某些规范在做什么。具体来说,

spec.files         = `git ls-files -z`.split("\x0")
spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

谁能解释一下这些与 Ruby Gem 的功能有何关系以及为什么它们是必要的?

【问题讨论】:

    标签: ruby gem rubygems gemspecs


    【解决方案1】:

    executables:

    gem 中包含的可执行文件。例如,rake gem 将 rake 作为可执行文件。这些文件必须是可执行的 Ruby 文件。

    files:

    gem 中包含的文件。这些是构建时将包含在您的 gem 中的文件。

    require_paths:

    包含Array 的目录和文件,在 gem 激活时应将其添加到 $LOAD_PATH。默认为["lib"]

    test_files

    gem 中包含的测试文件。

    【讨论】:

    • 在 ruby​​ 2.2.0 中没有更多的test_files
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多