jazz_hands 0.0.6 → 0.1.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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.1.0 (2012-01-04)
2
+
3
+ * For performance, enable [pry-nav][pry-nav] only on MRI 1.9.3 by default. To
4
+ use on MRI 1.9.2, add `JazzHands.enable_pry_nav` to a Rails initializer.
5
+ * Due to buggy behavior, syntax highlighting as you type via
6
+ [Coolline][coolline] and [Coderay][coderay] is disabled by default. Enable
7
+ with `JazzHands.enable_syntax_highlighting_as_you_type` in a Rails
8
+ initializer. MRI 1.9.3 only.
9
+ * Fix [Hirb][hirb] support.
10
+ * Upgrade [awesome_print][awesome_print] to 1.0.2.
11
+
1
12
  ## 0.0.6 (2011-12-03)
2
13
 
3
14
  * Add line numbers to the prompt for easy reference when using `_in_` and
data/README.md CHANGED
@@ -4,7 +4,7 @@ Jazz Hands
4
4
  Spending hours in the rails console? Spruce it up and show off those
5
5
  hard-working hands!
6
6
 
7
- **jazz_hands** combines multiple console-related gems and a bit of glue:
7
+ **jazz_hands** is an opinionated set of console-related gems and a bit of glue:
8
8
 
9
9
  * [**Pry**][pry] for a powerful shell alternative to IRB.
10
10
  * [**Awesome Print**][awesome_print] for stylish pretty print.
@@ -12,15 +12,16 @@ hard-working hands!
12
12
  * **Pry Doc** to browse Ruby source, including C, directly from the console.
13
13
  * [**Pry Git**][pry-git] to teach the console about git. Diffs, blames, and
14
14
  commits on methods and classes, not just files.
15
- * [**Pry Nav**][pry-nav] to turn the console into a simple debugger.
16
15
  * [**Pry Remote**][pry-remote] to connect remotely to a Pry console.
16
+ * [**Pry Nav**][pry-nav] to turn the console into a simple debugger. _Ruby 1.9.3
17
+ recommended_
17
18
  * [**Coolline**][coolline] and [**Coderay**][coderay] for syntax highlighting as
18
- you type. _Ruby 1.9.3 only_
19
+ you type. _Optional. Ruby 1.9.3 only_
19
20
 
20
21
 
21
22
  ## Usage
22
23
 
23
- Rails 3 and above only. Add to your project Gemfile:
24
+ Ruby 1.9.2+, Rails 3+ only. Add to your project Gemfile:
24
25
 
25
26
  ```ruby
26
27
  group :development, :test do
@@ -32,6 +33,14 @@ That's it. Run `rails console` as usual.
32
33
 
33
34
  [Hirb][hirb] isn't enabled by default. To use, run `Hirb.enable` in the console.
34
35
 
36
+ For performance, [pry-nav][pry-nav] is only enabled on 1.9.3 by default. To
37
+ manually enable for 1.9.2, add `JazzHands.enable_pry_nav` to an initializer.
38
+
39
+ Syntax highlighting as you type via [Coolline][coolline] and [Coderay][coderay]
40
+ is disabled by default due to slightly buggy behavior. To enable, add
41
+ `JazzHands.enable_syntax_highlighting_as_you_type` to an initializer. Only works
42
+ with 1.9.3.
43
+
35
44
 
36
45
  ## Contributing
37
46
 
data/jazz_hands.gemspec CHANGED
@@ -27,5 +27,6 @@ Gem::Specification.new do |gem|
27
27
  gem.add_runtime_dependency 'hirb', '= 0.6.0'
28
28
  gem.add_runtime_dependency 'coolline', '>= 0.1.0'
29
29
  gem.add_runtime_dependency 'coderay', '>= 0.9.8'
30
- gem.add_runtime_dependency 'awesome_print', '~> 1.0.1'
30
+ gem.add_runtime_dependency 'awesome_print', '~> 1.0.2'
31
+ gem.add_runtime_dependency 'railties', '~> 3.0'
31
32
  end
data/lib/jazz_hands.rb CHANGED
@@ -1,2 +1,51 @@
1
1
  require 'jazz_hands/version'
2
2
  require 'jazz_hands/railtie' if defined?(Rails)
3
+
4
+ module JazzHands
5
+ extend self
6
+
7
+ # Enable pry-nav.
8
+ #
9
+ # For performance reasons, pry-nav is enabled by default for only MRI 1.9.3+.
10
+ # To use with MRI 1.9.2, call this method from a Rails initializer:
11
+ #
12
+ # JazzHands.enable_pry_nav
13
+ #
14
+ def enable_pry_nav
15
+ require 'pry-nav'
16
+ end
17
+
18
+
19
+ # Enable syntax highlighting as you type in the Rails console via coolline and
20
+ # coderay (MRI 1.9.3+ only). Disabled by default as it's a bit buggy.
21
+ #
22
+ # Call from a Rails initializer:
23
+ #
24
+ # JazzHands.enable_syntax_highlighting_as_you_type
25
+ #
26
+ def enable_syntax_highlighting_as_you_type
27
+ raise 'Syntax highlighting only supported on 1.9.3+' unless RUBY_VERSION >= '1.9.3'
28
+
29
+ # Use coolline with CodeRay for syntax highlighting as you type.
30
+ # Only works on >= 1.9.3 because coolline depends on io/console.
31
+
32
+ require 'coolline'
33
+ require 'coderay'
34
+
35
+ Pry.config.input = Coolline.new do |c|
36
+ c.transform_proc = proc do
37
+ CodeRay.scan(c.line, :ruby).term
38
+ end
39
+
40
+ c.completion_proc = proc do
41
+ word = c.completed_word
42
+ Object.constants.map(&:to_s).select { |w| w.start_with? word }
43
+ end
44
+ end
45
+ end
46
+
47
+
48
+ ### Internal methods ###
49
+
50
+ attr_accessor :hirb_output
51
+ end
@@ -7,20 +7,12 @@ class << Hirb::View
7
7
 
8
8
  def enable_output_method
9
9
  @output_method = true
10
-
11
- # Adjust Pry output to try Hirb before its existing mechanism
12
- @old_pry_print = Pry.config.print
13
- Pry.config.print = ->(output, value) do
14
- view_or_page_output(value) || @old_pry_print.call(output, value)
15
- end
16
-
10
+ JazzHands.hirb_output = true
17
11
  enable_output_method_existing
18
12
  end
19
13
 
20
14
  def disable_output_method
21
- # Set Pry back to its existing output mechanism
22
- Pry.config.print = @old_pry_print
23
-
15
+ JazzHands.hirb_output = false
24
16
  disable_output_method_existing
25
17
  end
26
18
  end
@@ -2,14 +2,12 @@ require 'pry'
2
2
  require 'pry-doc'
3
3
  require 'pry-git'
4
4
  require 'pry-remote'
5
- require 'pry-nav'
6
5
  require 'awesome_print'
7
6
  require 'jazz_hands/hirb_ext'
8
7
 
9
- if RUBY_VERSION >= '1.9.3'
10
- require 'coolline'
11
- require 'coderay'
12
- end
8
+ # Enable pry-nav by default on MRI 1.9.3 only
9
+ require 'pry-nav' if RUBY_VERSION >= '1.9.3'
10
+
13
11
 
14
12
  module JazzHands
15
13
  class Railtie < Rails::Railtie
@@ -17,23 +15,15 @@ module JazzHands
17
15
  silence_warnings do
18
16
  ::IRB = Pry # Replace IRB with Pry completely
19
17
 
20
- # Use coolline with CodeRay for syntax highlighting as you type
21
- # Only works on >= 1.9.3 because coolline depends on io/console
22
- if RUBY_VERSION >= '1.9.3'
23
- Pry.config.input = Coolline.new do |c|
24
- c.transform_proc = proc do
25
- CodeRay.scan(c.line, :ruby).term
26
- end
27
-
28
- c.completion_proc = proc do
29
- word = c.completed_word
30
- Object.constants.map(&:to_s).select { |w| w.start_with? word }
31
- end
32
- end
33
- end
18
+ # We're managing the loading of plugins, especially pry-nav which
19
+ # shouldn't be loaded on 1.9.2. So don't let pry autoload them.
20
+ Pry.config.should_load_plugins = false
21
+ Pry.config.plugins.enabled = false
34
22
 
35
- # Use awesome_print for output, but keep pry's pager
23
+ # Use awesome_print for output, but keep pry's pager. If Hirb is
24
+ # enabled, try printing with it first.
36
25
  Pry.config.print = ->(output, value) do
26
+ return if JazzHands.hirb_output && Hirb::View.view_or_page_output(value)
37
27
  pretty = value.ai(indent: 2)
38
28
  Pry::Helpers::BaseHelpers.stagger_output("=> #{pretty}", output)
39
29
  end
@@ -1,3 +1,3 @@
1
1
  module JazzHands
2
- VERSION = '0.0.6'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jazz_hands
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-03 00:00:00.000000000 Z
12
+ date: 2012-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
16
- requirement: &70305225757160 !ruby/object:Gem::Requirement
16
+ requirement: &70123331636700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.7.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70305225757160
24
+ version_requirements: *70123331636700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: pry-doc
27
- requirement: &70305225755060 !ruby/object:Gem::Requirement
27
+ requirement: &70123331634820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70305225755060
35
+ version_requirements: *70123331634820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: pry-git
38
- requirement: &70305225753260 !ruby/object:Gem::Requirement
38
+ requirement: &70123331632940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.2.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70305225753260
46
+ version_requirements: *70123331632940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: pry-remote
49
- requirement: &70305225751380 !ruby/object:Gem::Requirement
49
+ requirement: &70123331631140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.1.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70305225751380
57
+ version_requirements: *70123331631140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: pry-nav
60
- requirement: &70305225750060 !ruby/object:Gem::Requirement
60
+ requirement: &70123331630080 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.0.4
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70305225750060
68
+ version_requirements: *70123331630080
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hirb
71
- requirement: &70305225747380 !ruby/object:Gem::Requirement
71
+ requirement: &70123331627580 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - =
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.6.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70305225747380
79
+ version_requirements: *70123331627580
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: coolline
82
- requirement: &70305221645000 !ruby/object:Gem::Requirement
82
+ requirement: &70123331457820 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.1.0
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70305221645000
90
+ version_requirements: *70123331457820
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: coderay
93
- requirement: &70305221644160 !ruby/object:Gem::Requirement
93
+ requirement: &70123331456960 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,18 +98,29 @@ dependencies:
98
98
  version: 0.9.8
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70305221644160
101
+ version_requirements: *70123331456960
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: awesome_print
104
- requirement: &70305221643000 !ruby/object:Gem::Requirement
104
+ requirement: &70123331455840 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.0.1
109
+ version: 1.0.2
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70305221643000
112
+ version_requirements: *70123331455840
113
+ - !ruby/object:Gem::Dependency
114
+ name: railties
115
+ requirement: &70123331454880 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ~>
119
+ - !ruby/object:Gem::Version
120
+ version: '3.0'
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: *70123331454880
113
124
  description: Spending hours in the rails console? Spruce it up and show off those
114
125
  hard-working hands! jazz_hands replaces IRB with Pry, improves output through awesome_print,
115
126
  and has some other goodies up its sleeves.