pry-command_result 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,31 @@
1
1
  require 'stringio'
2
2
 
3
3
  module Kernel
4
- def command_result(command)
5
- output = StringIO.new
4
+ def command_result(command, target = binding)
5
+ is_command = Pry.commands.to_a.map(&:first).any? do |cmd|
6
+ case cmd
7
+ when Regexp
8
+ cmd =~ command.split(' ').first
9
+ when String
10
+ cmd == command.split(' ').first
11
+ end
12
+ end
13
+
6
14
  pager = Pry.config.pager
7
15
  color = Pry.config.color
8
16
  Pry.config.pager = false
9
17
  Pry.config.color = false
10
- Pry.run_command(command, output: output, show_output: true)
11
- output.string
18
+
19
+ if is_command
20
+ output = StringIO.new
21
+ Pry.run_command(command, output: output, show_output: true)
22
+ output.string
23
+ else
24
+ eval(command, target)
25
+ end
12
26
  ensure
13
27
  Pry.config.color = color
14
28
  Pry.config.pager = pager
15
- output.close
29
+ output.close if output.respond_to? :close
16
30
  end
17
31
  end
@@ -1,3 +1,3 @@
1
1
  module PryCommandResult
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pry-command_result
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Takatoshi Matsumoto