Giter Site home page Giter Site logo

jazwiecki / trace_location Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yhirano55/trace_location

0.0 0.0 0.0 274 KB

🔍Help you get reading the huge open souce libraries in Ruby and trace its source locations

License: MIT License

Shell 0.45% Ruby 99.55%

trace_location's Introduction

TraceLocation

Build Status

TraceLocation helps you trace the source location to ease reading huge open-source libraries in Ruby.

Installation

Add this line to your application's Gemfile:

gem 'trace_location'

And then execute:

$ bundle

Or install it yourself as:

$ gem install trace_location

Usage

Example: Track establish connection in Active Record

config = Rails.application.config.database_configuration[Rails.env]

TraceLocation.trace do
  # You just surround you want to track the process.
  ActiveRecord::Base.establish_connection(config)
end

Then you can get logs like this: .md, .log, .csv

Trace method options

name content example
format :md, :log, :csv (default: :md) :md
match Regexp, Symbol, String or Array for allow list [:activerecord, :activesupport]
ignore Regexp, Symbol, String or Array for deny list /bootsnap|activesupport/
methods Symbol or Array of method names [:call]

More examples

Example: Track the validation process of Active Record

book = Book.new(title: "My Book Title")
TraceLocation.trace(match: /activerecord/) { book.validate }

Results: .md, .log, .csv

Example: Track the lifecycle of Rails application

env = Rack::MockRequest.env_for('http://localhost:3000/books')

TraceLocation.trace do
  status, headers, body = Rails.application.call(env)
end

Results: .md, .log, .csv

Example: Track the has_secure_password in User model

class User < ApplicationRecord
  # temporary surrounding with TraceLocation#trace
  TraceLocation.trace(format: :md, ignore: /activesupport/) do
    has_secure_password
  end

Results: .md, .log, .csv

Example: Track the rendering process of action in controller class

class BooksController < ApplicationController
  before_action :set_book, only: [:show, :update, :destroy]

  # GET /books
  def index
    @books = Book.all

    # temporary surrounding with TraceLocation#trace
    TraceLocation.trace(format: :md, ignore: /activesupport|rbenv|concurrent-ruby/) do
      render json: @books
    end
  end

Results: .md, .log, .csv

License

MIT License

trace_location's People

Contributors

yhirano55 avatar pocke avatar shioimm avatar sinsoku avatar firedev avatar okuramasafumi avatar palkan avatar dependabot[bot] avatar indigolain avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.