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 +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +8 -8
- data/lib/putter/configuration.rb +12 -9
- data/lib/putter/errors.rb +1 -1
- data/lib/putter/follower_data.rb +6 -6
- data/lib/putter/version.rb +1 -1
- data/lib/putter/watcher_data.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 504b551c265d3896f609a36f0492fe8734b6d19806d79caa22e32b7bca6af033
|
4
|
+
data.tar.gz: 1f00f4a645b5191ab44e1a6e0da551cc8a796777b030ef0872afb4fa7872a094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
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
|
-
# "
|
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.
|
145
|
+
config.methods_allowlist = [:to_s]
|
146
146
|
|
147
|
-
# "
|
148
|
-
# with the `
|
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.
|
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"`
|
data/lib/putter/configuration.rb
CHANGED
@@ -1,31 +1,34 @@
|
|
1
1
|
module Putter
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :allow_production, :
|
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
|
-
@
|
12
|
-
@
|
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
|
20
|
-
raise ::Putter::MethodConflictError unless (@
|
22
|
+
def methods_allowlist=(methods)
|
23
|
+
raise ::Putter::MethodConflictError unless (@methods_denylist & methods).empty?
|
21
24
|
|
22
|
-
@
|
25
|
+
@methods_allowlist = methods
|
23
26
|
end
|
24
27
|
|
25
|
-
def
|
26
|
-
raise ::Putter::MethodConflictError unless (@
|
28
|
+
def methods_denylist=(methods)
|
29
|
+
raise ::Putter::MethodConflictError unless (@methods_allowlist & methods).empty?
|
27
30
|
|
28
|
-
@
|
31
|
+
@methods_denylist = methods
|
29
32
|
end
|
30
33
|
|
31
34
|
private
|
data/lib/putter/errors.rb
CHANGED
data/lib/putter/follower_data.rb
CHANGED
@@ -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
|
15
|
-
return false if
|
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
|
33
|
-
::Putter.configuration.
|
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
|
37
|
-
::Putter.configuration.
|
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)
|
data/lib/putter/version.rb
CHANGED
data/lib/putter/watcher_data.rb
CHANGED
@@ -26,15 +26,15 @@ module Putter
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def methods_to_proxy(singleton_klass)
|
29
|
-
ignored_methods = Putter.configuration.
|
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
|
-
|
35
|
+
allowlist = Putter.configuration.methods_allowlist.map(&:to_sym) + [:new]
|
36
36
|
|
37
|
-
singleton_klass.instance_methods - ignored_methods +
|
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.
|
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:
|
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.
|
140
|
+
rubygems_version: 3.3.7
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Putter makes puts debugging easy.
|