bin/bumbler in bumbler-0.5.0 vs bin/bumbler in bumbler-0.6.0
- old
+ new
@@ -1,41 +1,54 @@
#!/usr/bin/env ruby
-add_load_path = lambda do
- path = File.join(File.dirname(__FILE__), '..', 'lib')
- $LOAD_PATH << path unless $LOAD_PATH.include? path
+# frozen_string_literal: true
+
+# in case we execute via ./bin
+add_load_path = -> do
+ local_lib = File.expand_path('../lib', __dir__)
+ $LOAD_PATH << local_lib unless $LOAD_PATH.include? local_lib
end
+add_load_path.call
-add_load_path.call # in case we execute via ./bin
-
require 'optparse'
require 'bumbler'
options = {}
OptionParser.new do |parser|
- parser.banner = <<BANNER
-Bumbler shows how long loading your bundle components take.
+ parser.banner = <<~BANNER
+ Bumbler shows how long loading your bundle components take.
-Usage:
- bumbler
+ Usage:
+ bumbler
-Options:
-BANNER
- parser.on("-t", "--threshold MILISECONDS", Integer, "Threshold in ms to be listed as slow") { |t| options[:threshold] = t }
+ Options:
+ BANNER
+ parser.on("-t", "--threshold MILLISECONDS", Integer, "Threshold in ms to be listed as slow") { |t| options[:threshold] = t }
parser.on("--initializers", "Show load time of initializers") { options[:initializers] = true }
+ parser.on("--all", "Show all load times") { options[:all] = true }
parser.on("-h", "--help", "Show this.") { puts parser; exit }
- parser.on('-v', '--version', 'Show Version'){ puts Bumbler::VERSION; exit}
+ parser.on('-v', '--version', 'Show Version') { puts Bumbler::VERSION; exit }
end.parse!
+abort "Not arguments supported" unless ARGV.empty?
+
Bumbler::Hooks.slow_threshold = options[:threshold] if options[:threshold]
if options[:initializers]
require './config/application'
add_load_path.call # bundler kicks us out
require 'bumbler/track_initializers'
require './config/environment'
-else
+elsif File.exist?('./config/environment')
require 'bumbler/go'
require './config/environment'
add_load_path.call # bundler kicks us out
+else
+ require 'bumbler/go'
+ Bundler.require(*Bundler.definition.groups)
end
-Bumbler::Stats.all_slow_items
+Bumbler::Stats.print_overview
+if options[:all]
+ Bumbler::Stats.print_tracked_items
+else
+ Bumbler::Stats.print_slow_items
+end