Module: Rib
- Extended by:
- Anchor::Imp, Byebug::Imp, Caller::Imp, Edit::Imp, LastValue::Imp
- Defined in:
- lib/rib/extra/byebug.rb,
lib/rib.rb,
lib/rib/api.rb,
lib/rib/shell.rb,
lib/rib/plugin.rb,
lib/rib/runner.rb,
lib/rib/version.rb,
lib/rib/app/auto.rb,
lib/rib/app/rack.rb,
lib/rib/app/rails.rb,
lib/rib/more/beep.rb,
lib/rib/more/edit.rb,
lib/rib/extra/hirb.rb,
lib/rib/more/color.rb,
lib/rib/more/anchor.rb,
lib/rib/more/caller.rb,
lib/rib/core/history.rb,
lib/rib/extra/paging.rb,
lib/rib/core/readline.rb,
lib/rib/core/multiline.rb,
lib/rib/core/completion.rb,
lib/rib/core/last_value.rb,
lib/rib/extra/autoindent.rb,
lib/rib/core/squeeze_history.rb,
lib/rib/core/strip_backtrace.rb,
lib/rib/more/multiline_history.rb,
lib/rib/more/bottomup_backtrace.rb,
lib/rib/more/multiline_history_file.rb
Overview
Defined Under Namespace
Modules: API, Anchor, Auto, Autoindent, Beep, BottomupBacktrace, Byebug, Caller, Color, Completion, Edit, Hirb, History, LastValue, Multiline, MultilineHistory, MultilineHistoryFile, Paging, Plugin, Rack, Rails, Readline, Runner, SqueezeHistory, StripBacktrace Classes: Shell
Constant Summary collapse
- Skip =
Object.new
- Blackhole =
Object.new
- VERSION =
'1.6.1'
Class Method Summary collapse
-
.abort(*words) ⇒ Object
Warn (print to $stderr, with colors in the future, maybe) something by the name of Rib and then exit(1).
-
.config ⇒ Object
All default Rib configs, would be passed to Shell.new in Rib.shell, but calling Shell.new directly won’t bring this in.
-
.config_path ⇒ Object
The config path where Rib tries to load upon Rib.shell.
- .config_path=(new_path) ⇒ Object
-
.disable_plugins(plugs = plugins) ⇒ Object
Convenient way to disable all plugins in the memory.
-
.enable_plugins(plugs = plugins) ⇒ Object
Convenient way to enable all plugins in the memory.
-
.home ⇒ Object
Rib.home is where Rib storing things.
- .last ⇒ Object
-
.plugins ⇒ Object
All plugins which have been loaded into the memory regardless it’s enabled or not.
-
.require_config ⇒ Object
Load (actually require) the config file if it exists.
-
.say(*words) ⇒ Object
Say (print to $stdout, with colors in the future, maybe) something by the name of Rib.
-
.shell ⇒ Object
Convenient shell accessor, which would just give you current last shell or create one and load the config file.
-
.shells ⇒ Object
All shells in the memory.
- .silence ⇒ Object
-
.vars ⇒ Object
All shared variables for all shells.
-
.warn(*words) ⇒ Object
Warn (print to $stderr, with colors in the future, maybe) something by the name of Rib.
Methods included from Edit::Imp
Methods included from Anchor::Imp
Methods included from Caller::Imp
Methods included from Byebug::Imp
byebug, finish, location, next, step
Methods included from LastValue::Imp
Class Method Details
.abort(*words) ⇒ Object
Warn (print to $stderr, with colors in the future, maybe) something by the name of Rib and then exit(1).
128 129 130 131 |
# File 'lib/rib.rb', line 128 def abort *words warn(words) exit(1) end |
.config ⇒ Object
All default Rib configs, would be passed to Shell.new in Rib.shell, but calling Shell.new directly won’t bring this in.
13 14 15 |
# File 'lib/rib.rb', line 13 def config @config ||= {:name => 'rib', :prefix => '.', :started_at => Time.now} end |
.config_path ⇒ Object
The config path where Rib tries to load upon Rib.shell. It is depending on where Rib.home was discovered if no specific config path was specified via -c or –config command
97 98 99 |
# File 'lib/rib.rb', line 97 def config_path @config_path ||= File.join(home, 'config.rb') end |
.config_path=(new_path) ⇒ Object
101 102 103 |
# File 'lib/rib.rb', line 101 def config_path= new_path @config_path = new_path end |
.disable_plugins(plugs = plugins) ⇒ Object
Convenient way to disable all plugins in the memory. This could also take a list of plugins and disable them.
66 67 68 |
# File 'lib/rib.rb', line 66 def disable_plugins plugs=plugins plugs.each(&:disable) end |
.enable_plugins(plugs = plugins) ⇒ Object
Convenient way to enable all plugins in the memory. This could also take a list of plugins and enable them.
75 76 77 |
# File 'lib/rib.rb', line 75 def enable_plugins plugs=plugins plugs.each(&:enable) end |
.home ⇒ Object
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)
33 34 35 36 37 38 39 |
# File 'lib/rib.rb', line 33 def home ENV['RIB_HOME'] ||= File.( ["#{config[:prefix]}/.rib", '~/.rib', '~/.config/rib'].find{ |path| File.exist?(File.(path)) } || '~/.rib' ) end |
.last ⇒ Object
24 25 26 |
# File 'lib/rib/core/readline.rb', line 24 def (::Readline::HISTORY).last self[-1] end |
.plugins ⇒ Object
All plugins which have been loaded into the memory regardless it’s enabled or not.
57 58 59 |
# File 'lib/rib.rb', line 57 def plugins Shell.ancestors.drop(1).select{ |a| a.singleton_class < Plugin } end |
.require_config ⇒ Object
Load (actually require) the config file if it exists. This might emit warnings if there’s some error while loading it.
83 84 85 86 87 88 89 90 |
# 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 |
.say(*words) ⇒ Object
Say (print to $stdout, with colors in the future, maybe) something by the name of Rib.
110 111 112 |
# File 'lib/rib.rb', line 110 def say *words $stdout.puts(Rib.prepare(words)) end |
.shell ⇒ Object
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.
46 47 48 49 50 51 |
# 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 |
.shells ⇒ Object
All shells in the memory
18 19 20 |
# File 'lib/rib.rb', line 18 def shells @shells ||= [] end |
.silence ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/rib.rb', line 133 def silence w, v = $-w, $VERBOSE $-w, $VERBOSE = false, false yield ensure $-w, $VERBOSE = w, v end |
.vars ⇒ Object
All shared variables for all shells
23 24 25 |
# File 'lib/rib.rb', line 23 def vars @vars ||= {} end |
.warn(*words) ⇒ Object
Warn (print to $stderr, with colors in the future, maybe) something by the name of Rib.
119 120 121 |
# File 'lib/rib.rb', line 119 def warn *words $stderr.puts(Rib.prepare(words)) end |