rails-callback_log 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails-callback_log.rb +51 -15
- data/lib/rails_callback_log/version.rb +1 -1
- data/rails-callback_log.gemspec +9 -4
- metadata +20 -13
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.travis.yml +0 -9
- data/CHANGELOG.md +0 -21
- data/CODE_OF_CONDUCT.md +0 -49
- data/README.md +0 -36
- data/Rakefile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f70470e5c23f303bedb00d4aa9f155189d5a76c
|
4
|
+
data.tar.gz: 950dfce87e83a6e5dd26aab9647084e3523df938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9825b7b8c62c752b2dc76340f3ac579dafde7cdf3fed39e52a57cddeba7f3f321cf09d70ceca48b49eaa1cc13ac1dbbd44e90eaa894eb662ad1ae8defeec6bd8
|
7
|
+
data.tar.gz: cc589b5cbcba867635aa4087d318bda6687387f70216a01683a65bebc6bbae2e9275e86f38b9c1a02ef4ec614e1741eefc73dea58a7e16823bf066fc010f733b
|
data/lib/rails-callback_log.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "rails_callback_log/version"
|
2
2
|
|
3
|
-
#
|
4
|
-
# continue, because we are going to overwrite it.
|
3
|
+
# Make sure `ActiveSupport::Callbacks` is loaded before we continue.
|
5
4
|
require "active_support/all"
|
6
5
|
|
7
6
|
module RailsCallbackLog
|
@@ -10,6 +9,18 @@ module RailsCallbackLog
|
|
10
9
|
FILTER = ENV["RAILS_CALLBACK_LOG_FILTER"].present?.freeze
|
11
10
|
|
12
11
|
class << self
|
12
|
+
def assert_method_not_defined(klass, method)
|
13
|
+
if klass.method_defined?(method.to_sym)
|
14
|
+
$stderr.puts(
|
15
|
+
format(
|
16
|
+
"Unable to install rails-callback_log: method already exists: %s",
|
17
|
+
method
|
18
|
+
)
|
19
|
+
)
|
20
|
+
::Kernel.exit(1)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
13
24
|
def matches_filter?(str)
|
14
25
|
source_location_filters.any? { |f| str.start_with?(f) }
|
15
26
|
end
|
@@ -22,25 +33,50 @@ module RailsCallbackLog
|
|
22
33
|
end
|
23
34
|
|
24
35
|
module CallbackExtension
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
def _rails_cb_log(caller, message)
|
37
|
+
if !::RailsCallbackLog::FILTER ||
|
38
|
+
caller.any? { |line| ::RailsCallbackLog.matches_filter?(line) }
|
39
|
+
::Rails.logger.debug(format("Callback: %s", message))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
if ::ActiveSupport.gem_version >= ::Gem::Version.new("5.1.0")
|
44
|
+
# Returns a lambda that wraps `super`, adding logging.
|
45
|
+
def make_lambda
|
46
|
+
original_lambda = super
|
47
|
+
lambda { |*args, &block|
|
48
|
+
_rails_cb_log(caller, @method_name)
|
49
|
+
original_lambda.call(*args, &block)
|
50
|
+
}
|
51
|
+
end
|
52
|
+
else
|
53
|
+
# Returns a lambda that wraps `super`, adding logging.
|
54
|
+
def make_lambda(filter)
|
55
|
+
original_lambda = super(filter)
|
56
|
+
lambda { |*args, &block|
|
57
|
+
_rails_cb_log(caller, filter)
|
58
|
+
original_lambda.call(*args, &block)
|
59
|
+
}
|
60
|
+
end
|
36
61
|
end
|
37
62
|
end
|
38
63
|
end
|
39
64
|
|
65
|
+
# Install our `CallbackExtension` using module prepend.
|
40
66
|
module ActiveSupport
|
41
67
|
module Callbacks
|
42
|
-
|
43
|
-
|
68
|
+
# In rails 4.2 and 5.0, `make_lambda` is a method of `Callback`.
|
69
|
+
# In rails 5.1, `make_lambda` is a method of `CallTemplate`.
|
70
|
+
if ::ActiveSupport.gem_version >= ::Gem::Version.new("5.1.0")
|
71
|
+
::RailsCallbackLog.assert_method_not_defined(CallTemplate, :_rails_cb_log)
|
72
|
+
class CallTemplate
|
73
|
+
prepend ::RailsCallbackLog::CallbackExtension
|
74
|
+
end
|
75
|
+
else
|
76
|
+
::RailsCallbackLog.assert_method_not_defined(Callback, :_rails_cb_log)
|
77
|
+
class Callback
|
78
|
+
prepend ::RailsCallbackLog::CallbackExtension
|
79
|
+
end
|
44
80
|
end
|
45
81
|
end
|
46
82
|
end
|
data/rails-callback_log.gemspec
CHANGED
@@ -11,12 +11,17 @@ require "rails_callback_log/version"
|
|
11
11
|
spec.summary = "Logs callbacks to help with debugging."
|
12
12
|
spec.homepage = "https://github.com/jaredbeck/rails-callback_log"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.files =
|
15
|
-
|
16
|
-
|
14
|
+
spec.files = [
|
15
|
+
"Gemfile", # necessary?
|
16
|
+
"LICENSE.txt", # because: lawyers
|
17
|
+
"lib/rails-callback_log.rb",
|
18
|
+
"lib/rails_callback_log/version.rb",
|
19
|
+
"rails-callback_log.gemspec"
|
20
|
+
]
|
17
21
|
spec.require_paths = ["lib"]
|
18
22
|
spec.required_ruby_version = ">= 2.0"
|
19
|
-
spec.add_runtime_dependency "activesupport", [">= 4.2.0", "< 5.
|
23
|
+
spec.add_runtime_dependency "activesupport", [">= 4.2.0", "< 5.2"]
|
24
|
+
spec.add_development_dependency "appraisal", "~> 2.2"
|
20
25
|
spec.add_development_dependency "bundler", "~> 1.12"
|
21
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
27
|
spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-callback_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Beck
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 4.2.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,21 @@ dependencies:
|
|
29
29
|
version: 4.2.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
32
|
+
version: '5.2'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: appraisal
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.2'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.2'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: bundler
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,15 +93,8 @@ executables: []
|
|
79
93
|
extensions: []
|
80
94
|
extra_rdoc_files: []
|
81
95
|
files:
|
82
|
-
- ".gitignore"
|
83
|
-
- ".rspec"
|
84
|
-
- ".travis.yml"
|
85
|
-
- CHANGELOG.md
|
86
|
-
- CODE_OF_CONDUCT.md
|
87
96
|
- Gemfile
|
88
97
|
- LICENSE.txt
|
89
|
-
- README.md
|
90
|
-
- Rakefile
|
91
98
|
- lib/rails-callback_log.rb
|
92
99
|
- lib/rails_callback_log/version.rb
|
93
100
|
- rails-callback_log.gemspec
|
@@ -111,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
118
|
version: '0'
|
112
119
|
requirements: []
|
113
120
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.6.10
|
115
122
|
signing_key:
|
116
123
|
specification_version: 4
|
117
124
|
summary: Logs callbacks to help with debugging.
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
This gem conforms to [semver 2.0.0][1] and follows the recommendations of
|
4
|
-
[keepachangelog.com][2].
|
5
|
-
|
6
|
-
### 0.1.0 (2016-07-25)
|
7
|
-
|
8
|
-
Breaking changes:
|
9
|
-
|
10
|
-
- Drop support for ruby 1.9.3
|
11
|
-
|
12
|
-
Added:
|
13
|
-
|
14
|
-
- Support for rails 5.0
|
15
|
-
|
16
|
-
### 0.0.3 (2016-06-24)
|
17
|
-
|
18
|
-
Initial release, support for rails 4.2 only.
|
19
|
-
|
20
|
-
[1]: http://semver.org/
|
21
|
-
[2]: http://keepachangelog.com/
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, and in the interest of
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
7
|
-
|
8
|
-
We are committed to making participation in this project a harassment-free
|
9
|
-
experience for everyone, regardless of level of experience, gender, gender
|
10
|
-
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
-
body size, race, ethnicity, age, religion, or nationality.
|
12
|
-
|
13
|
-
Examples of unacceptable behavior by participants include:
|
14
|
-
|
15
|
-
* The use of sexualized language or imagery
|
16
|
-
* Personal attacks
|
17
|
-
* Trolling or insulting/derogatory comments
|
18
|
-
* Public or private harassment
|
19
|
-
* Publishing other's private information, such as physical or electronic
|
20
|
-
addresses, without explicit permission
|
21
|
-
* Other unethical or unprofessional conduct
|
22
|
-
|
23
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
-
threatening, offensive, or harmful.
|
28
|
-
|
29
|
-
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
-
fairly and consistently applying these principles to every aspect of managing
|
31
|
-
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
-
Conduct may be permanently removed from the project team.
|
33
|
-
|
34
|
-
This code of conduct applies both within project spaces and in public spaces
|
35
|
-
when an individual is representing the project or its community.
|
36
|
-
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported by contacting a project maintainer at jared@jaredbeck.com. All
|
39
|
-
complaints will be reviewed and investigated and will result in a response that
|
40
|
-
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
-
incident.
|
43
|
-
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
-
version 1.3.0, available at
|
46
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
-
|
48
|
-
[homepage]: http://contributor-covenant.org
|
49
|
-
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/README.md
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# RailsCallbackLog
|
2
|
-
|
3
|
-
Logs callbacks to help with debugging.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
# Gemfile
|
9
|
-
gem "rails-callback_log", group: [:development, :test]
|
10
|
-
```
|
11
|
-
|
12
|
-
Do not use this gem in production because it adds significant overhead.
|
13
|
-
|
14
|
-
## Filtering Output
|
15
|
-
|
16
|
-
Rails has a lot of its own callbacks that you probably don't care about. If you
|
17
|
-
don't want to log them, enable filtering.
|
18
|
-
|
19
|
-
```
|
20
|
-
# Enable filtering
|
21
|
-
export RAILS_CALLBACK_LOG_FILTER="make it so"
|
22
|
-
|
23
|
-
# Disable filtering
|
24
|
-
unset RAILS_CALLBACK_LOG_FILTER
|
25
|
-
```
|
26
|
-
|
27
|
-
Filtering incurs a serious performance penalty, so it is off by default.
|
28
|
-
|
29
|
-
## See Also
|
30
|
-
|
31
|
-
- http://stackoverflow.com/q/13089936/567762
|
32
|
-
|
33
|
-
## License
|
34
|
-
|
35
|
-
The gem is available as open source under the terms of the [MIT
|
36
|
-
License](http://opensource.org/licenses/MIT).
|