Commit Graph

9 Commits

Author SHA1 Message Date
Koichi ITO 3e8760652c Suppress `Psych.safe_load` arg warn when using Psych 3.1.0+
This PR suppresses the following `Psych.safe_load` args warn when using
Psych 3.1.0 (Ruby 2.6+).

```console
% bundle exec rake spec
(snip)

/Users/koic/src/github.com/intridea/hashie/lib/hashie/extensions/parsers/yaml_erb_parser.rb:22:
Passing permitted_classes with the 2nd argument of Psych.safe_load is
deprecated. Use keyword argument like Psych.safe_load(yaml,
permitted_classes: ...) instead.
/Users/koic/src/github.com/intridea/hashie/lib/hashie/extensions/parsers/yaml_erb_parser.rb:22:
Passing permitted_symbols with the 3rd argument of Psych.safe_load is
deprecated. Use keyword argument like Psych.safe_load(yaml,
permitted_symbols: ...) instead.
/Users/koic/src/github.com/intridea/hashie/lib/hashie/extensions/parsers/yaml_erb_parser.rb:22:
Passing aliases with the 4th argument of Psych.safe_load is
deprecated. Use keyword argument like Psych.safe_load(yaml, aliases:
...) instead
```
2020-01-13 12:46:15 +09:00
Bobby McDonald 3dfa27f119
Remove references to blacklists and whitelists 2019-10-25 20:27:26 -04:00
Daniel Doubrovkine (dB.) @dblockdotorg 30ab2a3cb0 Allow options on Mash.load (#474)
`Mash.load` uses the Ruby standard library to load Yaml-serialized files
into a Mash. The original implementation used `YAML.load` for this
purpose. However, that method is inherently unsafe so we switched to
using `YAML.safe_load`.

Safely loading Yaml files has many different domain-specific
configuration flags that we did not, by default, expose. This change
introduces the ability to configure the safe loading of Yaml files so
that all types of Yaml can be loaded when necessary using the flags from
the standard library.

This implementation preserves the backwards-compatibility with the prior
implementation so that it should not require updates from users of the
current `Mash.load` behavior. For those who this change affects, we
included upgrading documentation to ease the transition.
2019-03-22 14:04:22 -05:00
Michael Herold a59d200849
Fix a regression with aliases on `Mash.load`
Also, reorganize the test into the existing file and update the
changelog.
2018-08-14 21:33:09 -05:00
Michael Herold 5a6ffc7e2d
Update Rubocop and address the addressable todos
This is a big step forward in our Rubocop setup. I addressed all of the todos
from the current version of Rubocop that made sense to. The only things that
remain are metrics and one cop that relies on the line length metric to work.

I made some judgment calls on disabling a few cops:

1. The `Layout/IndentHeredoc` cop wants you to either use the squiggly heredoc
   from Ruby 2.3 or introduce a library. Since we are a low-level library that
   is used as a transitive dependency, we cannot introduce another library as a
   dependence, so that option is out. Also, we support Rubies back to 2.0
   currently, so using the squiggly heredoc isn't an option. Once we remove
   support for Rubies older than 2.3, we can switch to the squiggly heredoc cop.
2. The `Naming/FileName` cop was reporting false positives for a few files in
   the repository, so I disabled it on those files.
3. The `Style/DoubleNegation` cop reports lints on a few cases where we use
   double negation. Given the very generic nature of Hashie, the double-negation
   is the easiest, clearest way to express that we want an item to be a Boolean.
   I disabled the cop because we exist in the gray area where this makes sense.
2018-06-17 11:04:56 -05:00
Takafumi ONAKA df47280851 Fix: NameError (uninitialized constant Hashie::Extensions::Parsers::YamlErbParser::Pathname)
`Hashie::Mash.load` require `Pathname` since v3.4.5.

see: bbafaded9d

```
irb(main):001:0> require "hashie"
=> true
irb(main):002:0> Hashie::Mash.load("foo.yml")
Traceback (most recent call last):
        6: from /opt/rubies/2.6.0-dev/bin/irb:11:in `<main>'
        5: from (irb):2
        4: from /Users/onaka/.gem/ruby/2.6.0/gems/hashie-3.5.7/lib/hashie/mash.rb:105:in `load'
        3: from /Users/onaka/.gem/ruby/2.6.0/gems/hashie-3.5.7/lib/hashie/extensions/parsers/yaml_erb_parser.rb:19:in `perform'
        2: from /Users/onaka/.gem/ruby/2.6.0/gems/hashie-3.5.7/lib/hashie/extensions/parsers/yaml_erb_parser.rb:19:in `new'
        1: from /Users/onaka/.gem/ruby/2.6.0/gems/hashie-3.5.7/lib/hashie/extensions/parsers/yaml_erb_parser.rb:9:in `initialize'
NameError (uninitialized constant Hashie::Extensions::Parsers::YamlErbParser::Pathname)
irb(main):003:0> require "pathname"
=> true
irb(main):004:0> Hashie::Mash.load("foo.yml")
=> #<Hashie::Mash bar="baz">
```
2018-02-08 10:51:18 +09:00
Atsushi Ishida bbafaded9d Hashie::Mash.load accepts a Pathname object. Closes #331.
https://github.com/intridea/hashie/issues/331
2016-07-15 11:56:55 -04:00
Julien Pervillé 104e3200c9 Extend YamlErbParser to understand __FILE__ when interpolating ERB. 2014-09-16 10:51:54 +02:00
gregory 59069f13ea Added Mash#load with YAML file support. 2014-07-14 07:31:34 -04:00