jazz_fingers 5.0.1 → 5.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/lib/jazz_fingers/configuration.rb +3 -3
- data/lib/jazz_fingers/prompt.rb +67 -28
- data/lib/jazz_fingers/prompt/pry_version_012_and_prior.rb +24 -0
- data/lib/jazz_fingers/prompt/pry_version_013_and_later.rb +26 -0
- data/lib/jazz_fingers/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc72ca8fb88d61751cd5452ff6f597d769524e3164e87b9b139ee80c5811513
|
4
|
+
data.tar.gz: cde39ec620a826e7a3148d7a8df8e86f033be1692bade1e00c376a92a2f2db41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d17ad8070588368567d2296e6a5c8da63866d71b7e993bdfd96af57dfa59a60d7ec8aade44d0abb65bbae4f7d49e4b3e8c0ebf2de24e775886a8ca8b07cd3c9e
|
7
|
+
data.tar.gz: 949d5fb0d2d2e5836185f4f361c486db5e15c3aa6ccca61b3f8b9f97c434aafcc437b5b53613840ebca2c542eceab3ed040511656f9c8d021907579ad5c57104
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.6
|
data/CHANGELOG.md
CHANGED
@@ -39,10 +39,10 @@ module JazzFingers
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def application_name
|
42
|
-
return
|
43
|
-
return
|
42
|
+
return underscore(@application_name) unless @application_name.nil?
|
43
|
+
return Rails.application.class.parent_name.underscore if defined?(Rails)
|
44
44
|
|
45
|
-
|
45
|
+
"jazz_fingers"
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
data/lib/jazz_fingers/prompt.rb
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module JazzFingers
|
2
4
|
class Prompt
|
5
|
+
OBJECT_INSTANCE = /#<(.+)>/
|
6
|
+
|
7
|
+
if Pry::VERSION >= "0.13.0"
|
8
|
+
require_relative "prompt/pry_version_013_and_later"
|
9
|
+
include PryVersion013AndLater
|
10
|
+
else
|
11
|
+
require_relative "prompt/pry_version_012_and_prior"
|
12
|
+
include PryVersion012AndPrior
|
13
|
+
end
|
14
|
+
|
3
15
|
def initialize(options = {})
|
4
16
|
@colored = options.fetch(:colored)
|
5
17
|
@separator = options.fetch(:separator)
|
@@ -28,48 +40,75 @@ module JazzFingers
|
|
28
40
|
"\001\e[1m\002#{text}\001\e[0m\002"
|
29
41
|
end
|
30
42
|
|
31
|
-
def
|
43
|
+
def main_separator
|
32
44
|
red_text(@separator)
|
33
45
|
end
|
34
46
|
|
35
|
-
def
|
36
|
-
|
47
|
+
def wait_separator
|
48
|
+
"*"
|
37
49
|
end
|
38
50
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
# Return the current Pry context
|
52
|
+
#
|
53
|
+
# When the Pry context is `"main"` or `"nil"`, use the application name from
|
54
|
+
# the JazzFingers config. Examples: "(my_rails_app_name)", "(jazz_fingers)".
|
55
|
+
#
|
56
|
+
# When in the context of an object instance, use the abbreviated object
|
57
|
+
# path. Example: "(#<Pry::Prompt>)", "(#<RSpec::...::ClassName>)"
|
58
|
+
#
|
59
|
+
# Fall back to the raw context provided by Pry.view_clip.
|
60
|
+
# Example: "(Pry::Prompt)"
|
61
|
+
def context(module_name = "main")
|
62
|
+
name =
|
63
|
+
case module_name
|
64
|
+
when "main", "nil"
|
65
|
+
@application_name
|
66
|
+
when OBJECT_INSTANCE
|
67
|
+
abbreviated_context(module_name)
|
68
|
+
else
|
69
|
+
module_name
|
70
|
+
end
|
46
71
|
|
47
|
-
|
48
|
-
|
49
|
-
text = Pry.view_clip(object)
|
72
|
+
blue_text("(#{name})")
|
73
|
+
end
|
50
74
|
|
51
|
-
|
52
|
-
|
75
|
+
def line_number(pry)
|
76
|
+
if pry.respond_to? :input_ring
|
77
|
+
bold_text(pry.input_ring.size)
|
53
78
|
else
|
54
|
-
|
79
|
+
bold_text(pry.input_array.size)
|
55
80
|
end
|
56
81
|
end
|
57
82
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
83
|
+
# Abbreviate the object path in the given `object_label` string so the
|
84
|
+
# prompt doesn't overflow. Display only the root and leaf namespaces.
|
85
|
+
#
|
86
|
+
# Examples:
|
87
|
+
# In: #<Class1::Class2::Class3::Class4::Class5>
|
88
|
+
# Out: #<Class1::...::Class5>
|
89
|
+
#
|
90
|
+
# In: #<Class1::Class2>
|
91
|
+
# Out: #<Class1::Class2>
|
92
|
+
#
|
93
|
+
# In: #<NoPathJustASingleLongClassName>
|
94
|
+
# Out: #<NoPathJustASingleLongClassName>
|
95
|
+
def abbreviated_context(object_label)
|
96
|
+
object_path = object_label[OBJECT_INSTANCE, 1]
|
97
|
+
object_path_components = object_path.split("::")
|
98
|
+
return object_label if object_path_components.length <= 2
|
63
99
|
|
64
|
-
|
65
|
-
|
66
|
-
spaces = ' ' * level
|
67
|
-
"#{RUBY_VERSION} #{name}#{line_number(pry)} * #{spaces}"
|
68
|
-
end
|
100
|
+
root, *_, leaf = object_path_components
|
101
|
+
"#<#{root}::...::#{leaf}>"
|
69
102
|
end
|
70
103
|
|
71
|
-
def
|
72
|
-
|
104
|
+
def template(module_name, pry, separator)
|
105
|
+
format(
|
106
|
+
"%<ruby>s %<context>s[%<line>s] %<separator>s ",
|
107
|
+
ruby: RUBY_VERSION,
|
108
|
+
context: context(module_name),
|
109
|
+
line: line_number(pry),
|
110
|
+
separator: separator
|
111
|
+
)
|
73
112
|
end
|
74
113
|
end
|
75
114
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JazzFingers
|
4
|
+
class Prompt
|
5
|
+
# For Pry < 0.13.
|
6
|
+
module PryVersion012AndPrior
|
7
|
+
def config
|
8
|
+
[main_prompt, wait_prompt]
|
9
|
+
end
|
10
|
+
|
11
|
+
def main_prompt
|
12
|
+
lambda do |context, _nesting, pry|
|
13
|
+
template(Pry.view_clip(context), pry, main_separator)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def wait_prompt
|
18
|
+
lambda do |context, _nesting, pry|
|
19
|
+
template(Pry.view_clip(context), pry, wait_separator)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JazzFingers
|
4
|
+
class Prompt
|
5
|
+
# For Pry >= 0.13.
|
6
|
+
module PryVersion013AndLater
|
7
|
+
# Add the JazzFingers prompt to the Pry::Prompt hash to enable changing it
|
8
|
+
# with `change-prompt`.
|
9
|
+
#
|
10
|
+
# Return the Pry::Prompt object.
|
11
|
+
def config
|
12
|
+
return Pry::Prompt[:jazz_fingers] if Pry::Prompt[:jazz_fingers]
|
13
|
+
|
14
|
+
Pry::Prompt.add(
|
15
|
+
:jazz_fingers,
|
16
|
+
"A spruced-up prompt provided by jazz_fingers.",
|
17
|
+
[main_separator, wait_separator]
|
18
|
+
) do |context, _nesting, pry, separator|
|
19
|
+
template(Pry.view_clip(context), pry, separator)
|
20
|
+
end
|
21
|
+
|
22
|
+
Pry::Prompt[:jazz_fingers]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/jazz_fingers/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jazz_fingers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Henrique Lopes Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -106,6 +106,8 @@ files:
|
|
106
106
|
- lib/jazz_fingers/input.rb
|
107
107
|
- lib/jazz_fingers/print.rb
|
108
108
|
- lib/jazz_fingers/prompt.rb
|
109
|
+
- lib/jazz_fingers/prompt/pry_version_012_and_prior.rb
|
110
|
+
- lib/jazz_fingers/prompt/pry_version_013_and_later.rb
|
109
111
|
- lib/jazz_fingers/version.rb
|
110
112
|
homepage: https://github.com/plribeiro3000/jazz_fingers
|
111
113
|
licenses:
|
@@ -122,11 +124,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
124
|
version: '2.0'
|
123
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
126
|
requirements:
|
125
|
-
- - "
|
127
|
+
- - ">"
|
126
128
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
129
|
+
version: 1.3.1
|
128
130
|
requirements: []
|
129
|
-
rubygems_version: 3.0.
|
131
|
+
rubygems_version: 3.0.8
|
130
132
|
signing_key:
|
131
133
|
specification_version: 4
|
132
134
|
summary: Exercise those fingers. Pry-based enhancements for the default Ruby console.
|