If I have a local gem (gemfile.gem) how can I get the name and version information from code or the command line without installing the gem.

Reason: I'm installing a user gem to validate it and want to uninstall it to clean up. User gem is not something I control so I can't depend on naming conventions.

CLI Solution:

```
gem spec gemfile.gem name
gem spec gemfile.gem version

```

Ruby Solution:

```
name = Psych.safe_load(`gem spec gemfile.gem name`).to_s
version = Psych.safe_load(`gem spec gemfile.gem version`, permitted_classes: [Gem::Version]).to_s
# Now you can uninstall the gem with
Gem::Uninstaller.new(name, {:version => version, :force => true}).uninstall

```