jazzhands 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42f3f4ac6e9bcb57824e89a3b85196242d916d64
4
- data.tar.gz: c31b8e1b3e456e3aa3c3e48f1913683f25b8afc1
3
+ metadata.gz: 47a61ff0764c2b6f3a8d5e86bf66dd4c08342640
4
+ data.tar.gz: 297fed33931e1493e9446f946f20f6b222aadcda
5
5
  SHA512:
6
- metadata.gz: ba11610497b6d464ec00c112cd5a595b971f4a2782b81f876616c829e6be2551a8e8859f44f1cdfee933a8025d7c19c40c85286241f14b3840e0eed8237c3c2f
7
- data.tar.gz: 614bb2b48f2b6b79ec9a73238f9d712a99826c9c8fecbc2263442637cac49228f83a2adff8edc21ed27f4bdf5dac64247047bd774a83515e9164c7c83c49bb95
6
+ metadata.gz: 8393d56f2faf8768e925f6bbd36d8ecafda938f31bb97de5771f199e4ec8896dea15e834c7fce6cdd532423f648298aabeb8a82c042f0f55765ac1eb56e09aa1
7
+ data.tar.gz: 1c7913bb5234d1d9be5cd1d9ef7be23b3c09c68f42ef8335e3f439343c1d6346804b49f4816ff66c9fec82cf9a7fe3aeda2080df79bffbe29eefde8ef689aec8
data/lib/jazzhands.rb CHANGED
@@ -1,66 +1 @@
1
1
  require 'jazzhands/version'
2
- require 'jazzhands/railtie' if defined?(Rails)
3
- require 'active_support'
4
- require 'readline'
5
-
6
- module Jazzhands
7
-
8
- ### Options ###
9
-
10
- # Color the prompt?
11
- #
12
- # A different setting than Pry.color since some may like colored output, but a
13
- # plain prompt.
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/)
22
-
23
- # Separator between application name and input in the prompt.
24
- #
25
- # Default: right angle quote, or '>' when using rb-readline which doesn't
26
- # handle mixed encodings well.
27
- #
28
- mattr_accessor :prompt_separator
29
- self.prompt_separator = defined?(RbReadline) ? '>' : "\u00BB"
30
-
31
-
32
- class << self
33
- # Enable syntax highlighting as you type in the Rails console via coolline and
34
- # coderay (MRI 1.9.3+ only). Disabled by default as it's a bit buggy.
35
- #
36
- # Call from a Rails initializer:
37
- #
38
- # Jazzhands.enable_syntax_highlighting_as_you_type!
39
- #
40
- def enable_syntax_highlighting_as_you_type!
41
- raise 'Syntax highlighting only supported on 1.9.3+' unless RUBY_VERSION >= '1.9.3'
42
-
43
- # Use coolline with CodeRay for syntax highlighting as you type.
44
- # Only works on >= 1.9.3 because coolline depends on io/console.
45
-
46
- require 'coolline'
47
- require 'coderay'
48
-
49
- Pry.config.input = Coolline.new do |c|
50
- c.transform_proc = proc do
51
- CodeRay.scan(c.line, :ruby).term
52
- end
53
-
54
- c.completion_proc = proc do
55
- word = c.completed_word
56
- Object.constants.map(&:to_s).select { |w| w.start_with? word }
57
- end
58
- end
59
- end
60
- alias :enable_syntax_highlighting_as_you_type :enable_syntax_highlighting_as_you_type!
61
- end
62
-
63
- ### Internal methods ###
64
-
65
- mattr_accessor :_hirb_output
66
- end
@@ -1,3 +1,3 @@
1
1
  module Jazzhands
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jazzhands
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Davis
@@ -182,8 +182,6 @@ files:
182
182
  - Rakefile
183
183
  - jazzhands.gemspec
184
184
  - lib/jazzhands.rb
185
- - lib/jazzhands/hirb_ext.rb
186
- - lib/jazzhands/railtie.rb
187
185
  - lib/jazzhands/version.rb
188
186
  homepage: https://github.com/daviddavis/jazzhands
189
187
  licenses:
@@ -1,18 +0,0 @@
1
- require 'hirb'
2
- require 'pry'
3
-
4
- class << Hirb::View
5
- alias_method :enable_output_method_existing, :enable_output_method
6
- alias_method :disable_output_method_existing, :disable_output_method
7
-
8
- def enable_output_method
9
- @output_method = true
10
- Jazzhands._hirb_output = true
11
- enable_output_method_existing
12
- end
13
-
14
- def disable_output_method
15
- Jazzhands._hirb_output = false
16
- disable_output_method_existing
17
- end
18
- end
@@ -1,72 +0,0 @@
1
- require 'pry'
2
- require 'pry-rails'
3
- require 'pry-doc'
4
- require 'pry-git'
5
- require 'pry-remote'
6
- require 'pry-stack_explorer'
7
- require 'awesome_print'
8
- require 'jazz_hands/hirb_ext'
9
- require 'pry-debugger'
10
-
11
-
12
- module Jazzhands
13
- class Railtie < Rails::Railtie
14
- initializer 'jazz_hands.initialize' do |app|
15
- silence_warnings do
16
- # We're managing the loading of plugins. So don't let pry autoload them.
17
- Pry.config.should_load_plugins = false
18
-
19
- # Use awesome_print for output, but keep pry's pager. If Hirb is
20
- # enabled, try printing with it first.
21
- Pry.config.print = ->(output, value) do
22
- return if Jazzhands._hirb_output && Hirb::View.view_or_page_output(value)
23
- pretty = value.ai(indent: 2)
24
- Pry::Helpers::BaseHelpers.stagger_output("=> #{pretty}", output)
25
- end
26
-
27
- # Friendlier prompt - line number, app name, nesting levels look like
28
- # directory paths.
29
- #
30
- # Heavy use of lazy lambdas so configuration (like Pry.color) can be
31
- # changed later or even during console usage.
32
- #
33
- # Custom color helpers using hints \001 and \002 so that good readline
34
- # libraries (GNU, rb-readline) correctly ignore color codes when
35
- # calculating line length.
36
-
37
- color = -> { Pry.color && Jazzhands.colored_prompt }
38
- red = ->(text) { color[] ? "\001\e[0;31m\002#{text}\001\e[0m\002" : text.to_s }
39
- blue = ->(text) { color[] ? "\001\e[0;34m\002#{text}\001\e[0m\002" : text.to_s }
40
- bold = ->(text) { color[] ? "\001\e[1m\002#{text}\001\e[0m\002" : text.to_s }
41
-
42
- separator = -> { red.(Jazzhands.prompt_separator) }
43
- name = app.class.parent_name.underscore
44
- colored_name = -> { blue.(name) }
45
-
46
- line = ->(pry) { "[#{bold.(pry.input_array.size)}] " }
47
- target_string = ->(object, level) do
48
- level = 0 if level < 0
49
- unless (string = Pry.view_clip(object)) == 'main'
50
- "(#{'../' * level}#{string})"
51
- else
52
- ''
53
- end
54
- end
55
-
56
- Pry.config.prompt = [
57
- ->(object, level, pry) do # Main prompt
58
- "#{line.(pry)}#{colored_name.()}#{target_string.(object, level)} #{separator.()} "
59
- end,
60
- ->(object, level, pry) do # Wait prompt in multiline input
61
- spaces = ' ' * (
62
- "[#{pry.input_array.size}] ".size + # Uncolored `line.(pry)`
63
- name.size +
64
- target_string.(object, level).size
65
- )
66
- "#{spaces} #{separator.()} "
67
- end
68
- ]
69
- end
70
- end
71
- end
72
- end