Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source of require, tree of requires with indentation? #2

Open
janpio opened this issue Sep 27, 2018 · 1 comment
Open

Source of require, tree of requires with indentation? #2

janpio opened this issue Sep 27, 2018 · 1 comment

Comments

@janpio
Copy link

janpio commented Sep 27, 2018

I am using your gem to output a list of the require and require_relative "activity" in my app now:

require_relative 'fastlane_core/globals' (C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/fastlane-2.105.2/fastlane_core/lib) 
require_relative 'fastlane_core/core_ext/string' (C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/fastlane-2.105.2/fastlane_core/lib)
require 'logger'
require 'colored'
require_relative 'cursor/version' (C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/tty-cursor-0.6.0/lib/tty)
require 'tty/cursor'
require 'tty-cursor'
require_relative 'spinner/version' (C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/tty-spinner-0.8.0/lib/tty)
require_relative 'spinner/formats' (C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/tty-spinner-0.8.0/lib/tty)
require_relative 'tty/spinner' (C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/tty-spinner-0.8.0/lib)

via

require 'backload'
require 'backload/require_relative'
def Kernel.backloaded(feature, options={})
  if options[:require]
      if rel = options[:relative]
        puts "require_relative '#{feature}' (#{rel})"
      else
        puts "require '#{feature}'"
      end
  end
end

That by itself is awesome, but of course I want more now 💯

Any idea how I would go about transforming this simple list into something that helps me undertand what files are requiring what, which then require other stuff?

In the best case this would be presented as a tree like structure, comparable to what tree returns:

├───bin                             
├───cert                            
│   └───lib                         
│       └───cert                    
├───credentials_manager             
│   └───lib                         
│       └───credentials_manager     
├───deliver                         
│   └───lib                         
│       ├───assets                  
│       └───deliver                 
├───fastlane                        
│   ├───lib                         
@janpio
Copy link
Author

janpio commented Sep 27, 2018

Here is a bit of code that tries to keep track of the level it is on: https://stackoverflow.com/questions/7190015/how-do-i-get-a-list-of-files-that-have-been-required-in-ruby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant