makandra / geordi

Collection of command line tools used in our daily work with Ruby, Rails and Linux.
https://makandra.com/
MIT License
104 stars 16 forks source link

use YAML.safe_load in dumple and allow aliases #175

Closed dastra-mak closed 2 years ago

dastra-mak commented 2 years ago

In v9.1.0 in noticed that the geordi dump command fails in projects that include YAML aliases in the database.yml file:

g dump

# Dumping the development database
Unknown alias: test

x Something went wrong.

database.yml:

development:
  adapter: postgresql
  encoding: unicode
  host: 127.0.0.1
  database: foo_development

test: &test
  adapter: postgresql
  encoding: unicode
  host: 127.0.0.1
  database: foo_test<%= ENV['TEST_ENV_NUMBER']%>

cucumber:
  <<: *test

In my project Psych v4.0.1 was used. The load method changed, to use safe_load instead. As the psych version is not fixed in geordi, I added a version switch that can cope with new and old versions.

codener commented 2 years ago

This change looks sane, thank you very much. One question though: Are you sure that Psych is available in each Ruby (2.5+) without any require?

dastra-mak commented 2 years ago

Yes, it is part of stdlib from 1.9.2 on (see https://github.com/ruby/psych#installation)