Skip to content

Commit 15daf67

Browse files
authored
Merge pull request #492 from BobbyMcWho/remove-blacklist-whitelist
Remove references to blacklists and whitelists
2 parents 65a8137 + 3dfa27f commit 15daf67

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class Response < Hashie::Mash
532532
end
533533
```
534534

535-
Disable warnings will honor the last `disable_warnings` call. Calling without parameters will override the blacklist, and calling with parameters will create a new blacklist. This includes child classes that inherit from a class that disables warnings.
535+
Disable warnings will honor the last `disable_warnings` call. Calling without parameters will override the ignored methods list, and calling with parameters will create a new ignored methods list. This includes child classes that inherit from a class that disables warnings.
536536

537537
```ruby
538538
class Message < Hashie::Mash
@@ -633,10 +633,10 @@ mash[1] #=> { name: 'John', lastname: 'Doe' }
633633

634634
The `Mash#load` method calls `YAML.safe_load(path, [], [], true)`.
635635

636-
Specify `whitelist_symbols`, `whitelist_classes` and `aliases` options as needed.
636+
Specify `permitted_symbols`, `permitted_classes` and `aliases` options as needed.
637637

638638
```ruby
639-
Mash.load('data/user.csv', whitelist_classes: [Symbol], whitelist_symbols: [], aliases: false)
639+
Mash.load('data/user.csv', permitted_classes: [Symbol], permitted_symbols: [], aliases: false)
640640
```
641641

642642
### Mash Extension: KeepOriginalKeys

UPGRADING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ There shouldn't really be a case that anyone was relying on catching this specif
5050

5151
The `Hashie::Mash#load` method now accepts options, changing the interface of `Parser#initialize`. If you have a custom parser, you must update its `initialize` method.
5252

53-
For example, `Hashie::Extensions::Parsers::YamlErbParser` now accepts `whitelist_classes`, `whitelist_symbols` and `aliases` options.
53+
For example, `Hashie::Extensions::Parsers::YamlErbParser` now accepts `permitted_classes`, `permitted_symbols` and `aliases` options.
5454

5555
Before:
5656

@@ -76,7 +76,7 @@ end
7676
Options can now be passed into `Mash#load`.
7777

7878
```ruby
79-
Mash.load(filename, whitelist_classes: [])
79+
Mash.load(filename, permitted_classes: [])
8080
```
8181

8282
### Upgrading to 3.5.2

lib/hashie/extensions/key_conflict_warning.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def disable_warnings?(method_key = nil)
3434
@disable_warnings ||= false
3535
end
3636

37-
# Returns an array of blacklisted methods that this class disables warnings for.
37+
# Returns an array of methods that this class disables warnings for.
3838
#
3939
# @api semipublic
4040
# @return [Boolean]

lib/hashie/extensions/parsers/yaml_erb_parser.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ def initialize(file_path, options = {})
1515
def perform
1616
template = ERB.new(@content)
1717
template.filename = @file_path
18-
whitelist_classes = @options.fetch(:whitelist_classes) { [] }
19-
whitelist_symbols = @options.fetch(:whitelist_symbols) { [] }
18+
permitted_classes = @options.fetch(:permitted_classes) { [] }
19+
permitted_symbols = @options.fetch(:permitted_symbols) { [] }
2020
aliases = @options.fetch(:aliases) { true }
21-
YAML.safe_load template.result, whitelist_classes, whitelist_symbols, aliases
21+
# TODO: Psych in newer rubies expects these args to be keyword args.
22+
YAML.safe_load template.result, permitted_classes, permitted_symbols, aliases
2223
end
2324

2425
def self.perform(file_path, options = {})

lib/hashie/mash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def initialize(source_hash = nil, default = nil, &blk)
103103

104104
# Creates a new anonymous subclass with key conflict
105105
# warnings disabled. You may pass an array of method
106-
# symbols to restrict the warnings blacklist to.
106+
# symbols to restrict the disabled warnings to.
107107
# Hashie::Mash.quiet.new(hash) all warnings disabled.
108108
# Hashie::Mash.quiet(:zip).new(hash) only zip warning
109109
# is disabled.

spec/hashie/mash_spec.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
expect(logger_output).to be_blank
177177
end
178178

179-
it 'writes to logger when a key is overridden that is not blacklisted' do
179+
it 'writes to logger when a key is overridden that is not ignored' do
180180
mash_class = Class.new(Hashie::Mash) do
181181
disable_warnings :merge
182182
end
@@ -185,7 +185,7 @@
185185
expect(logger_output).not_to be_blank
186186
end
187187

188-
it 'does not write to logger when a key is overridden that is blacklisted' do
188+
it 'does not write to logger when a key is overridden that is ignored' do
189189
mash_class = Class.new(Hashie::Mash) do
190190
disable_warnings :zip
191191
end
@@ -194,7 +194,7 @@
194194
expect(logger_output).to be_blank
195195
end
196196

197-
it 'carries over the disabled blacklist for warnings on grandchild classes' do
197+
it 'carries over the ignored warnings list for warnings on grandchild classes' do
198198
child_class = Class.new(Hashie::Mash) do
199199
disable_warnings :zip, :merge
200200
end
@@ -208,7 +208,7 @@
208208

209209
context 'multiple disable_warnings calls' do
210210
context 'calling disable_warnings multiple times with parameters' do
211-
it 'appends each new parameter to the blacklist' do
211+
it 'appends each new parameter to the ignore list' do
212212
child_class = Class.new(Hashie::Mash) do
213213
disable_warnings :zip
214214
disable_warnings :merge
@@ -220,7 +220,7 @@
220220
end
221221

222222
context 'calling disable_warnings without keys after calling with keys' do
223-
it 'uses the last call to ignore the blacklist' do
223+
it 'uses the last call to determine the ignore list' do
224224
child_class = Class.new(Hashie::Mash) do
225225
disable_warnings :zip
226226
disable_warnings
@@ -234,7 +234,7 @@
234234
end
235235

236236
context 'calling disable_parameters with keys after calling without keys' do
237-
it 'only ignores logging for the blacklisted methods' do
237+
it 'only ignores logging for ignored methods' do
238238
child_class = Class.new(Hashie::Mash) do
239239
disable_warnings
240240
disable_warnings :zip
@@ -795,30 +795,30 @@ class SubMash < Hashie::Mash
795795
end
796796

797797
context 'when the file has symbols' do
798-
it 'can override the value of whitelist_classes' do
799-
mash = Hashie::Mash.load('spec/fixtures/yaml_with_symbols.yml', whitelist_classes: [Symbol])
798+
it 'can override the value of permitted_classes' do
799+
mash = Hashie::Mash.load('spec/fixtures/yaml_with_symbols.yml', permitted_classes: [Symbol])
800800
expect(mash.user_icon.width).to eq(200)
801801
end
802-
it 'uses defaults for whitelist_classes' do
802+
it 'uses defaults for permitted_classes' do
803803
expect do
804804
Hashie::Mash.load('spec/fixtures/yaml_with_symbols.yml')
805805
end.to raise_error Psych::DisallowedClass, /Symbol/
806806
end
807-
it 'can override the value of whitelist_symbols' do
807+
it 'can override the value of permitted_symbols' do
808808
mash = Hashie::Mash.load('spec/fixtures/yaml_with_symbols.yml',
809-
whitelist_classes: [Symbol],
810-
whitelist_symbols: %i[
809+
permitted_classes: [Symbol],
810+
permitted_symbols: %i[
811811
user_icon
812812
width
813813
height
814814
])
815815
expect(mash.user_icon.width).to eq(200)
816816
end
817-
it 'raises an error on insufficient whitelist_symbols' do
817+
it 'raises an error on insufficient permitted_symbols' do
818818
expect do
819819
Hashie::Mash.load('spec/fixtures/yaml_with_symbols.yml',
820-
whitelist_classes: [Symbol],
821-
whitelist_symbols: %i[
820+
permitted_classes: [Symbol],
821+
permitted_symbols: %i[
822822
user_icon
823823
width
824824
])

0 commit comments

Comments
 (0)