putter 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4bb34206f87355ec6413702f263574ba0ea9f45fbf01da9578af7c899d4bbe0d
4
- data.tar.gz: 444c407875667ffcc61d8be7908faeb0e67cd2fc21c2b87e0db45171dc1ac0ad
3
+ metadata.gz: 504b551c265d3896f609a36f0492fe8734b6d19806d79caa22e32b7bca6af033
4
+ data.tar.gz: 1f00f4a645b5191ab44e1a6e0da551cc8a796777b030ef0872afb4fa7872a094
5
5
  SHA512:
6
- metadata.gz: d928358ecf0442f8512988f46f7090e7faade53aea9e14c0419ebe2cf830a666d16bfb67a3ff5d789de9d83a7634464fe57a9134a7739c1451849b0fc257ca67
7
- data.tar.gz: a2fb566c1bf2b1f99e8f8cb681a97f3968259e6e7e502341ba8dbd32b69ca127eaab24274e502d11e511da4c87270397bddc09cdc9b725c43386f99b8de284ba
6
+ metadata.gz: 829f154421ed19a1274fd0ca25256f933bf85c408aa152de0a4d0b17d708b969e3f1c4170ad02461425a1a9595a374aa0a67556c9627e346d7e0ed528242af95
7
+ data.tar.gz: 5713fc62de7b5e666979cf2c0b71d1e16f2d7d9ac17ba26c7004db6858917ea9ecd585c1ea0bd7ec7071e53e2d61bb2d79a068ceedf409e81a8775f2a350ba05
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # CHANGELOG
2
+ ### 0.7.0 - 2022-10-14
3
+ - Change whitelist/blacklist, to allowlist/denylist but maintain backwards
4
+ compatibility
5
+
2
6
  ### 0.6.1 - 2021-08-02
3
7
  - Update required ruby version to at least 2.7
4
- -
8
+
5
9
  ### 0.6.0 - 2021-08-02
6
10
  - Update required ruby version to 2.7
7
11
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Putter
2
2
 
3
- ### Still Maintained as of February 2020
3
+ ### Still Maintained as of October 2022
4
4
 
5
5
  ## Description
6
6
 
@@ -68,7 +68,7 @@ Putter.follow(
68
68
  # Will be "ClassName" for classes or "ClassName instance" for instances
69
69
  methods: ["my_method"], # Optional - If array is empty, then all methods will be watched.
70
70
  # Otherwise, this is an array of methods to print debugging input for. This will override
71
- # any settings in the configuration blacklist
71
+ # any settings in the configuration denylist
72
72
  )
73
73
  ```
74
74
 
@@ -111,7 +111,7 @@ Putter.watch(
111
111
  label: "My class", # Optional - Label to use after "Putter Debugging: My class". Will be "ClassName" for classes or "ClassName instance #" for instances
112
112
  methods: ["my_method"], # Optional - If array is empty, then all methods will be watched.
113
113
  # Otherwise, this is an array of methods to print debugging input for. This will override
114
- # any settings in the configuration blacklist
114
+ # any settings in the configuration denylist
115
115
  )
116
116
  ```
117
117
 
@@ -137,18 +137,18 @@ Putter.configure do |config|
137
137
  # Defaults to [Object] or [Object, ActiveRecord::Based] if defined
138
138
  config.ignore_methods_from = [Object, ActiveRecord::Base]
139
139
 
140
- # "methods_whitelist" takes an array of methods and will always proxy and debug those methods
140
+ # "methods_allowlist" takes an array of methods and will always proxy and debug those methods
141
141
  # regardless of whether or not the class is ignored and regardless of what methods are passed
142
142
  # in when running "Putter.follow" or "Putter.watch"
143
143
 
144
144
  # Defaults to []
145
- config.methods_whitelist = [:to_s]
145
+ config.methods_allowlist = [:to_s]
146
146
 
147
- # "methods_blacklist" takes an array of methods and will never proxy. If this is combined
148
- # with the `methods_whitelist` then it will raise a `MethodConflictError`.
147
+ # "methods_denylist" takes an array of methods and will never proxy. If this is combined
148
+ # with the `methods_allowlist` then it will raise a `MethodConflictError`.
149
149
 
150
150
  # Defaults to []
151
- config.methods_blacklist = [:to_s]
151
+ config.methods_denylist = [:to_s]
152
152
 
153
153
  # "allow_production" takes a boolean and determines whether or not Putter will run if
154
154
  # `Rails.env == "production"`
@@ -1,31 +1,34 @@
1
1
  module Putter
2
2
  class Configuration
3
- attr_accessor :allow_production, :methods_whitelist, :methods_blacklist, :print_strategy
3
+ attr_accessor :allow_production, :methods_allowlist, :methods_denylist, :print_strategy
4
4
  attr_writer :ignore_methods_from
5
5
 
6
+ alias_method :methods_whitelist=, :methods_allowlist=
7
+ alias_method :methods_blacklist=, :methods_denylist=
8
+
6
9
  def initialize
7
10
  @ignore_methods_from = [Object]
8
11
  @ignore_methods_from << ActiveRecord::Base if defined?(ActiveRecord::Base)
9
12
  @print_strategy = PrintStrategy::Default
10
13
  @allow_production = false
11
- @methods_whitelist = []
12
- @methods_blacklist = []
14
+ @methods_allowlist = []
15
+ @methods_denylist = []
13
16
  end
14
17
 
15
18
  def ignore_methods_from
16
19
  convert_to_array(@ignore_methods_from)
17
20
  end
18
21
 
19
- def methods_whitelist=(methods)
20
- raise ::Putter::MethodConflictError unless (@methods_blacklist & methods).empty?
22
+ def methods_allowlist=(methods)
23
+ raise ::Putter::MethodConflictError unless (@methods_denylist & methods).empty?
21
24
 
22
- @methods_whitelist = methods
25
+ @methods_allowlist = methods
23
26
  end
24
27
 
25
- def methods_blacklist=(methods)
26
- raise ::Putter::MethodConflictError unless (@methods_whitelist & methods).empty?
28
+ def methods_denylist=(methods)
29
+ raise ::Putter::MethodConflictError unless (@methods_allowlist & methods).empty?
27
30
 
28
- @methods_blacklist = methods
31
+ @methods_denylist = methods
29
32
  end
30
33
 
31
34
  private
data/lib/putter/errors.rb CHANGED
@@ -6,7 +6,7 @@ module Errors
6
6
  end
7
7
 
8
8
  class MethodConflictError < StandardError
9
- def initialize(msg="Methods cannot be white and blacklisted")
9
+ def initialize(msg="Methods cannot be allow and denylisted")
10
10
  super
11
11
  end
12
12
  end
@@ -11,8 +11,8 @@ module Putter
11
11
  def add_method?(method)
12
12
  return false if @proxy.instance_methods.include?(method)
13
13
  return true if @proxied_methods.include?(method)
14
- return true if is_whitelisted_method?(method)
15
- return false if is_blacklisted_method?(method)
14
+ return true if is_allowed_method?(method)
15
+ return false if is_denied_method?(method)
16
16
  return false if is_ignored_method?(method)
17
17
  return true if @proxied_methods.empty?
18
18
  end
@@ -29,12 +29,12 @@ module Putter
29
29
  end
30
30
  end
31
31
 
32
- def is_whitelisted_method?(method)
33
- ::Putter.configuration.methods_whitelist.map(&:to_sym).include?(method.to_sym)
32
+ def is_allowed_method?(method)
33
+ ::Putter.configuration.methods_allowlist.map(&:to_sym).include?(method.to_sym)
34
34
  end
35
35
 
36
- def is_blacklisted_method?(method)
37
- ::Putter.configuration.methods_blacklist.map(&:to_sym).include?(method.to_sym)
36
+ def is_denied_method?(method)
37
+ ::Putter.configuration.methods_denylist.map(&:to_sym).include?(method.to_sym)
38
38
  end
39
39
 
40
40
  def is_ignored_method?(method)
@@ -1,3 +1,3 @@
1
1
  module Putter
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -26,15 +26,15 @@ module Putter
26
26
  end
27
27
 
28
28
  def methods_to_proxy(singleton_klass)
29
- ignored_methods = Putter.configuration.methods_blacklist.map(&:to_sym)
29
+ ignored_methods = Putter.configuration.methods_denylist.map(&:to_sym)
30
30
 
31
31
  Putter.configuration.ignore_methods_from.each do |klass|
32
32
  ignored_methods += klass.methods
33
33
  end
34
34
 
35
- whitelist = Putter.configuration.methods_whitelist.map(&:to_sym) + [:new]
35
+ allowlist = Putter.configuration.methods_allowlist.map(&:to_sym) + [:new]
36
36
 
37
- singleton_klass.instance_methods - ignored_methods + whitelist
37
+ singleton_klass.instance_methods - ignored_methods + allowlist
38
38
  end
39
39
  end
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: putter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John DeWyze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-02 00:00:00.000000000 Z
11
+ date: 2022-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  requirements: []
140
- rubygems_version: 3.2.22
140
+ rubygems_version: 3.3.7
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: Putter makes puts debugging easy.