wtf-tools 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -5
- data/example/dump.rb +1 -1
- data/example/tracking.rb +1 -1
- data/lib/wtf/dumper.rb +4 -3
- data/lib/wtf/method_tracker.rb +1 -1
- data/wtf-tools.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd814bb3d6c501937b14cc58895910ecc022e500
|
4
|
+
data.tar.gz: 8035edd40c08bf9b4c5c6ee3f99f5cb381a9c3ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae70406ac25e7093a5953bce47b92a582270d6e74e26d27154287b7c23a2aafe8f2512a75ec350c452d1e17b500f50a6f20e9e86c90d583df3dc83c5daeefb5c
|
7
|
+
data.tar.gz: e737a3e0126265eac0cd0cba6640556b0374c19a3e67b7c0adcd1ac89086a4fb3ab5f15d44e1303d0fd31fbf1fd949f1dd5635744399b883c8f4a440055fb52d
|
data/README.md
CHANGED
@@ -29,9 +29,9 @@ Supported options
|
|
29
29
|
```
|
30
30
|
Prefix
|
31
31
|
(default) WTF (my_file_name/method_name:227):
|
32
|
-
:
|
32
|
+
:np no default prefix
|
33
33
|
:nl new line before the record
|
34
|
-
:
|
34
|
+
:time with timestamp: [2014-10-28 12:33:11 +0200]
|
35
35
|
|
36
36
|
Formatting
|
37
37
|
(default) simple Ruby inspect
|
@@ -131,13 +131,17 @@ This will add a `WTF?`-style dump in the default location, containing stacktrace
|
|
131
131
|
Configuration
|
132
132
|
-------------
|
133
133
|
|
134
|
-
Configure WTF before using the above-mentioned facilities.
|
134
|
+
Configure WTF before using the above-mentioned facilities.
|
135
|
+
Rails initializers directory is a good place to put it.
|
136
|
+
Subkeys of `output` must be lambdas taking one string argument. They are merged into default output options.
|
135
137
|
|
136
138
|
```ruby
|
137
139
|
WTF.options = {
|
138
|
-
default: Rails.logger,
|
139
140
|
files: "#{Rails.root}/log/wtf",
|
140
|
-
|
141
|
+
output: {
|
142
|
+
default: ->(data) { Rails.logger.info(data) },
|
143
|
+
redis: ->(data) { Redis.new.rpush(:wtf, data) },
|
144
|
+
}
|
141
145
|
}
|
142
146
|
|
143
147
|
require 'yaml' # to use :yaml option, etc
|
data/example/dump.rb
CHANGED
data/example/tracking.rb
CHANGED
data/lib/wtf/dumper.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
module WTF
|
2
2
|
class Dumper
|
3
|
-
PREFIX_OPTIONS = [:time, :nl, :
|
3
|
+
PREFIX_OPTIONS = [:time, :nl, :np].freeze
|
4
4
|
FORMAT_OPTIONS = [:pp, :yaml, :json, :text, :line, :csv].freeze
|
5
5
|
MODIFY_OPTIONS = [:bare].freeze
|
6
6
|
OUTPUT_OPTIONS = [:puts, :error, :file].freeze
|
7
7
|
|
8
8
|
OPTIONS = (PREFIX_OPTIONS + FORMAT_OPTIONS + MODIFY_OPTIONS + OUTPUT_OPTIONS).freeze
|
9
9
|
|
10
|
-
attr_reader :options
|
10
|
+
attr_reader :args, :options
|
11
11
|
|
12
12
|
def initialize(*args)
|
13
|
+
@args = args
|
13
14
|
@options = {}
|
14
15
|
while is_option?(args.last)
|
15
16
|
@options[args.pop] = true
|
@@ -29,9 +30,9 @@ module WTF
|
|
29
30
|
|
30
31
|
def prefix(args)
|
31
32
|
data = ''
|
32
|
-
return data if options[:no]
|
33
33
|
data << "\n" if options[:nl]
|
34
34
|
data << "[%s] " % Time.now if options[:time]
|
35
|
+
return data if options[:np]
|
35
36
|
data << if args[0].is_a?(Symbol)
|
36
37
|
args.shift.to_s.upcase
|
37
38
|
else
|
data/lib/wtf/method_tracker.rb
CHANGED
@@ -38,7 +38,7 @@ module WTF
|
|
38
38
|
attr_accessor :stats, :stack, :last_time, :last_heap
|
39
39
|
|
40
40
|
def reset_state
|
41
|
-
self.stats = Hash.new { |h,k| h[k] = { :
|
41
|
+
self.stats = Hash.new { |h,k| h[k] = { freq: 0, time: 0.0, heap: 0 } }
|
42
42
|
self.stack = [[nil, :top]]
|
43
43
|
self.last_time = AbsoluteTime.now
|
44
44
|
self.last_heap = GC.stat[:heap_length]
|
data/wtf-tools.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'wtf-tools'
|
3
|
-
s.version = '1.0.
|
4
|
-
s.date = '
|
3
|
+
s.version = '1.0.3'
|
4
|
+
s.date = '2016-07-01'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
6
|
s.required_ruby_version = Gem::Requirement.new(">= 2.0.0")
|
7
7
|
s.summary = 'tools for debugging and profiling Ruby on Rails projects'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wtf-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remigijus Jodelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: absolute_time
|