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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57c0c8fb5737da67755dd7eb6736617ece8b31b7
4
- data.tar.gz: 3f53602929c2cbb6a99e69ab2f54ad7f17024dc7
3
+ metadata.gz: cd814bb3d6c501937b14cc58895910ecc022e500
4
+ data.tar.gz: 8035edd40c08bf9b4c5c6ee3f99f5cb381a9c3ed
5
5
  SHA512:
6
- metadata.gz: d3037df787128aee6fff83d936488f9870256f800c188ab935aa473ddb7b5c8d85f2ff225fdf75ecfb1c00e71bacc9b23397580ac5e7212c1b0f97c80b6029a2
7
- data.tar.gz: 244a0c3410d67d00a1cc62962f80828b25a39a7f414f61a1c6526e06b8bd92721f7af49f039c0b9a7abea2d69a839150ea8e071406e189e0aa17c8b86ae2386b
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
- :time with timestamp: [2014-10-28 12:33:11 +0200]
32
+ :np no default prefix
33
33
  :nl new line before the record
34
- :no no prefix at all
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. Rails initializers directory is a good place for it.
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
- redis: Redis.new,
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
@@ -25,6 +25,6 @@ WTF? data, :pp, :nl
25
25
 
26
26
  WTF? data, :json, :nl
27
27
 
28
- WTF? data, :yaml, :no, :file
28
+ WTF? data, :yaml, :np, :file
29
29
 
30
30
  data.wtf(:file).size
@@ -4,7 +4,7 @@ require 'fileutils'
4
4
  require 'csv'
5
5
 
6
6
  WTF.options = {
7
- :files => './wtf',
7
+ files: './wtf',
8
8
  }
9
9
 
10
10
  class Sample
@@ -1,15 +1,16 @@
1
1
  module WTF
2
2
  class Dumper
3
- PREFIX_OPTIONS = [:time, :nl, :no].freeze
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
@@ -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] = { :freq => 0, :time => 0.0, :heap => 0 } }
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]
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'wtf-tools'
3
- s.version = '1.0.2'
4
- s.date = '2014-10-14'
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.2
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: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: absolute_time