Skip to content

Instantly share code, notes, and snippets.

@BrennickL
Last active July 26, 2024 16:57
Show Gist options
  • Save BrennickL/0b0ee8f78a0f8ca53194e62b1c77b132 to your computer and use it in GitHub Desktop.
Save BrennickL/0b0ee8f78a0f8ca53194e62b1c77b132 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "<<my_gem_name>>"
begin
require "pry"
Pry.start
rescue StandardError => e
puts "ERROR: #{e.message.capitalize}."
end
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
begin
require "irb"
require "irb/kit"
IRB::Kit.register_commands :all
IRB::Kit.register_helpers :all
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:CUSTOM] = {
PROMPT_I: "[#{IRB::Kit.prompt}]> ",
PROMPT_N: "[#{IRB::Kit.prompt}]| ",
PROMPT_C: "[#{IRB::Kit.prompt}]| ",
PROMPT_S: "[#{IRB::Kit.prompt}]%l ",
RETURN: "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :CUSTOM
IRB.conf[:COMPLETOR] = :type
IRB.start(__FILE__)
rescue LoadError => e
puts "ERROR: #{e.message.capitalize}."
end
# HELPER
def reload!(print = true)
puts "Reloading ..." if print
# Main project directory.
root_dir = File.expand_path("..", __dir__)
# Directories within the project that should be reloaded.
reload_dirs = %w[lib]
# Loop through and reload every file in all relevant project directories.
reload_dirs.each do |dir|
Dir.glob("#{root_dir}/#{dir}/**/*.rb").each { |f| load(f) }
end
# Return true when complete.
true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment