pry-pipeline 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -1
- data/lib/pry-pipeline.rb +1 -0
- data/lib/pry-pipeline/ext.rb +2 -1
- data/lib/pry-pipeline/response.rb +23 -0
- data/lib/pry-pipeline/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -53,7 +53,7 @@ end
|
|
53
53
|
=> nil
|
54
54
|
```
|
55
55
|
|
56
|
-
### Pipeline to ruby
|
56
|
+
### Pipeline to ruby block
|
57
57
|
|
58
58
|
```
|
59
59
|
$ pry
|
@@ -72,6 +72,17 @@ rb_obj_method(VALUE obj, VALUE vid)
|
|
72
72
|
=> nil
|
73
73
|
```
|
74
74
|
|
75
|
+
### Pipeline to ruby block from pry's command with [pry-command_result](https://github.com/ToQoz/pry-command_result)
|
76
|
+
|
77
|
+
```
|
78
|
+
[1] pry(main)> command_result('$ Pry.run_command') | -> v { v.lines.grep(/From/).join("\n") }
|
79
|
+
=> "From: /Users/toqoz/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.11.3/lib/pry/pry_class.rb @ line 232:\n"
|
80
|
+
|
81
|
+
[2] pry(main)> puts _
|
82
|
+
From: /Users/toqoz/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/pry-0.9.11.3/lib/pry/pry_class.rb @ line 232:
|
83
|
+
=> nil
|
84
|
+
```
|
85
|
+
|
75
86
|
## Useful usage(with [ruby-anything](https://github.com/ToQoz/ruby-anything))
|
76
87
|
|
77
88
|
*You can select method interactively and see its source!!!*
|
data/lib/pry-pipeline.rb
CHANGED
data/lib/pry-pipeline/ext.rb
CHANGED
@@ -4,7 +4,7 @@ class String
|
|
4
4
|
def _pipe_(cmd);
|
5
5
|
case cmd
|
6
6
|
when Proc
|
7
|
-
(cmd.call self
|
7
|
+
PryPipeline::Response.new(cmd.call self).to_s
|
8
8
|
when String
|
9
9
|
Pry.run_command("#{cmd} #{self}")
|
10
10
|
end
|
@@ -16,3 +16,4 @@ class Symbol
|
|
16
16
|
def _pipe_(*args); to_s._pipe_(*args) end
|
17
17
|
alias_method :|, :_pipe_
|
18
18
|
end
|
19
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module PryPipeline
|
4
|
+
class Response
|
5
|
+
def initialize(response)
|
6
|
+
@response = response
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
case @response
|
11
|
+
when Hash
|
12
|
+
h = @response.to_hash
|
13
|
+
h.keys.map { |key| "#{key} #{h[key]}" }.join("\n")
|
14
|
+
when Array
|
15
|
+
@response.to_a.join("\n")
|
16
|
+
when String, Symbol
|
17
|
+
@response.to_s
|
18
|
+
else
|
19
|
+
@response
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/pry-pipeline/version.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: pry-pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Takatoshi Matsumoto
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- Rakefile
|
42
42
|
- lib/pry-pipeline.rb
|
43
43
|
- lib/pry-pipeline/ext.rb
|
44
|
+
- lib/pry-pipeline/response.rb
|
44
45
|
- lib/pry-pipeline/version.rb
|
45
46
|
- pry-pipeline.gemspec
|
46
47
|
homepage: https://github.com/ToQoz/pry-pipeline
|