module Rib
from github.com/janlelis/ripl-multi_line
This is based on lib/byebug/processors/pry_processor.rb
Constants
- Blackhole
- Skip
- VERSION
Private Class Methods
# File lib/rib.rb, line 142 def self.prepare words name = config[:name] "#{name}: #{words.join("\n#{' '*(name.size+2)}")}" end
Public Instance Methods
# File lib/rib.rb, line 101 def config_path= new_path @config_path = new_path end
Convenient way to disable all plugins in the memory. This could also take a list of plugins and disable them.
@api public @param plugs [Array] (Rib.plugins
) Plugins which would be disabled.
# File lib/rib.rb, line 66 def disable_plugins plugs=plugins plugs.each(&:disable) end
Convenient way to enable all plugins in the memory. This could also take a list of plugins and enable them.
@api public @param plugs [Array] (Rib.plugins
) Plugins which would be enabled.
# File lib/rib.rb, line 75 def enable_plugins plugs=plugins plugs.each(&:enable) end
Rib.home
is where Rib
storing things. By default, it goes to '~/.rib', or somewhere containing a 'config.rb' or 'history.rb' in the order of './.rib' (project specific config), or '~/.rib' (home config), or '~/.config/rib' (home config, residing in ~/.config)
@api public
# File lib/rib.rb, line 33 def home ENV['RIB_HOME'] ||= File.expand_path( ["#{config[:prefix]}/.rib", '~/.rib', '~/.config/rib'].find{ |path| File.exist?(File.expand_path(path)) } || '~/.rib' ) end
All plugins which have been loaded into the memory regardless it's enabled or not.
@api public
# File lib/rib.rb, line 57 def plugins Shell.ancestors.drop(1).select{ |a| a.singleton_class < Plugin } end
Load (actually require) the config file if it exists. This might emit warnings if there's some error while loading it.
@api public
# File lib/rib.rb, line 83 def require_config result = require(config_path) if File.exist?(config_path) Rib.say("Config loaded from: #{config_path}") if $VERBOSE && result result rescue StandardError, LoadError, SyntaxError => e Rib.warn("Error loading #{config_path}\n" \ " #{Rib::API.format_error(e)}") end
Convenient shell accessor, which would just give you current last shell or create one and load the config file. If you need a clean shell which does not load config file, use Shell.new
instead.
@api public
# File lib/rib.rb, line 46 def shell shells.last || begin require_config if config_path && config_path != Skip (shells << Shell.new(config)).last end end
All shells in the memory
# File lib/rib.rb, line 18 def shells @shells ||= [] end
# File lib/rib.rb, line 133 def silence w, v = $-w, $VERBOSE $-w, $VERBOSE = false, false yield ensure $-w, $VERBOSE = w, v end
All shared variables for all shells
# File lib/rib.rb, line 23 def vars @vars ||= {} end