我读到我们shouldn't package test files with a Ruby Gem。
现在我想知道,我们是否应该打包Gemspec。
例如,给定以下Ruby Gem:
tree .
.
├── LICENSE.txt
├── README.md
├── lib
│ └── simplegem.rb
├── simplegem.gemspec
└── test
├── simplegem_test.rb
└── thing_test.rb
2 directories, 6 files
我的Gem::Specification应该是这样的:
$LOAD_PATH.unshift 'lib'
require 'simplegem'
Gem::Specification.new do |s|
s.name = 'simplegem'
s.version = Simplegem::VERSION
s.licenses = ['MIT']
s.summary = 'This is a simple gem!'
s.description = 'Much longer explanation of the simple gem!'
s.authors = ['...']
s.email = '...'
s.files = %w(simplegem.gemspec
LICENSE.txt
README.md
lib/simplegem.rb)
s.homepage = 'https://github.com/mbigras'
end
或者:
$LOAD_PATH.unshift 'lib'
require 'simplegem'
Gem::Specification.new do |s|
s.name = 'simplegem'
s.version = Simplegem::VERSION
s.licenses = ['MIT']
s.summary = 'This is a simple gem!'
s.description = 'Much longer explanation of the simple gem!'
s.authors = ['...']
s.email = '...'
s.files = %w(LICENSE.txt
README.md
lib/simplegem.rb)
s.homepage = 'https://github.com/mbigras'
end
注意第一个包含simplegem.gemspec
数组中的s.files
,第二个包含"1","[('1012', 5), ('1046', 5), ('1052', 5), ('1056', 4.9910199299984184), ('1030', 4.8534167927670344), ('1040', 4.8212814442619543), ('1035', 4.7661155679960796), ('1034', 4.6870279945429703), ('1042', 4.5541209598953358), ('1027', 4.5151900893812948)]"
"2","[('1049', 5), ('1016', 4.6133266327772251), ('1010', 4.5357481760897569), ('1046', 4.3349671883556038), ('1050', 4.3227509505599846), ('1037', 4.2902806273386966), ('1041', 4.2507193844291828), ('1053', 4.0984615265310147), ('1009', 4.098439317076469), ('1030', 4.0)]"
"3","[('1012', 4.9811840834706604), ('1016', 4.8312378650104533), ('1041', 4.7528923569042405), ('1049', 4.5049427949269853), ('1050', 4.3853256507131384), ('1045', 4.1598878939000565), ('1005', 4.1014830595313585), ('1022', 4.0958233778390403), ('1054', 4.0854105427315339), ('1024', 4.061922071985868)]"
数组。
答案 0 :(得分:2)
没有必要使用Ruby宝石包装Gemspec,在我的一个宝石家中安装的宝石调查中,我注意到实际上大多数宝石都没有包含gemspec文件:
~/.rvm/gems/ruby-2.3.7/gems $ find . -name \*.gemspec | wc -l
95
~/.rvm/gems/ruby-2.3.7@happy-backend/gems $ ls | wc -l
318
你为什么不打包?
为什么打包?
$GEM_HOME/specifications
文件夹