class Guard::Jobs::PryWrapper
Attributes
thread[R]
Public Instance Methods
_setup(options)
click to toggle source
# File lib/marv/project/guard/pry.rb, line 7 def _setup(options) Pry.config.should_load_rc = false Pry.config.should_load_local_rc = false history_file_path = options[:history_file] || HISTORY_FILE if legacy_pry? Pry.config.history.file = File.expand_path(history_file_path) else Pry.config.history_file = File.expand_path(history_file_path) end _add_hooks(options) ::Guard::Commands::All.import ::Guard::Commands::Change.import ::Guard::Commands::Notification.import ::Guard::Commands::Pause.import ::Guard::Commands::Reload.import ::Guard::Commands::Show.import ::Guard::Commands::Scope.import _setup_commands _configure_prompt end
Private Instance Methods
_colorize(text, color)
click to toggle source
Colorizes message using Thor Color Util
# File lib/marv/project/guard/pry.rb, line 42 def _colorize(text, color) Marv.colorize(text, color) end
_configure_prompt()
click to toggle source
Configures the pry prompt to see `guard` instead of `pry`.
# File lib/marv/project/guard/pry.rb, line 49 def _configure_prompt prompt_procs = [ _prompt(_colorize("\u00BB", :green)), _prompt(_colorize("*", :yellow)) ] if legacy_pry? Pry.config.prompt = prompt_procs else prompt_args = [:marv, 'Marv prompt for guard watcher', prompt_procs] Pry::Prompt.add(*prompt_args) do |context, nesting, pry_instance, sep| sep.call(context, nesting, pry_instance) end Pry.config.prompt = Pry::Prompt[:marv] end end
_prompt(ending_char)
click to toggle source
Returns a proc that will return itself a string ending with the given `ending_char` when called.
# File lib/marv/project/guard/pry.rb, line 71 def _prompt(ending_char) proc do |target_self, nest_level, pry| history = pry.input_ring.size process = ::Guard.listener.paused? ? _colorize("pause", :yellow) : _colorize("marv", :green) level = ":#{nest_level}" unless nest_level.zero? hist_text = _colorize("[#{history}]", :yellow) clip_text = _colorize("(#{_clip_name(target_self)})", :cyan) level_text = _colorize("#{level}", :cyan) path_text = _colorize(File.basename(Dir.pwd), :magenta) "#{hist_text} #{_scope_for_prompt}#{process} #{path_text} #{clip_text}#{level_text} #{ending_char} " end end
legacy_pry?()
click to toggle source
# File lib/marv/project/guard/pry.rb, line 36 def legacy_pry? Gem::Version.new(Pry::VERSION) < Gem::Version.new('0.13') end