pry 0.6.6 → 0.6.7pre4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ def apply_spec_defaults(s)
20
20
  s.description = s.summary
21
21
  s.require_path = 'lib'
22
22
  s.add_dependency("ruby_parser",">=2.0.5")
23
+ s.add_dependency("coderay",">=0.9.7")
23
24
  s.add_development_dependency("bacon",">=1.1.0")
24
25
  s.homepage = "http://banisterfiend.wordpress.com"
25
26
  s.has_rdoc = 'yard'
@@ -56,6 +57,22 @@ namespace :ruby do
56
57
  end
57
58
  end
58
59
 
60
+ [:mingw32, :mswin32].each do |v|
61
+ namespace v do
62
+ spec = Gem::Specification.new do |s|
63
+ apply_spec_defaults(s)
64
+ s.add_dependency("method_source",">=0.3.4")
65
+ s.add_dependency("win32console", ">=1.3.0")
66
+ s.platform = "i386-#{v}"
67
+ end
68
+
69
+ Rake::GemPackageTask.new(spec) do |pkg|
70
+ pkg.need_zip = false
71
+ pkg.need_tar = false
72
+ end
73
+ end
74
+ end
75
+
59
76
  namespace :jruby do
60
77
  spec = Gem::Specification.new do |s|
61
78
  apply_spec_defaults(s)
@@ -71,7 +88,7 @@ end
71
88
 
72
89
 
73
90
  desc "build all platform gems at once"
74
- task :gems => [:rmgems, "ruby:gem", "jruby:gem"]
91
+ task :gems => [:rmgems, "ruby:gem", "jruby:gem", "mswin32:gem", "mingw32:gem"]
75
92
 
76
93
  desc "remove all platform gems"
77
94
  task :rmgems => ["ruby:clobber_package"]
data/bin/pry CHANGED
@@ -35,6 +35,18 @@ See: `https://github.com/banister` for more information.
35
35
  options[:loadrc] = false
36
36
  end
37
37
 
38
+ opts.on("--color", "Start session with syntax highlighting on.") do
39
+ Pry.color = true
40
+ end
41
+
42
+ opts.on("--simple-prompt", "Simple prompt mode.") do
43
+ Pry.prompt = Pry::SIMPLE_PROMPT
44
+ end
45
+
46
+ opts.on("-I LOADPATH", "Specify $LOAD_PATH directory.") do |load_path|
47
+ $LOAD_PATH << load_path
48
+ end
49
+
38
50
  opts.on("-v", "--version", "Display the Pry version.") do
39
51
  puts "Pry version #{Pry::VERSION} on Ruby #{RUBY_VERSION}"
40
52
  exit
data/lib/pry.rb CHANGED
@@ -3,16 +3,30 @@
3
3
 
4
4
  direc = File.dirname(__FILE__)
5
5
 
6
+ $LOAD_PATH << File.expand_path(direc)
7
+
6
8
  require "method_source"
9
+ require 'shellwords'
7
10
  require "readline"
8
11
  require "stringio"
9
- require "#{direc}/pry/version"
10
- require "#{direc}/pry/hooks"
11
- require "#{direc}/pry/print"
12
- require "#{direc}/pry/command_base"
13
- require "#{direc}/pry/commands"
14
- require "#{direc}/pry/prompts"
15
- require "#{direc}/pry/completion"
16
- require "#{direc}/pry/core_extensions"
17
- require "#{direc}/pry/pry_class"
18
- require "#{direc}/pry/pry_instance"
12
+ require "coderay"
13
+
14
+ if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
15
+ begin
16
+ require 'win32console'
17
+ rescue LoadError
18
+ $stderr.puts "Need to `gem install win32console`"
19
+ exit 1
20
+ end
21
+ end
22
+
23
+ require "pry/version"
24
+ require "pry/hooks"
25
+ require "pry/print"
26
+ require "pry/command_base"
27
+ require "pry/commands"
28
+ require "pry/prompts"
29
+ require "pry/completion"
30
+ require "pry/core_extensions"
31
+ require "pry/pry_class"
32
+ require "pry/pry_instance"
@@ -1,9 +1,7 @@
1
- direc = File.dirname(__FILE__)
2
-
3
1
  require "optparse"
4
2
  require "method_source"
5
- require "#{direc}/command_base"
6
- require "#{direc}/pry_instance"
3
+ require "pry/command_base"
4
+ require "pry/pry_instance"
7
5
 
8
6
  class Pry
9
7
 
@@ -25,6 +23,10 @@ class Pry
25
23
  raise "Cannot retrieve source for dynamically defined method."
26
24
  end
27
25
  end
26
+
27
+ remove_first_word = lambda do |text|
28
+ text.split.drop(1).join(' ')
29
+ end
28
30
 
29
31
  command "!", "Clear the input buffer. Useful if the parsing process goes wrong and you get stuck in the read loop." do
30
32
  output.puts "Input buffer cleared!"
@@ -41,6 +43,20 @@ class Pry
41
43
 
42
44
  alias_command "quit-program", "exit-program", ""
43
45
 
46
+ command "toggle-color", "Toggle syntax highlighting." do
47
+ Pry.color = !Pry.color
48
+ output.puts "Syntax highlighting #{Pry.color ? "on" : "off"}"
49
+ end
50
+
51
+ command "simple-prompt", "Toggle the simple prompt." do
52
+ case Pry.active_instance.prompt
53
+ when Pry::SIMPLE_PROMPT
54
+ Pry.active_instance.prompt = Pry::DEFAULT_PROMPT
55
+ else
56
+ Pry.active_instance.prompt = Pry::SIMPLE_PROMPT
57
+ end
58
+ end
59
+
44
60
  command "nesting", "Show nesting information." do
45
61
  nesting = opts[:nesting]
46
62
 
@@ -76,7 +92,7 @@ class Pry
76
92
  end
77
93
 
78
94
  command "exit-all", "End all nested Pry sessions. Accepts optional return value. Aliases: !@" do
79
- str = opts[:val].split.drop(1).join(' ')
95
+ str = remove_first_word.call(opts[:val])
80
96
  throw(:breakout, [0, target.eval(str)])
81
97
  end
82
98
 
@@ -219,7 +235,11 @@ Shows local and instance variables by default.
219
235
  info.sort_by { |k, v| v.last }.each do |k, v|
220
236
  if !v.first.empty?
221
237
  output.puts "#{k}:\n--"
222
- output.puts Pry.view(v.first)
238
+ if Pry.color
239
+ output.puts CodeRay.scan(Pry.view(v.first), :ruby).term
240
+ else
241
+ output.puts Pry.view(v.first)
242
+ end
223
243
  output.puts
224
244
  end
225
245
  end
@@ -227,7 +247,11 @@ Shows local and instance variables by default.
227
247
  # plain
228
248
  else
229
249
  list = info.values.sort_by { |v| v.last }.map { |v| v.first }.inject(&:+)
230
- output.puts Pry.view(list)
250
+ if Pry.color
251
+ output.puts CodeRay.scan(Pry.view(list), :ruby).term
252
+ else
253
+ output.puts Pry.view(list)
254
+ end
231
255
  list
232
256
  end
233
257
  end
@@ -364,6 +388,11 @@ e.g show-doc hello_method
364
388
  check_for_dynamically_defined_method.call(file)
365
389
 
366
390
  output.puts "--\nFrom #{file} @ line ~#{line}:\n--"
391
+
392
+ if Pry.color
393
+ doc = CodeRay.scan(doc, :ruby).term
394
+ end
395
+
367
396
  output.puts doc
368
397
  doc
369
398
  end
@@ -426,6 +455,11 @@ e.g: show-method hello_method
426
455
  check_for_dynamically_defined_method.call(file)
427
456
 
428
457
  output.puts "--\nFrom #{file} @ line #{line}:\n--"
458
+
459
+ if Pry.color
460
+ code = CodeRay.scan(code, :ruby).term
461
+ end
462
+
429
463
  output.puts code
430
464
  code
431
465
  end
@@ -444,6 +478,11 @@ e.g: show-method hello_method
444
478
  check_for_dynamically_defined_method.call(file)
445
479
 
446
480
  output.puts "--\nFrom #{file} @ line #{line}:\n--"
481
+
482
+ if Pry.color
483
+ code = CodeRay.scan(code, :ruby).term
484
+ end
485
+
447
486
  output.puts code
448
487
  code
449
488
  else
@@ -467,7 +506,7 @@ e.g: show-method hello_method
467
506
  end
468
507
 
469
508
  command "exit", "End the current Pry session. Accepts optional return value. Aliases: quit, back" do
470
- str = opts[:val].split.drop(1).join(' ')
509
+ str = remove_first_word.call(opts[:val])
471
510
  throw(:breakout, [opts[:nesting].level, target.eval(str)])
472
511
  end
473
512
 
@@ -8,7 +8,11 @@ class Pry
8
8
  output.puts "#{value.class}: #{value.message}"
9
9
  output.puts "from #{value.backtrace.first}"
10
10
  else
11
- output.puts "=> #{Pry.view(value)}"
11
+ if Pry.color
12
+ output.puts "=> #{CodeRay.scan(Pry.view(value), :ruby).term}"
13
+ else
14
+ output.puts "=> #{Pry.view(value)}"
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -22,5 +22,5 @@ class Pry
22
22
  ]
23
23
 
24
24
  # A simple prompt - doesn't display target or nesting level
25
- SIMPLE_PROMPT = [proc { "pry> " }, proc { "pry* " }]
25
+ SIMPLE_PROMPT = [proc { ">> " }, proc { ">* " }]
26
26
  end
@@ -1,14 +1,3 @@
1
- direc = File.dirname(__FILE__)
2
-
3
- require 'readline'
4
- require 'shellwords'
5
- require "#{direc}/prompts"
6
- require "#{direc}/hooks"
7
- require "#{direc}/print"
8
- require "#{direc}/commands"
9
- require "#{direc}/core_extensions"
10
- require "#{direc}/pry_instance"
11
-
12
1
  # @author John Mair (banisterfiend)
13
2
  class Pry
14
3
 
@@ -69,6 +58,10 @@ class Pry
69
58
  # Value returned by last executed Pry command.
70
59
  # @return [Object] The command value
71
60
  attr_accessor :cmd_ret_value
61
+
62
+ # Determines whether colored output is enabled.
63
+ # @return [Boolean]
64
+ attr_accessor :color
72
65
  end
73
66
 
74
67
  # Start a Pry REPL.
@@ -157,6 +150,7 @@ class Pry
157
150
  @prompt = DEFAULT_PROMPT
158
151
  @print = DEFAULT_PRINT
159
152
  @hooks = DEFAULT_HOOKS
153
+ @color = false
160
154
  end
161
155
 
162
156
  self.reset_defaults
@@ -1,6 +1,3 @@
1
- require 'readline'
2
- require 'shellwords'
3
-
4
1
  class Pry
5
2
 
6
3
  # The list of configuration options.
@@ -1,3 +1,3 @@
1
1
  class Pry
2
- VERSION = "0.6.6"
2
+ VERSION = "0.6.7pre4"
3
3
  end
metadata CHANGED
@@ -1,20 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
5
- prerelease:
4
+ version: 0.6.7pre4
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Mair (banisterfiend)
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-02-28 00:00:00.000000000 +13:00
12
+ date: 2011-03-03 00:00:00.000000000 +13:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_parser
17
- requirement: &17356980 !ruby/object:Gem::Requirement
17
+ requirement: &17582820 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,21 @@ dependencies:
22
22
  version: 2.0.5
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *17356980
25
+ version_requirements: *17582820
26
+ - !ruby/object:Gem::Dependency
27
+ name: coderay
28
+ requirement: &17582472 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *17582472
26
37
  - !ruby/object:Gem::Dependency
27
38
  name: bacon
28
- requirement: &17355156 !ruby/object:Gem::Requirement
39
+ requirement: &17582124 !ruby/object:Gem::Requirement
29
40
  none: false
30
41
  requirements:
31
42
  - - ! '>='
@@ -33,10 +44,10 @@ dependencies:
33
44
  version: 1.1.0
34
45
  type: :development
35
46
  prerelease: false
36
- version_requirements: *17355156
47
+ version_requirements: *17582124
37
48
  - !ruby/object:Gem::Dependency
38
49
  name: method_source
39
- requirement: &17336220 !ruby/object:Gem::Requirement
50
+ requirement: &17576580 !ruby/object:Gem::Requirement
40
51
  none: false
41
52
  requirements:
42
53
  - - ! '>='
@@ -44,7 +55,7 @@ dependencies:
44
55
  version: 0.3.4
45
56
  type: :runtime
46
57
  prerelease: false
47
- version_requirements: *17336220
58
+ version_requirements: *17576580
48
59
  description: attach an irb-like session to any object at runtime
49
60
  email: jrmair@gmail.com
50
61
  executables:
@@ -97,12 +108,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
108
  required_rubygems_version: !ruby/object:Gem::Requirement
98
109
  none: false
99
110
  requirements:
100
- - - ! '>='
111
+ - - ! '>'
101
112
  - !ruby/object:Gem::Version
102
- version: '0'
113
+ version: 1.3.1
103
114
  requirements: []
104
115
  rubyforge_project:
105
- rubygems_version: 1.5.2
116
+ rubygems_version: 1.6.0
106
117
  signing_key:
107
118
  specification_version: 3
108
119
  summary: attach an irb-like session to any object at runtime