项目中需要用到 caracal-1.4.1 这个 gem,我发现它依赖 rubyzip 的版本是 1.1,但是因为跟 axlsx 依赖 rubyzip 的版本有冲突,故我的第一想法就是手动改 caracal 这个 gem 的依赖版本跟 axlsx 一样。 实操步骤,首先下载 caracal-1.4.1 这个 gem,利用 gem unpack caracal-1.4.1.gem,解压得到源码,修改 caracal.gemspec 内的依赖关系,然后在执行 gem build caracal.gemspec,报了一些警告如下:
WARNING: no files specified
WARNING: open-ended dependency on tilt (>= 1.4) is not recommended
if tilt is semantically versioned, use:
add_runtime_dependency 'tilt', '~> 1.4'
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: caracal
Version: 1.4.1
File: caracal-1.4.1.gem
caracal.gemspec 的内容如下
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'caracal/version'
Gem::Specification.new do |spec|
spec.name = 'caracal'
spec.version = Caracal::VERSION
spec.authors = ['Trade Infomatics', 'John Dugan']
spec.email = ['[email protected]']
spec.summary = %q{ Fast, professional Microsoft Word (docx) writer for Ruby. }
spec.description = %q{ Caracal is a pure Ruby Microsoft Word generation library that produces professional quality MSWord documents (docx) using a simple, HTML-style DSL. }
spec.homepage = 'https://github.com/trade-informatics/caracal'
spec.license = 'MIT'
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']
spec.add_dependency 'nokogiri', '~> 1.6'
spec.add_dependency 'rubyzip', '~> 1.1' //我修改的地方,改成了'~> 1.0.0'
spec.add_dependency 'tilt', '>= 1.4'
spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rspec', '~> 3.0'
end
然后比较了下原始大小和重新生成的大小相差好多,一个是 4608(重新生成的 gem 大小),一个是 108544(原始 gem 大小),请教下各位这是怎么回事