È possibile verificare le specifiche della gemma per verificare se è stato definito extensions
. Dovete scaricare la gemma o controllare la sua fonte per fare questo, ma è non difficile da fare a livello di codice con un po 'di unix-fu:
curl -L <gem-url> | tar xOf - metadata.gz | gunzip | ruby -r yaml -e 'p YAML.load($stdin.read).extensions.any?'
Confrontiamo bson & bson_ext (dato che sono il primo non versioni -C-estensione e C-estensione dello stesso gioiello mi veniva in mente):
% curl -L https://rubygems.org/downloads/bson-1.8.0.gem | tar xOf - metadata.gz | gunzip | ruby -r yaml -e 'p YAML.load($stdin.read).extensions.any?'
false
% curl -L https://rubygems.org/downloads/bson_ext-1.8.0.gem | tar xOf - metadata.gz | gunzip | ruby -r yaml -e 'p YAML.load($stdin.read).extensions.any?'
true
Si potrebbe automatizzare la necessità di conoscere la versione attuale della gemma usando il RubyGems API:
curl https://rubygems.org/api/v1/gems/bson.yaml | ruby -r yaml -e 'p YAML.load($stdin.read)["version"]'
fonte
2012-12-10 01:15:41