-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path.pryrc
49 lines (40 loc) · 1.46 KB
/
.pryrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true
# ShinyCMS ~ https://shinycms.org
#
# Copyright 2009-2020 Denny de la Haye ~ https://denny.me
#
# ShinyCMS is free software; you can redistribute it and/or modify it under the terms of the GPL (version 2 or later)
# Use Amazing Print gem to format console output
require 'amazing_print'
AmazingPrint.pry!
# Show app name and current environment in console prompt.
# Environment is shown in RED CAPITALS if it's not dev or test :)
if ENV[ 'PRETTY_PRY_PROMPT' ].present?
def prompt_name( name )
return name unless name.is_a?( Pry::Config )
name.call
end
def app_name_for_pry_prompt
Pry::Helpers::Text.cyan( 'ShinyCMS' )
end
def rails_env_for_pry_prompt
return Pry::Helpers::Text.cyan '(dev)' if Rails.env.development?
return Pry::Helpers::Text.green '(test)' if Rails.env.test?
Pry::Helpers::Text.red "[#{Rails.env.upcase}]"
end
Pry::Prompt.add(
:shiny_prompt, 'ShinyCMS rails console prompt'
) do |context, nesting, pry, seperator|
format(
'%<app_name>s %<rails_env>s [%<in_count>s] %<name>s(%<context>s)%<nesting>s%<separator>s ',
name: prompt_name( pry.config.prompt_name ),
app_name: app_name_for_pry_prompt,
rails_env: rails_env_for_pry_prompt,
in_count: pry.input_ring.count,
context: Pry.view_clip( context ),
nesting: ( nesting.positive? ? ":#{nesting}" : '' ),
separator: seperator
)
end
Pry.config.prompt = Pry::Prompt[ :shiny_prompt ]
end