jazz_fingers 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.hound.yml +0 -3
- data/.rubocop.yml +0 -3
- data/CHANGELOG.md +15 -1
- data/Gemfile +1 -1
- data/README.md +12 -9
- data/Rakefile +1 -1
- data/jazz_fingers.gemspec +19 -20
- data/lib/jazz_fingers/configuration.rb +40 -0
- data/lib/jazz_fingers/hirb_ext.rb +2 -5
- data/lib/jazz_fingers/input.rb +27 -0
- data/lib/jazz_fingers/print.rb +15 -0
- data/lib/jazz_fingers/prompt.rb +76 -0
- data/lib/jazz_fingers/setup.rb +9 -0
- data/lib/jazz_fingers/version.rb +1 -1
- data/lib/jazz_fingers.rb +30 -26
- metadata +17 -33
- data/lib/jazz_fingers/railtie.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaecd076918e8c0a873af5007079f239c6da8b94
|
4
|
+
data.tar.gz: 19fb8b5fdb8ef30f55e9737f9bcb6344dc2253b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6e8dc5f3708373499ac583f108d7fd55ae4b6efca65a5af5b8c65f1345ce49300ef2d832a6556aa1ef03c39f89a7581b65c67c45ad575d8a4cb8bbf7d61a58d
|
7
|
+
data.tar.gz: 52ca34d63cbb53f6580728581edd113ea56b588ed9addbceea459f72327172243c004e0dcd8ca810d04bc934f3259322894b50199b922e60f6d2cb9889382158
|
data/.hound.yml
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,20 @@
|
|
1
|
+
## 2.0.0 (2015-05-31)
|
2
|
+
|
3
|
+
* Add alias to the most used commands
|
4
|
+
* Update [pry-byebug][pry-byebug] to ~> v3.1
|
5
|
+
* Improve abstraction by creating models to handle specific responsibilities
|
6
|
+
* Add configuration to enable/disable [pry-coolline][pry-coolline]
|
7
|
+
* Add configuration to enable/disable [awesome_print][awesome_print]
|
8
|
+
* Remove [pry-rails][pry-rails] dependency
|
9
|
+
* Remove [railties][railties] dependency
|
10
|
+
|
11
|
+
## 1.0.0 (2015-02-05)
|
12
|
+
* Downgrade [pry-byebug][pry-byebug] to v1.3.3
|
13
|
+
|
1
14
|
## 0.5.5 (2015-02-03)
|
2
15
|
|
3
16
|
* Update [pry-byebug][pry-byebug] to v2.0.0
|
4
|
-
* Update [
|
17
|
+
* Update [awesome_print][awesome_print] to v1.6.1
|
5
18
|
|
6
19
|
## 0.5.4 (2014-11-06)
|
7
20
|
|
@@ -139,3 +152,4 @@
|
|
139
152
|
[pry-debugger]: https://github.com/nixme/pry-debugger
|
140
153
|
[pry-rails]: https://github.com/rweng/pry-rails
|
141
154
|
[pry-byebug]: https://github.com/deivid-rodriguez/pry-byebug
|
155
|
+
[railties]: https://github.com/rails/rails
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,16 +3,14 @@ Jazz Fingers
|
|
3
3
|
|
4
4
|
This repo is a fork, with updates and bug fixes based on [`jazz_hands`](https://github.com/nixme/jazz_hands).
|
5
5
|
|
6
|
-
Spending hours in the
|
7
|
-
hard-working
|
6
|
+
Spending hours in the pry console? Spruce it up and show off those
|
7
|
+
hard-working fingers!
|
8
8
|
|
9
9
|
**jazz_fingers** is an opinionated set of console-related gems and a bit of glue:
|
10
10
|
|
11
11
|
* [**Pry**][pry] for a powerful shell alternative to IRB.
|
12
12
|
* [**Awesome Print**][awesome_print] for stylish pretty print.
|
13
13
|
* [**Hirb**][hirb] for tabular collection output.
|
14
|
-
* [**Pry Rails**][pry-rails] for additional commands (`show-routes`,
|
15
|
-
`show-models`, `show-middleware`) in the Rails console.
|
16
14
|
* [**Pry Doc**][pry-doc] to browse Ruby source, including C, directly from the
|
17
15
|
console.
|
18
16
|
* [**Pry Git**][pry-git] to teach the console about git. Diffs, blames, and
|
@@ -23,7 +21,7 @@ hard-working hands!
|
|
23
21
|
|
24
22
|
## Usage
|
25
23
|
|
26
|
-
Ruby 2.0.0
|
24
|
+
Ruby 2.0.0+. Add to your project Gemfile:
|
27
25
|
|
28
26
|
```ruby
|
29
27
|
group :development, :test do
|
@@ -31,7 +29,7 @@ group :development, :test do
|
|
31
29
|
end
|
32
30
|
```
|
33
31
|
|
34
|
-
That's it. Run `
|
32
|
+
That's it. Run `pry` as usual.
|
35
33
|
|
36
34
|
[Hirb][hirb] isn't enabled by default. To use, run `Hirb.enable` in the console.
|
37
35
|
|
@@ -43,12 +41,18 @@ X) will work but is not recommended.
|
|
43
41
|
|
44
42
|
## Options
|
45
43
|
|
46
|
-
Change the following options by creating an initializer
|
44
|
+
Change the following options by creating an initializer
|
47
45
|
Example `config/initializers/jazz_fingers.rb`:
|
48
46
|
|
49
47
|
```ruby
|
50
48
|
if defined?(JazzFingers)
|
51
|
-
JazzFingers.
|
49
|
+
JazzFingers.configure do |config|
|
50
|
+
config.colored_prompt = false
|
51
|
+
config.awesome_print = false
|
52
|
+
config.coolline = false
|
53
|
+
end
|
54
|
+
|
55
|
+
require 'jazz_fingers/setup'
|
52
56
|
end
|
53
57
|
```
|
54
58
|
|
@@ -70,7 +74,6 @@ mixed encodings.
|
|
70
74
|
[pry]: http://pry.github.com
|
71
75
|
[awesome_print]: https://github.com/michaeldv/awesome_print
|
72
76
|
[hirb]: https://github.com/cldwalker/hirb
|
73
|
-
[pry-rails]: https://github.com/rweng/pry-rails
|
74
77
|
[pry-doc]: https://github.com/pry/pry-doc
|
75
78
|
[pry-git]: https://github.com/pry/pry-git
|
76
79
|
[pry-remote]: https://github.com/Mon-Ouie/pry-remote
|
data/Rakefile
CHANGED
data/jazz_fingers.gemspec
CHANGED
@@ -1,32 +1,31 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path("../lib/jazz_fingers/version", __FILE__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
|
-
gem.name =
|
6
|
+
gem.name = "jazz_fingers"
|
7
7
|
gem.version = JazzFingers::VERSION
|
8
|
-
gem.author =
|
9
|
-
gem.email =
|
10
|
-
gem.license =
|
11
|
-
gem.homepage =
|
12
|
-
gem.summary =
|
8
|
+
gem.author = "Paulo Henrique Lopes Ribeiro"
|
9
|
+
gem.email = "plribeiro3000@gmail.com"
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.homepage = "https://github.com/plribeiro3000/jazz_fingers"
|
12
|
+
gem.summary = "Exercise those fingers. Pry-based enhancements for the default Rails console."
|
13
13
|
gem.description = "Spending hours in the rails console? Spruce it up and show off those hard-working hands! jazz_fingers replaces IRB with Pry, improves output through awesome_print, and has some other goodies up its sleeves."
|
14
14
|
|
15
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
16
16
|
gem.files = `git ls-files`.split("\n")
|
17
17
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
gem.require_paths = [
|
18
|
+
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
# 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
|
27
|
-
gem.add_runtime_dependency
|
28
|
-
gem.add_runtime_dependency
|
29
|
-
gem.add_runtime_dependency
|
30
|
-
gem.
|
31
|
-
gem.add_runtime_dependency 'railties', '>= 3.0', '< 5.0'
|
21
|
+
gem.required_ruby_version = ">= 2.0"
|
22
|
+
gem.add_runtime_dependency "pry", "~> 0.10"
|
23
|
+
gem.add_runtime_dependency "pry-doc", "~> 0.6"
|
24
|
+
gem.add_runtime_dependency "pry-git", "~> 0.2"
|
25
|
+
gem.add_runtime_dependency "pry-remote", ">= 0.1.7"
|
26
|
+
gem.add_runtime_dependency "pry-byebug", "~> 3.1"
|
27
|
+
gem.add_runtime_dependency "hirb", "~> 0.7"
|
28
|
+
gem.add_runtime_dependency "pry-coolline", "~> 0.2"
|
29
|
+
gem.add_runtime_dependency "awesome_print", "~> 1.6"
|
30
|
+
gem.add_development_dependency "rubocop"
|
32
31
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
class Configuration
|
3
|
+
attr_writer :colored_prompt, :prompt_separator, :coolline, :awesome_print
|
4
|
+
|
5
|
+
# Color the prompt?
|
6
|
+
#
|
7
|
+
# A different setting than Pry.color since some may like colored output, but a
|
8
|
+
# plain prompt.
|
9
|
+
#
|
10
|
+
# Default: 'true' for GNU readline or rb-readline which correctly count line
|
11
|
+
# widths with color codes when using \001 and \002 hints. 'false' for
|
12
|
+
# libedit-based wrapper (standard on OS X unless ruby is explicitly compiled
|
13
|
+
# otherwise).
|
14
|
+
def colored_prompt
|
15
|
+
return (Readline::VERSION !~ /EditLine/) && Pry.color if @colored_prompt.nil?
|
16
|
+
|
17
|
+
@colored_prompt
|
18
|
+
end
|
19
|
+
|
20
|
+
# Separator between application name and input in the prompt.
|
21
|
+
#
|
22
|
+
# Default: right angle quote, or '>' when using rb-readline which doesn't
|
23
|
+
# handle mixed encodings well.
|
24
|
+
def prompt_separator
|
25
|
+
@prompt_separator ||= defined?(RbReadline) ? ">" : "\u00BB"
|
26
|
+
end
|
27
|
+
|
28
|
+
def coolline?
|
29
|
+
return false if @coolline.nil?
|
30
|
+
|
31
|
+
@coolline
|
32
|
+
end
|
33
|
+
|
34
|
+
def awesome_print?
|
35
|
+
return true if @awesome_print.nil?
|
36
|
+
|
37
|
+
@awesome_print
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,18 +1,15 @@
|
|
1
|
-
require 'hirb'
|
2
|
-
require 'pry'
|
3
|
-
|
4
1
|
class << Hirb::View
|
5
2
|
alias_method :enable_output_method_existing, :enable_output_method
|
6
3
|
alias_method :disable_output_method_existing, :disable_output_method
|
7
4
|
|
8
5
|
def enable_output_method
|
9
6
|
@output_method = true
|
10
|
-
JazzFingers.
|
7
|
+
JazzFingers.config.awesome_print = true
|
11
8
|
enable_output_method_existing
|
12
9
|
end
|
13
10
|
|
14
11
|
def disable_output_method
|
15
|
-
JazzFingers.
|
12
|
+
JazzFingers.config.awesome_print = false
|
16
13
|
disable_output_method_existing
|
17
14
|
end
|
18
15
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "pry-coolline"
|
2
|
+
require "coderay"
|
3
|
+
|
4
|
+
module JazzFingers
|
5
|
+
class Input
|
6
|
+
class << self
|
7
|
+
def config
|
8
|
+
{
|
9
|
+
cool: cool_input
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def cool_input
|
14
|
+
Coolline.new do |c|
|
15
|
+
c.transform_proc = proc do
|
16
|
+
CodeRay.scan(c.line, :ruby).term
|
17
|
+
end
|
18
|
+
|
19
|
+
c.completion_proc = proc do
|
20
|
+
word = c.completed_word
|
21
|
+
Object.constants.map(&:to_s).select { |w| w.start_with?(word) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "awesome_print"
|
2
|
+
|
3
|
+
module JazzFingers
|
4
|
+
class Print
|
5
|
+
class << self
|
6
|
+
def config
|
7
|
+
lambda do |_output, value, pry_object|
|
8
|
+
return if Hirb::View.view_or_page_output(value)
|
9
|
+
pretty = value.ai(indent: 2)
|
10
|
+
pry_object.pager.page("=> #{pretty}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module JazzFingers
|
2
|
+
class Prompt
|
3
|
+
def initialize(options = {})
|
4
|
+
@colored = options.fetch(:colored)
|
5
|
+
@separator = options.fetch(:separator)
|
6
|
+
end
|
7
|
+
|
8
|
+
def colored?
|
9
|
+
@colored
|
10
|
+
end
|
11
|
+
|
12
|
+
def red_text(text)
|
13
|
+
return text.to_s unless colored?
|
14
|
+
|
15
|
+
"\001\e[0;31m\002#{text}\001\e[0m\002"
|
16
|
+
end
|
17
|
+
|
18
|
+
def blue_text(text)
|
19
|
+
return text.to_s unless colored?
|
20
|
+
|
21
|
+
"\001\e[0;34m\002#{text}\001\e[0m\002"
|
22
|
+
end
|
23
|
+
|
24
|
+
def bold_text(text)
|
25
|
+
return text.to_s unless colored?
|
26
|
+
|
27
|
+
"\001\e[1m\002#{text}\001\e[0m\002"
|
28
|
+
end
|
29
|
+
|
30
|
+
def separator
|
31
|
+
red_text(@separator)
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
if respond_to?(:app)
|
36
|
+
name = "(#{app.class.parent_name.underscore})"
|
37
|
+
else
|
38
|
+
name = "(jazz_fingers)"
|
39
|
+
end
|
40
|
+
|
41
|
+
blue_text(name)
|
42
|
+
end
|
43
|
+
|
44
|
+
def line_number(pry)
|
45
|
+
"[#{bold_text(pry.input_array.size)}]"
|
46
|
+
end
|
47
|
+
|
48
|
+
def text(object, level)
|
49
|
+
level = 0 if level < 0
|
50
|
+
text = Pry.view_clip(object)
|
51
|
+
|
52
|
+
if text == "main"
|
53
|
+
""
|
54
|
+
else
|
55
|
+
"(#{'../' * level}#{text})"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def main_prompt
|
60
|
+
lambda do |_object, _level, pry|
|
61
|
+
"#{RUBY_VERSION} #{name}#{line_number(pry)} #{separator} "
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def block_prompt
|
66
|
+
lambda do |_object, level, pry|
|
67
|
+
spaces = " " * level
|
68
|
+
"#{RUBY_VERSION} #{name}#{line_number(pry)} * #{spaces}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def config
|
73
|
+
[main_prompt, block_prompt]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,9 @@
|
|
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
|
+
|
6
|
+
# Command Shortcuts
|
7
|
+
Pry.commands.alias_command('c', 'continue')
|
8
|
+
Pry.commands.alias_command('s', 'step')
|
9
|
+
Pry.commands.alias_command('n', 'next')
|
data/lib/jazz_fingers/version.rb
CHANGED
data/lib/jazz_fingers.rb
CHANGED
@@ -1,34 +1,38 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "hirb"
|
2
|
+
require "pry"
|
3
|
+
require "pry-doc"
|
4
|
+
require "pry-git"
|
5
|
+
require "pry-remote"
|
6
|
+
require "readline"
|
7
|
+
require "jazz_fingers/hirb_ext"
|
5
8
|
|
6
9
|
module JazzFingers
|
10
|
+
autoload :Configuration, "jazz_fingers/configuration"
|
11
|
+
autoload :Input, "jazz_fingers/input"
|
12
|
+
autoload :Print, "jazz_fingers/print"
|
13
|
+
autoload :Prompt, "jazz_fingers/prompt"
|
14
|
+
autoload :VERSION, "jazz_fingers/version"
|
7
15
|
|
8
|
-
|
16
|
+
class << self
|
17
|
+
def print
|
18
|
+
@print ||= Print.config
|
19
|
+
end
|
9
20
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
# Default: 'true' for GNU readline or rb-readline which correctly count line
|
16
|
-
# widths with color codes when using \001 and \002 hints. 'false' for
|
17
|
-
# libedit-based wrapper (standard on OS X unless ruby is explicitly compiled
|
18
|
-
# otherwise).
|
19
|
-
#
|
20
|
-
mattr_accessor :colored_prompt
|
21
|
-
self.colored_prompt = (Readline::VERSION !~ /EditLine/)
|
21
|
+
def prompt
|
22
|
+
@prompt ||= Prompt.new(colored: config.colored_prompt, separator: config.prompt_separator)
|
23
|
+
@prompt.config
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
# handle mixed encodings well.
|
27
|
-
#
|
28
|
-
mattr_accessor :prompt_separator
|
29
|
-
self.prompt_separator = defined?(RbReadline) ? '>' : "\u00BB"
|
26
|
+
def input
|
27
|
+
@input ||= Input.config
|
28
|
+
end
|
30
29
|
|
31
|
-
|
30
|
+
def configure
|
31
|
+
yield @config ||= Configuration.new
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
+
def config
|
35
|
+
@config ||= Configuration.new
|
36
|
+
end
|
37
|
+
end
|
34
38
|
end
|
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:
|
4
|
+
version: 2.0.0
|
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: 2015-
|
11
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.10'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: pry-rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.3'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.3'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: pry-doc
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +70,16 @@ dependencies:
|
|
84
70
|
name: pry-byebug
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- -
|
73
|
+
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
75
|
+
version: '3.1'
|
90
76
|
type: :runtime
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- -
|
80
|
+
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
82
|
+
version: '3.1'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: hirb
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,34 +114,28 @@ dependencies:
|
|
128
114
|
requirements:
|
129
115
|
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.6
|
117
|
+
version: '1.6'
|
132
118
|
type: :runtime
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.6
|
124
|
+
version: '1.6'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
126
|
+
name: rubocop
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - ">="
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
146
|
-
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: '5.0'
|
149
|
-
type: :runtime
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
150
133
|
prerelease: false
|
151
134
|
version_requirements: !ruby/object:Gem::Requirement
|
152
135
|
requirements:
|
153
136
|
- - ">="
|
154
137
|
- !ruby/object:Gem::Version
|
155
|
-
version: '
|
156
|
-
- - "<"
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '5.0'
|
138
|
+
version: '0'
|
159
139
|
description: Spending hours in the rails console? Spruce it up and show off those
|
160
140
|
hard-working hands! jazz_fingers replaces IRB with Pry, improves output through
|
161
141
|
awesome_print, and has some other goodies up its sleeves.
|
@@ -178,8 +158,12 @@ files:
|
|
178
158
|
- Rakefile
|
179
159
|
- jazz_fingers.gemspec
|
180
160
|
- lib/jazz_fingers.rb
|
161
|
+
- lib/jazz_fingers/configuration.rb
|
181
162
|
- lib/jazz_fingers/hirb_ext.rb
|
182
|
-
- lib/jazz_fingers/
|
163
|
+
- lib/jazz_fingers/input.rb
|
164
|
+
- lib/jazz_fingers/print.rb
|
165
|
+
- lib/jazz_fingers/prompt.rb
|
166
|
+
- lib/jazz_fingers/setup.rb
|
183
167
|
- lib/jazz_fingers/version.rb
|
184
168
|
homepage: https://github.com/plribeiro3000/jazz_fingers
|
185
169
|
licenses:
|
data/lib/jazz_fingers/railtie.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'awesome_print'
|
2
|
-
require 'pry'
|
3
|
-
require 'pry-coolline'
|
4
|
-
require 'pry-doc'
|
5
|
-
require 'pry-git'
|
6
|
-
require 'pry-rails'
|
7
|
-
require 'pry-remote'
|
8
|
-
require 'jazz_fingers/hirb_ext'
|
9
|
-
|
10
|
-
module JazzFingers
|
11
|
-
class Railtie < Rails::Railtie
|
12
|
-
initializer 'jazz_fingers.initialize' do |app|
|
13
|
-
silence_warnings do
|
14
|
-
# We're managing the loading of plugins. So don't let pry autoload them.
|
15
|
-
Pry.config.should_load_plugins = false
|
16
|
-
|
17
|
-
# Use awesome_print for output, but keep pry's pager. If Hirb is
|
18
|
-
# enabled, try printing with it first.
|
19
|
-
Pry.config.print = ->(_output, value, _pry_) do
|
20
|
-
return if JazzFingers._hirb_output && Hirb::View.view_or_page_output(value)
|
21
|
-
pretty = value.ai(indent: 2)
|
22
|
-
_pry_.pager.page("=> #{pretty}")
|
23
|
-
end
|
24
|
-
|
25
|
-
# Friendlier prompt - line number, app name, nesting levels look like
|
26
|
-
# directory paths.
|
27
|
-
#
|
28
|
-
# Heavy use of lazy lambdas so configuration (like Pry.color) can be
|
29
|
-
# changed later or even during console usage.
|
30
|
-
#
|
31
|
-
# Custom color helpers using hints \001 and \002 so that good readline
|
32
|
-
# libraries (GNU, rb-readline) correctly ignore color codes when
|
33
|
-
# calculating line length.
|
34
|
-
|
35
|
-
color = -> { Pry.color && JazzFingers.colored_prompt }
|
36
|
-
red = ->(text) { color[] ? "\001\e[0;31m\002#{text}\001\e[0m\002" : text.to_s }
|
37
|
-
blue = ->(text) { color[] ? "\001\e[0;34m\002#{text}\001\e[0m\002" : text.to_s }
|
38
|
-
bold = ->(text) { color[] ? "\001\e[1m\002#{text}\001\e[0m\002" : text.to_s }
|
39
|
-
|
40
|
-
separator = -> { red.(JazzFingers.prompt_separator) }
|
41
|
-
name = app.class.parent_name.underscore
|
42
|
-
colored_name = -> { blue.(name) }
|
43
|
-
|
44
|
-
line = ->(pry) { "[#{bold.(pry.input_array.size)}] " }
|
45
|
-
target_string = ->(object, level) do
|
46
|
-
level = 0 if level < 0
|
47
|
-
unless (string = Pry.view_clip(object)) == 'main'
|
48
|
-
"(#{'../' * level}#{string})"
|
49
|
-
else
|
50
|
-
''
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
Pry.config.prompt = [
|
55
|
-
->(object, level, pry) do # Main prompt
|
56
|
-
"#{line.(pry)}#{colored_name.()}#{target_string.(object, level)} #{separator.()} "
|
57
|
-
end,
|
58
|
-
->(object, level, pry) do # Wait prompt in multiline input
|
59
|
-
spaces = ' ' * (
|
60
|
-
"[#{pry.input_array.size}] ".size + # Uncolored `line.(pry)`
|
61
|
-
name.size +
|
62
|
-
target_string.(object, level).size
|
63
|
-
)
|
64
|
-
"#{spaces} #{separator.()} "
|
65
|
-
end
|
66
|
-
]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|