Module: Rib
- Extended by:
- Anchor::Imp, Debugger::Imp, Edit::Imp
- Defined in:
- lib/rib.rb,
lib/rib/api.rb,
lib/rib/plugin.rb,
lib/rib/version.rb,
lib/rib/app/auto.rb,
lib/rib/app/rack.rb,
lib/rib/app/rails.rb,
lib/rib/app/ramaze.rb
Defined Under Namespace
Modules: API, Anchor, Auto, Autoindent, Color, Completion, Debugger, Edit, Hirb, History, Multiline, MultilineHistory, MultilineHistoryFile, Plugin, Rack, Rails, Ramaze, Readline, Runner, SqueezeHistory, StripBacktrace, Underscore Classes: Shell
Constant Summary collapse
- Skip =
Object.new
- Blackhole =
Object.new
- VERSION =
'1.1.5'
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.
-
.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.
-
.plugins ⇒ Object
All plugins which have been loaded into the memory regardless it’s enabled or not.
-
.require_config ⇒ Object
Load (actually require) ~/.config/rib/config.rb if 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 ~/.config/rib/config.rb if non has existed.
-
.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 Debugger::Imp
debug, debugger_execute, display, list, step, watch
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)
101 102 103 104 |
# File 'lib/rib.rb', line 101 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.
11 12 13 |
# File 'lib/rib.rb', line 11 def config @config ||= {:config => File.join(home, 'config.rb'), :name => 'rib'} end |
.config_path ⇒ Object
The config path where Rib tries to load upon Rib.shell
77 78 79 80 81 82 83 84 85 |
# File 'lib/rib.rb', line 77 def config_path return nil unless config[:config] path = File.(config[:config]) if File.exist?(path) path else nil end 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.
54 55 56 |
# File 'lib/rib.rb', line 54 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.
60 61 62 |
# File 'lib/rib.rb', line 60 def enable_plugins plugs=plugins plugs.each(&:enable) end |
.home ⇒ Object
Rib.home is where Rib storing things
26 27 28 29 30 31 32 33 34 |
# File 'lib/rib.rb', line 26 def home ENV['RIB_HOME'] ||= begin ['~/.rib', '~/.config/rib'].find{ |path| p = File.(path) File.exist?(File.join(p, 'config.rb')) || File.exist?(File.join(p, 'history.rb')) } || '~/.rib' end end |
.plugins ⇒ Object
All plugins which have been loaded into the memory regardless it’s enabled or not.
48 49 50 |
# File 'lib/rib.rb', line 48 def plugins Shell.ancestors[1..-1].select{ |a| a.singleton_class < Plugin } end |
.require_config ⇒ Object
Load (actually require) ~/.config/rib/config.rb if exists. This might emit warnings if there’s some error while loading it.
66 67 68 69 70 71 72 73 74 |
# File 'lib/rib.rb', line 66 def require_config return unless config_path result = require(config_path) Rib.say("Config loaded from: #{config_path}") if $VERBOSE && result result rescue Exception => e Rib.warn("Error loading #{config[:config]}\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
89 90 91 |
# File 'lib/rib.rb', line 89 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 ~/.config/rib/config.rb if non has existed. If you need a clean shell which does not load rc file, use Shell.new instead.
39 40 41 42 43 44 |
# File 'lib/rib.rb', line 39 def shell shells.last || begin require_config if config_path (shells << Shell.new(config)).last end end |
.shells ⇒ Object
All shells in the memory
16 17 18 |
# File 'lib/rib.rb', line 16 def shells @shells ||= [] end |
.silence ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/rib.rb', line 106 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
21 22 23 |
# File 'lib/rib.rb', line 21 def vars @vars ||= {} end |
.warn(*words) ⇒ Object
Warn (print to $stderr, with colors in the future, maybe) something by the name of Rib
95 96 97 |
# File 'lib/rib.rb', line 95 def warn *words $stderr.puts(Rib.prepare(words)) end |