Ruby:安装一个 yanked gem(例如 OS X 10.9 上的 wkpdf)

Ruby: install a yanked gem (e.g. wkpdf on OS X 10.9)

我想按照 https://apple.stackexchange.com/questions/122176/convert-html-to-pdf-with-page-margins-and-hyperlinks, but, as per http://plessl.github.io/wkpdf/ and https://rubygems.org/gems/wkpdf 安装 wkpdf,gem "wkpdf" 是 "yanked",尽管它很可能仍处于工作状态.

% sudo gem install wkpdf
ERROR:  Could not find a valid gem 'wkpdf' (>= 0) in any repository
11.556u 0.437s 0:29.63 40.4%    0+0k 57+1io 363pf+0w

还有办法安装吗?我是 运行 OS X 10.9, gem -v returns 2.0,

该项目仍然在线:

https://github.com/plessl/wkpdf

您可以执行以下操作:

$ wget https://github.com/plessl/wkpdf/archive/v0.6.11.tar.gz
$ tar -xf v0.6.11.tar.gz
$ cd wkpdf-0.6.11
$ gem build wkpdf.gemspec
$ sudo gem install wkpdf-0.6.11-universal-darwin.gem

该网页似乎提供了对相关 gem 文件的引用:

% curl https://rubygems.org/gems/wkpdf |& fgrep Download
        <a id="download" class="gem__link t-list__item" href="/downloads/wkpdf-0.6.11-universal-darwin.gem">Download</a>

因此,只需对其执行 wget,它就可以在本地安装:

% wget https://rubygems.org/downloads/wkpdf-0.6.11-universal-darwin.gem

% sudo gem install wkpdf
Fetching: trollop-2.1.2.gem (100%)
Successfully installed trollop-2.1.2
Successfully installed wkpdf-0.6.11-universal-darwin
Parsing documentation for trollop-2.1.2
Installing ri documentation for trollop-2.1.2
Parsing documentation for wkpdf-0.6.11-universal-darwin
Installing ri documentation for wkpdf-0.6.11-universal-darwin
2 gems installed
2.603u 0.478s 0:15.32 20.0% 0+0k 186+56io 403pf+0w
% wkpdf
Cannot load RubyCocoa library
wkpdf requires that RubyCocoa is installed, which is shipped by default since
Mac OS X 10.5. If you use Mac OS X 10.4, you have to install RubyCocoa
yourself from http://rubycocoa.sourceforge.net/HomePage

但是,在 wkpdf 的特定情况下,它似乎还需要 RubyCocoa(根据 https://github.com/plessl/wkpdf/issues/45, first hit from http://www.google.ru/search?q=rubycocoa+10.9),它仅适用于 Ruby 1.8,而不是 2.0(它已成为 OS X 10.9 的默认设置,即使还安装了 Ruby 1.8)。

因此,必须从 2.0 卸载 wkpdf,然后安装到 1.8:

% sudo gem uninstall wkpdf

% sudo /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem install wkpdf
Successfully installed trollop-2.1.2
Successfully installed wkpdf-0.6.11-universal-darwin
2 gems installed
Installing ri documentation for trollop-2.1.2...
Installing ri documentation for wkpdf-0.6.11-universal-darwin...
Installing RDoc documentation for trollop-2.1.2...
Installing RDoc documentation for wkpdf-0.6.11-universal-darwin...
4.275u 0.252s 0:11.27 40.1% 0+0k 26+26io 3pf+0w
% wkpdf
Error: option --output must be specified.
Try --help for help.

总而言之,在 OS X 10.9:

wget https://rubygems.org/downloads/wkpdf-0.6.11-universal-darwin.gem

sudo /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem install wkpdf

wkpdf --source http://www.apple.com --output apple.wkpdf.pdf; open apple.wkpdf.pdf`