jazz_fingers 4.0.1 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.hound.yml +1 -0
- data/.rubocop.yml +2 -14
- data/.ruby-version +1 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/README.md +7 -8
- data/Rakefile +1 -1
- data/jazz_fingers.gemspec +18 -19
- data/lib/jazz_fingers.rb +48 -11
- data/lib/jazz_fingers/awesome_print.rb +26 -0
- data/lib/jazz_fingers/coderay.rb +20 -0
- data/lib/jazz_fingers/coderay/escaped_colors.rb +74 -0
- data/lib/jazz_fingers/coderay/unescaped_colors.rb +74 -0
- data/lib/jazz_fingers/commands.rb +7 -0
- data/lib/jazz_fingers/commands/caller_method.rb +16 -0
- data/lib/jazz_fingers/commands/copy.rb +10 -0
- data/lib/jazz_fingers/commands/sql.rb +14 -0
- data/lib/jazz_fingers/configuration.rb +17 -11
- data/lib/jazz_fingers/input.rb +2 -2
- data/lib/jazz_fingers/print.rb +2 -3
- data/lib/jazz_fingers/prompt.rb +68 -24
- 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 +23 -45
- data/.hound.yml +0 -17
- data/lib/jazz_fingers/hirb_ext.rb +0 -15
- data/lib/jazz_fingers/setup.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bf15e3fff4144b2f8497097e0ad14e631091f2baf18faab756d0a74764539884
|
4
|
+
data.tar.gz: 75d7edba78a71f7b13eb5222de79719e0b7aed023d344230fa51c9efe09e39f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71c22ebac22ce8c1d69a765a7680a3ed7cdb9429ea9e7f47c3291f2746879b5789400d71e09f808fe2d6ae5240f71367050593acd0a8ec48ce2b80a71b9767dd
|
7
|
+
data.tar.gz: 949cb360d56b3ef4b4c9cfbeecd67fb92fc1c5a9d7bee604be673cc1ffa03b5ce8b295c4131f834f99d68e2bbd6f3f557283a2b2f9c303ef8c8d43171f8e8366
|
data/.hound.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.rubocop.yml
|
data/.rubocop.yml
CHANGED
@@ -1,17 +1,5 @@
|
|
1
1
|
Metrics/LineLength:
|
2
|
-
|
3
|
-
|
4
|
-
Style/EachWithObject:
|
5
|
-
Enabled: false
|
2
|
+
Max: 120
|
6
3
|
|
7
|
-
Style/
|
8
|
-
EnforcedStyle: when_needed
|
9
|
-
|
10
|
-
Style/FormatString:
|
4
|
+
Style/Documentation:
|
11
5
|
Enabled: false
|
12
|
-
|
13
|
-
Style/SignalException:
|
14
|
-
EnforcedStyle: only_raise
|
15
|
-
|
16
|
-
Style/StringLiterals:
|
17
|
-
EnforcedStyle: double_quotes
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 5.1.0.rc1 (2020-04-25)
|
4
|
+
* Change deprecated method on pry > 0.13.0
|
5
|
+
* Improve naming context
|
6
|
+
|
7
|
+
## 5.0.1 (2019-06-02)
|
8
|
+
* Remove documentation for removed dependency
|
9
|
+
* Use non deprecated method of `pry` if existent
|
10
|
+
|
11
|
+
## 5.0.0 (2018-05-02)
|
12
|
+
* Remove [pry-doc][pry-doc] dependency to reduce memory footprint
|
13
|
+
* Remove [hirb][hirb] dependency since its not being actively maintained
|
14
|
+
|
3
15
|
## 4.0.1 (2016-05-26)
|
4
16
|
* Remove requires for `pry-remote`
|
5
17
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,11 +10,15 @@ hard-working fingers!
|
|
10
10
|
|
11
11
|
* [**Pry**][pry] for a powerful shell alternative to IRB.
|
12
12
|
* [**Awesome Print**][awesome_print] for stylish pretty print.
|
13
|
-
* [**Hirb**][hirb] for tabular collection output.
|
14
|
-
* [**Pry Doc**][pry-doc] to browse Ruby source, including C, directly from the
|
15
13
|
console.
|
16
14
|
* [**Pry Coolline**][pry-coolline] for syntax highlighting as you type.
|
17
15
|
|
16
|
+
## Notes on Update to `5.0.0`
|
17
|
+
* [**Hirb**][hirb] was removed since it is not actively being maintained
|
18
|
+
* [**Pry-Doc**][pry-doc] was removed since it adds a lot of memory footprint which makes `JazzFingers` too heavy to use in production.
|
19
|
+
Add it to your `Gemfile` if you want it back
|
20
|
+
* `jazz_fingers/setup` is not needed since the setup is done automatically after the configuration block ends
|
21
|
+
* Call `JazzFingers.setup!` if you are using the default configurations
|
18
22
|
|
19
23
|
## Usage
|
20
24
|
|
@@ -28,8 +32,6 @@ end
|
|
28
32
|
|
29
33
|
That's it. Run `pry` as usual.
|
30
34
|
|
31
|
-
[Hirb][hirb] isn't enabled by default. To use, run `Hirb.enable` in the console.
|
32
|
-
|
33
35
|
Ruby compiled against a proper readline library, ideally GNU readline, is
|
34
36
|
recommended. Alternatively, [`gem install rb-readline`][rb-readline] for an
|
35
37
|
acceptible backup. Using ruby compiled against a `libedit` wrapper (primarily OS
|
@@ -38,8 +40,7 @@ X) will work but is not recommended.
|
|
38
40
|
|
39
41
|
## Options
|
40
42
|
|
41
|
-
|
42
|
-
Example `config/initializers/jazz_fingers.rb`:
|
43
|
+
Some configurations can be overwritten:
|
43
44
|
|
44
45
|
```ruby
|
45
46
|
if defined?(JazzFingers)
|
@@ -49,8 +50,6 @@ if defined?(JazzFingers)
|
|
49
50
|
config.coolline = false
|
50
51
|
config.application_name = MyAwesomeProject
|
51
52
|
end
|
52
|
-
|
53
|
-
require 'jazz_fingers/setup'
|
54
53
|
end
|
55
54
|
```
|
56
55
|
|
data/Rakefile
CHANGED
data/jazz_fingers.gemspec
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require File.expand_path("../lib/jazz_fingers/version", __FILE__)
|
1
|
+
require File.expand_path('lib/jazz_fingers/version', __dir__)
|
4
2
|
|
5
3
|
Gem::Specification.new do |gem|
|
6
|
-
gem.name =
|
4
|
+
gem.name = 'jazz_fingers'
|
7
5
|
gem.version = JazzFingers::VERSION
|
8
|
-
gem.author =
|
9
|
-
gem.email =
|
10
|
-
gem.license =
|
11
|
-
gem.homepage =
|
12
|
-
gem.summary =
|
13
|
-
|
6
|
+
gem.author = 'Paulo Henrique Lopes Ribeiro'
|
7
|
+
gem.email = 'plribeiro3000@gmail.com'
|
8
|
+
gem.license = 'MIT'
|
9
|
+
gem.homepage = 'https://github.com/plribeiro3000/jazz_fingers'
|
10
|
+
gem.summary = 'Exercise those fingers. Pry-based enhancements for the default Ruby console.'
|
11
|
+
description =
|
12
|
+
'Spending hours in the ruby console? Spruce it up and show off those hard-working hands! jazz_fingers'\
|
13
|
+
'replaces IRB with Pry, improves output through awesome_print, and has some other goodies up its sleeves.'
|
14
|
+
gem.description = description
|
14
15
|
|
15
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
16
17
|
gem.files = `git ls-files`.split("\n")
|
17
18
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
gem.require_paths = [
|
19
|
+
gem.require_paths = ['lib']
|
19
20
|
|
20
21
|
# Dependencies
|
21
|
-
gem.required_ruby_version =
|
22
|
-
gem.add_runtime_dependency
|
23
|
-
gem.add_runtime_dependency
|
24
|
-
gem.add_runtime_dependency
|
25
|
-
gem.add_runtime_dependency
|
26
|
-
gem.add_runtime_dependency "pry-coolline", "~> 0.2"
|
27
|
-
gem.add_runtime_dependency "awesome_print", "~> 1.6"
|
22
|
+
gem.required_ruby_version = '>= 2.0'
|
23
|
+
gem.add_runtime_dependency 'awesome_print', '~> 1.6'
|
24
|
+
gem.add_runtime_dependency 'pry', '~> 0.10'
|
25
|
+
gem.add_runtime_dependency 'pry-byebug', '~> 3.4'
|
26
|
+
gem.add_runtime_dependency 'pry-coolline', '~> 0.2'
|
28
27
|
|
29
|
-
gem.add_development_dependency
|
28
|
+
gem.add_development_dependency 'rubocop'
|
30
29
|
end
|
data/lib/jazz_fingers.rb
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
ENV['HOME'] ||= '/dev/null'
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require "readline"
|
8
|
-
require "jazz_fingers/hirb_ext"
|
3
|
+
require 'pry'
|
4
|
+
require 'pry-byebug'
|
5
|
+
require 'readline'
|
6
|
+
require 'forwardable'
|
9
7
|
|
10
8
|
module JazzFingers
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
9
|
+
autoload :AWESOME_PRINT, 'jazz_fingers/awesome_print'
|
10
|
+
autoload :CodeRay, 'jazz_fingers/coderay'
|
11
|
+
autoload :Commands, 'jazz_fingers/commands'
|
12
|
+
autoload :Configuration, 'jazz_fingers/configuration'
|
13
|
+
autoload :Input, 'jazz_fingers/input'
|
14
|
+
autoload :Print, 'jazz_fingers/print'
|
15
|
+
autoload :Prompt, 'jazz_fingers/prompt'
|
16
|
+
autoload :VERSION, 'jazz_fingers/version'
|
16
17
|
|
17
18
|
class << self
|
19
|
+
extend Forwardable
|
20
|
+
|
21
|
+
def_delegators :config, :awesome_print?, :coolline?
|
22
|
+
|
18
23
|
def print
|
19
24
|
@print ||= Print.config
|
20
25
|
end
|
@@ -35,10 +40,42 @@ module JazzFingers
|
|
35
40
|
|
36
41
|
def configure
|
37
42
|
yield @config ||= Configuration.new
|
43
|
+
setup!
|
38
44
|
end
|
39
45
|
|
40
46
|
def config
|
41
47
|
@config ||= Configuration.new
|
42
48
|
end
|
49
|
+
|
50
|
+
def setup!
|
51
|
+
Pry.prompt = prompt
|
52
|
+
Pry.input = input if JazzFingers.coolline?
|
53
|
+
Pry.config.should_load_plugins = false
|
54
|
+
Pry.commands.alias_command('c', 'continue')
|
55
|
+
Pry.commands.alias_command('s', 'step')
|
56
|
+
Pry.commands.alias_command('n', 'next')
|
57
|
+
Pry.editor = 'vi'
|
58
|
+
Pry.config.ls.separator = "\n"
|
59
|
+
Pry.config.ls.heading_color = :magenta
|
60
|
+
Pry.config.ls.public_method_color = :green
|
61
|
+
Pry.config.ls.protected_method_color = :yellow
|
62
|
+
Pry.config.ls.private_method_color = :bright_black
|
63
|
+
|
64
|
+
JazzFingers::Commands.constants(false).each do |constant|
|
65
|
+
command = JazzFingers::Commands.const_get(constant)
|
66
|
+
Pry.config.commands.import(command)
|
67
|
+
end
|
68
|
+
|
69
|
+
if JazzFingers.awesome_print?
|
70
|
+
require 'awesome_print'
|
71
|
+
|
72
|
+
AwesomePrint.defaults = JazzFingers::AWESOME_PRINT
|
73
|
+
Pry.print = print
|
74
|
+
end
|
75
|
+
|
76
|
+
JazzFingers::CodeRay.setup!
|
77
|
+
|
78
|
+
true
|
79
|
+
end
|
43
80
|
end
|
44
81
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
AWESOME_PRINT = {
|
3
|
+
indent: 2,
|
4
|
+
sort_keys: true,
|
5
|
+
color: {
|
6
|
+
args: :greenish,
|
7
|
+
array: :pale,
|
8
|
+
bigdecimal: :blue,
|
9
|
+
class: :yellow,
|
10
|
+
date: :greenish,
|
11
|
+
falseclass: :red,
|
12
|
+
fixnum: :blue,
|
13
|
+
float: :blue,
|
14
|
+
hash: :pale,
|
15
|
+
keyword: :cyan,
|
16
|
+
method: :purpleish,
|
17
|
+
nilclass: :red,
|
18
|
+
string: :yellowish,
|
19
|
+
struct: :pale,
|
20
|
+
symbol: :cyanish,
|
21
|
+
time: :greenish,
|
22
|
+
trueclass: :green,
|
23
|
+
variable: :cyanish
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
module CodeRay
|
3
|
+
autoload :ESCAPED_COLORS, 'jazz_fingers/coderay/escaped_colors'
|
4
|
+
autoload :UNESCAPED_COLORS, 'jazz_fingers/coderay/unescaped_colors'
|
5
|
+
|
6
|
+
def self.setup!
|
7
|
+
::CodeRay.scan("example", :ruby).term
|
8
|
+
|
9
|
+
if ::CodeRay::VERSION >= '1.1.0'
|
10
|
+
ESCAPED_COLORS.each do |key, value|
|
11
|
+
::CodeRay::Encoders::Terminal::TOKEN_COLORS[key] = value
|
12
|
+
end
|
13
|
+
else
|
14
|
+
UNESCAPED_COLORS.each do |key, value|
|
15
|
+
::CodeRay::Encoders::Terminal::TOKEN_COLORS[key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
module CodeRay
|
3
|
+
ESCAPED_COLORS = {
|
4
|
+
attribute_name: "\e[33m",
|
5
|
+
attribute_value: "\e[31m",
|
6
|
+
binary: "\e[1;35m",
|
7
|
+
char: {
|
8
|
+
self: "\e[36m",
|
9
|
+
delimiter: "\e[34m"
|
10
|
+
},
|
11
|
+
class: "\e[1;35m",
|
12
|
+
class_variable: "\e[36m",
|
13
|
+
color: "\e[32m",
|
14
|
+
comment: "\e[37m",
|
15
|
+
complex: "\e[34m",
|
16
|
+
constant: "\e[34m\e[4m",
|
17
|
+
decoration: "\e[35m",
|
18
|
+
definition: "\e[1;32m",
|
19
|
+
directive: "\e[32m\e[4m",
|
20
|
+
doc: "\e[46m",
|
21
|
+
doctype: "\e[1;30m",
|
22
|
+
doc_string: "\e[31m\e[4m",
|
23
|
+
entity: "\e[33m",
|
24
|
+
error: "\e[1;33m\e[41m",
|
25
|
+
exception: "\e[1;31m",
|
26
|
+
float: "\e[1;35m",
|
27
|
+
function: "\e[1;34m",
|
28
|
+
global_variable: "\e[42m",
|
29
|
+
hex: "\e[1;36m",
|
30
|
+
include: "\e[33m",
|
31
|
+
integer: "\e[1;34m",
|
32
|
+
key: "\e[35m",
|
33
|
+
label: "\e[1;15m",
|
34
|
+
local_variable: "\e[33m",
|
35
|
+
octal: "\e[1;35m",
|
36
|
+
operator_name: "\e[1;29m",
|
37
|
+
predefined_constant: "\e[1;36m",
|
38
|
+
predefined_type: "\e[1;30m",
|
39
|
+
predefined: "\e[4m\e[1;34m",
|
40
|
+
preprocessor: "\e[36m",
|
41
|
+
pseudo_class: "\e[34m",
|
42
|
+
regexp: {
|
43
|
+
self: "\e[31m",
|
44
|
+
content: "\e[31m",
|
45
|
+
delimiter: "\e[1;29m",
|
46
|
+
modifier: "\e[35m",
|
47
|
+
function: "\e[1;29m"
|
48
|
+
},
|
49
|
+
reserved: "\e[1;31m",
|
50
|
+
shell: {
|
51
|
+
self: "\e[42m",
|
52
|
+
content: "\e[1;29m",
|
53
|
+
delimiter: "\e[37m",
|
54
|
+
},
|
55
|
+
string: {
|
56
|
+
self: "\e[36m",
|
57
|
+
modifier: "\e[1;32m",
|
58
|
+
escape: "\e[1;36m",
|
59
|
+
delimiter: "\e[1;32m",
|
60
|
+
},
|
61
|
+
symbol: "\e[1;31m",
|
62
|
+
tag: "\e[34m",
|
63
|
+
type: "\e[1;34m",
|
64
|
+
value: "\e[36m",
|
65
|
+
variable: "\e[34m",
|
66
|
+
|
67
|
+
insert: "\e[42m",
|
68
|
+
delete: "\e[41m",
|
69
|
+
change: "\e[44m",
|
70
|
+
head: "\e[45m"
|
71
|
+
}.freeze
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
module CodeRay
|
3
|
+
UNESCAPED_COLORS = {
|
4
|
+
attribute_name: '33',
|
5
|
+
attribute_value: '31',
|
6
|
+
binary: '1;35',
|
7
|
+
char: {
|
8
|
+
self: '36',
|
9
|
+
delimiter: '34'
|
10
|
+
},
|
11
|
+
class: '1;35',
|
12
|
+
class_variable: '36',
|
13
|
+
color: '32',
|
14
|
+
comment: '37',
|
15
|
+
complex: '34',
|
16
|
+
constant: ['34', '4'],
|
17
|
+
decoration: '35',
|
18
|
+
definition: '1;32',
|
19
|
+
directive: ['32', '4'],
|
20
|
+
doc: '46',
|
21
|
+
doctype: '1;30',
|
22
|
+
doc_string: ['31', '4'],
|
23
|
+
entity: '33',
|
24
|
+
error: ['1;33', '41'],
|
25
|
+
exception: '1;31',
|
26
|
+
float: '1;35',
|
27
|
+
function: '1;34',
|
28
|
+
global_variable: '42',
|
29
|
+
hex: '1;36',
|
30
|
+
include: '33',
|
31
|
+
integer: '1;34',
|
32
|
+
key: '35',
|
33
|
+
label: '1;15',
|
34
|
+
local_variable: '33',
|
35
|
+
octal: '1;35',
|
36
|
+
operator_name: '1;29',
|
37
|
+
predefined_constant: '1;36',
|
38
|
+
predefined_type: '1;30',
|
39
|
+
predefined: ['4', '1;34'],
|
40
|
+
preprocessor: '36',
|
41
|
+
pseudo_class: '34',
|
42
|
+
regexp: {
|
43
|
+
self: '31',
|
44
|
+
content: '31',
|
45
|
+
delimiter: '1;29',
|
46
|
+
modifier: '35',
|
47
|
+
function: '1;29'
|
48
|
+
},
|
49
|
+
reserved: '1;31',
|
50
|
+
shell: {
|
51
|
+
self: '42',
|
52
|
+
content: '1;29',
|
53
|
+
delimiter: '37',
|
54
|
+
},
|
55
|
+
string: {
|
56
|
+
self: '36',
|
57
|
+
modifier: '1;32',
|
58
|
+
escape: '1;36',
|
59
|
+
delimiter: '1;32',
|
60
|
+
},
|
61
|
+
symbol: '1;31',
|
62
|
+
tag: '34',
|
63
|
+
type: '1;34',
|
64
|
+
value: '36',
|
65
|
+
variable: '34',
|
66
|
+
|
67
|
+
insert: '42',
|
68
|
+
delete: '41',
|
69
|
+
change: '44',
|
70
|
+
head: '45'
|
71
|
+
}.freeze
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
module Commands
|
3
|
+
CALLER_METHOD = Pry::CommandSet.new do
|
4
|
+
command "caller_method" do |depth|
|
5
|
+
depth = depth.to_i || 1
|
6
|
+
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ caller(depth+1).first
|
7
|
+
file = Regexp.last_match[1]
|
8
|
+
line = Regexp.last_match[2].to_i
|
9
|
+
method = Regexp.last_match[3]
|
10
|
+
output.puts [file, line, method]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
module Commands
|
3
|
+
SQL = Pry::CommandSet.new do
|
4
|
+
command "sql", "Send sql over AR." do |query|
|
5
|
+
if defined?(Rails)
|
6
|
+
pp ActiveRecord::Base.connection.select_all(query)
|
7
|
+
else
|
8
|
+
pp "Rails not defined"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module JazzFingers
|
2
2
|
class Configuration
|
3
3
|
attr_writer :colored_prompt, :prompt_separator, :coolline, :awesome_print,
|
4
|
-
|
4
|
+
:application_name
|
5
5
|
|
6
6
|
# Color the prompt?
|
7
7
|
#
|
@@ -23,7 +23,7 @@ module JazzFingers
|
|
23
23
|
# Default: right angle quote, or '>' when using rb-readline which doesn't
|
24
24
|
# handle mixed encodings well.
|
25
25
|
def prompt_separator
|
26
|
-
@prompt_separator ||= defined?(RbReadline) ?
|
26
|
+
@prompt_separator ||= defined?(RbReadline) ? '>' : "\u00BB"
|
27
27
|
end
|
28
28
|
|
29
29
|
def coolline?
|
@@ -39,23 +39,29 @@ module JazzFingers
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def application_name
|
42
|
-
return
|
42
|
+
return underscore(@application_name) unless @application_name.nil?
|
43
43
|
|
44
44
|
if defined?(Rails)
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
application_class = Rails.application.class
|
46
|
+
|
47
|
+
if application_class.respond_to?(:module_parent_name)
|
48
|
+
application_class.module_parent_name.underscore
|
49
|
+
else
|
50
|
+
application_class.parent_name.underscore
|
51
|
+
end
|
48
52
|
end
|
53
|
+
|
54
|
+
"jazz_fingers"
|
49
55
|
end
|
50
56
|
|
51
57
|
private
|
52
58
|
|
53
59
|
def underscore(camel_cased_word)
|
54
|
-
camel_cased_word.to_s.gsub(/::/, '/')
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
60
|
+
camel_cased_word.to_s.gsub(/::/, '/')
|
61
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
62
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
63
|
+
.tr('-', '_')
|
64
|
+
.downcase
|
59
65
|
end
|
60
66
|
end
|
61
67
|
end
|
data/lib/jazz_fingers/input.rb
CHANGED
data/lib/jazz_fingers/print.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'awesome_print'
|
2
2
|
|
3
3
|
module JazzFingers
|
4
4
|
class Print
|
5
5
|
class << self
|
6
6
|
def config
|
7
7
|
lambda do |_output, value, pry_object|
|
8
|
-
|
9
|
-
pretty = value.ai(indent: 2)
|
8
|
+
pretty = value.ai
|
10
9
|
pry_object.pager.page("=> #{pretty}\n")
|
11
10
|
end
|
12
11
|
end
|
data/lib/jazz_fingers/prompt.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module JazzFingers
|
2
4
|
class Prompt
|
5
|
+
OBJECT_INSTANCE = /#<(.+)>/
|
6
|
+
|
7
|
+
autoload :PryVersion013AndLater, 'jazz_fingers/prompt/pry_version_013_and_later'
|
8
|
+
autoload :PryVersion012AndPrior, 'jazz_fingers/prompt/pry_version_012_and_prior'
|
9
|
+
|
10
|
+
if Pry::VERSION >= "0.13.0"
|
11
|
+
include PryVersion013AndLater
|
12
|
+
else
|
13
|
+
include PryVersion012AndPrior
|
14
|
+
end
|
15
|
+
|
3
16
|
def initialize(options = {})
|
4
17
|
@colored = options.fetch(:colored)
|
5
18
|
@separator = options.fetch(:separator)
|
@@ -28,44 +41,75 @@ module JazzFingers
|
|
28
41
|
"\001\e[1m\002#{text}\001\e[0m\002"
|
29
42
|
end
|
30
43
|
|
31
|
-
def
|
44
|
+
def main_separator
|
32
45
|
red_text(@separator)
|
33
46
|
end
|
34
47
|
|
35
|
-
def
|
36
|
-
|
48
|
+
def wait_separator
|
49
|
+
"*"
|
37
50
|
end
|
38
51
|
|
39
|
-
|
40
|
-
|
41
|
-
|
52
|
+
# Return the current Pry context
|
53
|
+
#
|
54
|
+
# When the Pry context is `"main"` or `"nil"`, use the application name from
|
55
|
+
# the JazzFingers config. Examples: "(my_rails_app_name)", "(jazz_fingers)".
|
56
|
+
#
|
57
|
+
# When in the context of an object instance, use the abbreviated object
|
58
|
+
# path. Example: "(#<Pry::Prompt>)", "(#<RSpec::...::ClassName>)"
|
59
|
+
#
|
60
|
+
# Fall back to the raw context provided by Pry.view_clip.
|
61
|
+
# Example: "(Pry::Prompt)"
|
62
|
+
def context(module_name = "main")
|
63
|
+
name =
|
64
|
+
case module_name
|
65
|
+
when "main", "nil"
|
66
|
+
@application_name
|
67
|
+
when OBJECT_INSTANCE
|
68
|
+
abbreviated_context(module_name)
|
69
|
+
else
|
70
|
+
module_name
|
71
|
+
end
|
42
72
|
|
43
|
-
|
44
|
-
|
45
|
-
text = Pry.view_clip(object)
|
73
|
+
blue_text("(#{name})")
|
74
|
+
end
|
46
75
|
|
47
|
-
|
48
|
-
|
76
|
+
def line_number(pry)
|
77
|
+
if pry.respond_to? :input_ring
|
78
|
+
bold_text(pry.input_ring.size)
|
49
79
|
else
|
50
|
-
|
80
|
+
bold_text(pry.input_array.size)
|
51
81
|
end
|
52
82
|
end
|
53
83
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
84
|
+
# Abbreviate the object path in the given `object_label` string so the
|
85
|
+
# prompt doesn't overflow. Display only the root and leaf namespaces.
|
86
|
+
#
|
87
|
+
# Examples:
|
88
|
+
# In: #<Class1::Class2::Class3::Class4::Class5>
|
89
|
+
# Out: #<Class1::...::Class5>
|
90
|
+
#
|
91
|
+
# In: #<Class1::Class2>
|
92
|
+
# Out: #<Class1::Class2>
|
93
|
+
#
|
94
|
+
# In: #<NoPathJustASingleLongClassName>
|
95
|
+
# Out: #<NoPathJustASingleLongClassName>
|
96
|
+
def abbreviated_context(object_label)
|
97
|
+
object_path = object_label[OBJECT_INSTANCE, 1]
|
98
|
+
object_path_components = object_path.split("::")
|
99
|
+
return object_label if object_path_components.length <= 2
|
59
100
|
|
60
|
-
|
61
|
-
|
62
|
-
spaces = " " * level
|
63
|
-
"#{RUBY_VERSION} #{name}#{line_number(pry)} * #{spaces}"
|
64
|
-
end
|
101
|
+
root, *_, leaf = object_path_components
|
102
|
+
"#<#{root}::...::#{leaf}>"
|
65
103
|
end
|
66
104
|
|
67
|
-
def
|
68
|
-
|
105
|
+
def template(module_name, pry, separator)
|
106
|
+
format(
|
107
|
+
"%<ruby>s %<context>s[%<line>s] %<separator>s ",
|
108
|
+
ruby: RUBY_VERSION,
|
109
|
+
context: context(module_name),
|
110
|
+
line: line_number(pry),
|
111
|
+
separator: separator
|
112
|
+
)
|
69
113
|
end
|
70
114
|
end
|
71
115
|
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,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jazz_fingers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paulo Henrique Lopes Ribeiro
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: awesome_print
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: pry
|
28
|
+
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.10'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry-byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.4'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: hirb
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.7'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.7'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: pry-coolline
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0.2'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: awesome_print
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '1.6'
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '1.6'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: rubocop
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +81,7 @@ dependencies:
|
|
109
81
|
- !ruby/object:Gem::Version
|
110
82
|
version: '0'
|
111
83
|
description: Spending hours in the ruby console? Spruce it up and show off those hard-working
|
112
|
-
hands!
|
84
|
+
hands! jazz_fingersreplaces IRB with Pry, improves output through awesome_print,
|
113
85
|
and has some other goodies up its sleeves.
|
114
86
|
email: plribeiro3000@gmail.com
|
115
87
|
executables: []
|
@@ -130,18 +102,26 @@ files:
|
|
130
102
|
- Rakefile
|
131
103
|
- jazz_fingers.gemspec
|
132
104
|
- lib/jazz_fingers.rb
|
105
|
+
- lib/jazz_fingers/awesome_print.rb
|
106
|
+
- lib/jazz_fingers/coderay.rb
|
107
|
+
- lib/jazz_fingers/coderay/escaped_colors.rb
|
108
|
+
- lib/jazz_fingers/coderay/unescaped_colors.rb
|
109
|
+
- lib/jazz_fingers/commands.rb
|
110
|
+
- lib/jazz_fingers/commands/caller_method.rb
|
111
|
+
- lib/jazz_fingers/commands/copy.rb
|
112
|
+
- lib/jazz_fingers/commands/sql.rb
|
133
113
|
- lib/jazz_fingers/configuration.rb
|
134
|
-
- lib/jazz_fingers/hirb_ext.rb
|
135
114
|
- lib/jazz_fingers/input.rb
|
136
115
|
- lib/jazz_fingers/print.rb
|
137
116
|
- lib/jazz_fingers/prompt.rb
|
138
|
-
- lib/jazz_fingers/
|
117
|
+
- lib/jazz_fingers/prompt/pry_version_012_and_prior.rb
|
118
|
+
- lib/jazz_fingers/prompt/pry_version_013_and_later.rb
|
139
119
|
- lib/jazz_fingers/version.rb
|
140
120
|
homepage: https://github.com/plribeiro3000/jazz_fingers
|
141
121
|
licenses:
|
142
122
|
- MIT
|
143
123
|
metadata: {}
|
144
|
-
post_install_message:
|
124
|
+
post_install_message:
|
145
125
|
rdoc_options: []
|
146
126
|
require_paths:
|
147
127
|
- lib
|
@@ -156,10 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
136
|
- !ruby/object:Gem::Version
|
157
137
|
version: '0'
|
158
138
|
requirements: []
|
159
|
-
|
160
|
-
|
161
|
-
signing_key:
|
139
|
+
rubygems_version: 3.1.3
|
140
|
+
signing_key:
|
162
141
|
specification_version: 4
|
163
142
|
summary: Exercise those fingers. Pry-based enhancements for the default Ruby console.
|
164
143
|
test_files: []
|
165
|
-
has_rdoc:
|
data/.hound.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
Metrics/LineLength:
|
2
|
-
Enabled: false
|
3
|
-
|
4
|
-
Style/EachWithObject:
|
5
|
-
Enabled: false
|
6
|
-
|
7
|
-
Style/Encoding:
|
8
|
-
EnforcedStyle: when_needed
|
9
|
-
|
10
|
-
Style/FormatString:
|
11
|
-
Enabled: false
|
12
|
-
|
13
|
-
Style/SignalException:
|
14
|
-
EnforcedStyle: only_raise
|
15
|
-
|
16
|
-
Style/StringLiterals:
|
17
|
-
EnforcedStyle: double_quotes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class << Hirb::View
|
2
|
-
alias_method :enable_output_method_existing, :enable_output_method
|
3
|
-
alias_method :disable_output_method_existing, :disable_output_method
|
4
|
-
|
5
|
-
def enable_output_method
|
6
|
-
@output_method = true
|
7
|
-
JazzFingers.config.awesome_print = true
|
8
|
-
enable_output_method_existing
|
9
|
-
end
|
10
|
-
|
11
|
-
def disable_output_method
|
12
|
-
JazzFingers.config.awesome_print = false
|
13
|
-
disable_output_method_existing
|
14
|
-
end
|
15
|
-
end
|
data/lib/jazz_fingers/setup.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# JazzFingers dance
|
2
|
-
Pry.print = JazzFingers.print if JazzFingers.config.awesome_print?
|
3
|
-
Pry.prompt = JazzFingers.prompt
|
4
|
-
Pry.input = JazzFingers.input if JazzFingers.config.coolline?
|
5
|
-
Pry.config.should_load_plugins = false
|
6
|
-
|
7
|
-
# Command Shortcuts
|
8
|
-
Pry.commands.alias_command("c", "continue")
|
9
|
-
Pry.commands.alias_command("s", "step")
|
10
|
-
Pry.commands.alias_command("n", "next")
|