Sha256: e3a5ce92ec61039758db1343e45e970036fd047f2f3a12871333fd77b2017332
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
module PryRails class Prompt class << self def formatted_env if Rails.env.production? bold_env = Pry::Helpers::Text.bold(Rails.env) Pry::Helpers::Text.red(bold_env) elsif Rails.env.development? Pry::Helpers::Text.green(Rails.env) else Rails.env end end def project_name File.basename(Rails.root) end end end desc = "Includes the current Rails environment and project folder name.\n" \ "[1] [project_name][Rails.env] pry(main)>" if Pry::Prompt.respond_to?(:add) Pry::Prompt.add 'rails', desc, %w(> *) do |target_self, nest_level, pry, sep| "[#{pry.input_ring.size}] " \ "[#{Prompt.project_name}][#{Prompt.formatted_env}] " \ "#{pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \ "#{":#{nest_level}" unless nest_level.zero?}#{sep} " end else draw_prompt = lambda do |target_self, nest_level, pry, sep| "[#{pry.input_array.size}] " \ "[#{Prompt.project_name}][#{Prompt.formatted_env}] " \ "#{pry.config.prompt_name}(#{Pry.view_clip(target_self)})" \ "#{":#{nest_level}" unless nest_level.zero?}#{sep} " end prompts = [ proc do |target_self, nest_level, pry| draw_prompt.call(target_self, nest_level, pry, '>') end, proc do |target_self, nest_level, pry| draw_prompt.call(target_self, nest_level, pry, '*') end ] Pry::Prompt::MAP["rails"] = {value: prompts, description: desc} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pry-rails-0.3.7 | lib/pry-rails/prompt.rb |