tracer-rb 0.1.0
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 +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +59 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/tracer.rb +19 -0
- data/lib/tracer/formatters/basic.rb +18 -0
- data/lib/tracer/set_trace_func.rb +22 -0
- data/lib/tracer/version.rb +3 -0
- data/tracer.gemspec +25 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b155175d7f066cd8464bbb71ecbb8c98f0347f3
|
4
|
+
data.tar.gz: 5c87d0f8331b72e7b739c3963d8bad461a6afc22
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e086ee54dd983da7ed3acc0015e39b6383c75fffa86f1ba4d17f827f8cd9189d1d1a722106bfbcbaaa5c958a8076f2a37da2696e448f16e93d8ca7a28bb1ce40
|
7
|
+
data.tar.gz: 6f7650fc07d977e7c9598e973039a92f7c1a21a0929731de35d9b7975b7505d3e4e5c8befd232b8accc3eae1a6e03ad2a6bd7f8dbbd536e7b4b8dbbd8e3877f8
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Julian Kulesh
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Tracer
|
2
|
+
[](https://travis-ci.org/raventid/tracer)
|
3
|
+
|
4
|
+
|
5
|
+
Tracer is a simple and fast tracer for your Ruby code. It follows your code line by line and deep dive into any gem source code to carefully inspect every method you call. Think - it's puts debugging on steroids.
|
6
|
+
|
7
|
+
It's very opinioned out of the box, but in the same time it tries really hard to be flexible, so you can adopt it to your tracing style.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'tracer'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install tracer
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
### Configuration
|
28
|
+
Tracer provides a few options you can configure:
|
29
|
+
- Show or not params for methods (for custom classes you can choose a strategie)
|
30
|
+
- Write output on screen or to file (also you can provide your custom strategie)
|
31
|
+
- How to handle fatal errors (few options)
|
32
|
+
|
33
|
+
You can skip setting it up, because Tracer provides saine defaults for every case.
|
34
|
+
|
35
|
+
|
36
|
+
Basic usage might look like:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Tracer::Runner.run do
|
40
|
+
MyLibrary.call("Hello")
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
```
|
45
|
+
Output:
|
46
|
+
-- call name: "Hello"
|
47
|
+
-- puts name
|
48
|
+
```
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
53
|
+
|
54
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/raventid/tracer.
|
59
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tracer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/tracer.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "tracer/version"
|
2
|
+
require "tracer/set_trace_func"
|
3
|
+
require "tracer/formatters/basic"
|
4
|
+
|
5
|
+
module Tracer
|
6
|
+
class Runner
|
7
|
+
def initialize(adapter=nil)
|
8
|
+
@adapter = adapter || SetTraceFunc.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
@adapter.run { yield }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.run
|
16
|
+
self.new.run { yield }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module Tracer
|
4
|
+
module Formatters
|
5
|
+
class Basic
|
6
|
+
def self.call
|
7
|
+
start = ::DateTime.now.strftime('%Q').to_i / 1000.0
|
8
|
+
|
9
|
+
proc do |event, file, line, id, binding, classname|
|
10
|
+
now_ms = ::DateTime.now.strftime('%Q').to_i / 1000.0
|
11
|
+
duration = '%.3f' % (now_ms - start)
|
12
|
+
start = ::DateTime.now.strftime('%Q').to_i / 1000.0
|
13
|
+
printf "%s %s %8s %s:%-2d %10s %8s\n", ::DateTime.now.strftime("%S.%L"), duration, event, file, line, id, classname
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Tracer
|
2
|
+
class SetTraceFunc
|
3
|
+
|
4
|
+
def run
|
5
|
+
start_tracing
|
6
|
+
yield
|
7
|
+
rescue
|
8
|
+
raise
|
9
|
+
ensure
|
10
|
+
stop_tracing
|
11
|
+
end
|
12
|
+
|
13
|
+
def start_tracing
|
14
|
+
formatter = Tracer::Formatters::Basic.call
|
15
|
+
set_trace_func(formatter)
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop_tracing
|
19
|
+
set_trace_func(nil)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/tracer.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tracer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tracer-rb"
|
8
|
+
spec.version = Tracer::VERSION
|
9
|
+
spec.authors = ["raventid"]
|
10
|
+
spec.email = ["juliankul@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Simple and fast tracer for your Ruby code.}
|
13
|
+
spec.description = %q{Simple and fast tracer for your Ruby code. It's like puts debugging but on steroids.}
|
14
|
+
spec.homepage = "https://github.com/raventid/tracer"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.6"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tracer-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- raventid
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Simple and fast tracer for your Ruby code. It's like puts debugging but
|
70
|
+
on steroids.
|
71
|
+
email:
|
72
|
+
- juliankul@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/tracer.rb
|
86
|
+
- lib/tracer/formatters/basic.rb
|
87
|
+
- lib/tracer/set_trace_func.rb
|
88
|
+
- lib/tracer/version.rb
|
89
|
+
- tracer.gemspec
|
90
|
+
homepage: https://github.com/raventid/tracer
|
91
|
+
licenses: []
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.5.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Simple and fast tracer for your Ruby code.
|
113
|
+
test_files: []
|