pvc 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.
- data/Gemfile.lock +2 -2
- data/README.md +14 -14
- data/lib/pvc/process_piece.rb +2 -2
- data/lib/pvc/version.rb +1 -1
- data/spec/pvc/integration_spec.rb +16 -16
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,38 +17,38 @@ This code is packaged as a Gem. If you like, you can build and install it by run
|
|
17
17
|
## Synopsis - implemented
|
18
18
|
|
19
19
|
# Run a single process
|
20
|
-
PVC.new("echo hello").run
|
20
|
+
PVC.new("echo", "hello").run
|
21
21
|
|
22
22
|
# Or pipe from one process to another
|
23
|
-
PVC.new("echo hello").to(
|
23
|
+
PVC.new("echo", "hello").to(*%w{tr h H}).run
|
24
24
|
|
25
25
|
# Get individual or several outputs from the final result
|
26
|
-
PVC.new("echo hello && ls doesnotexist").run.stdout # => "hello\n"
|
27
|
-
PVC.new("echo hello && ls doesnotexist").run.stderr # => "ls: doesnotexist: No such file or directory\n"
|
28
|
-
PVC.new("echo hello && ls doesnotexist").run.stdboth # => "hello\nls: doesnotexist: No such file or directory\n"
|
29
|
-
PVC.new("echo hello && ls doesnotexist").run.code # => 1
|
30
|
-
stderr, code = PVC.new("echo hello && ls doesnotexist").run.get(:stderr, :code) # => ["ls: doesnotexist: No such file or directory\n", 1]
|
26
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stdout # => "hello\n"
|
27
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stderr # => "ls: doesnotexist: No such file or directory\n"
|
28
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stdboth # => "hello\nls: doesnotexist: No such file or directory\n"
|
29
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.code # => 1
|
30
|
+
stderr, code = PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.get(:stderr, :code) # => ["ls: doesnotexist: No such file or directory\n", 1]
|
31
31
|
|
32
32
|
# Input a string into stdin
|
33
|
-
PVC.new.input("one\ntwo\nthree\n").to("sort -r").run.stdout # => "two\nthree\none\n"
|
33
|
+
PVC.new.input("one\ntwo\nthree\n").to("sort", "-r").run.stdout # => "two\nthree\none\n"
|
34
34
|
|
35
35
|
# Process intermediate results with Ruby
|
36
|
-
PVC.new("cat some.log").to { |i,o| i.each_line { |line| o.puts line if line.match(/ERROR/) } }.to("tail -n10").run
|
36
|
+
PVC.new("cat", "some.log").to { |i,o| i.each_line { |line| o.puts line if line.match(/ERROR/) } }.to("tail", "-n10").run
|
37
37
|
|
38
38
|
# Mix stderr and stdin at some point in a pipeline
|
39
|
-
PVC.new("echo hello && ls doesnotexist").with_err.to("wc -l").run.stdout # => " 2\n"
|
39
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").with_err.to("wc", "-l").run.stdout # => " 2\n"
|
40
40
|
|
41
41
|
# Pass on only stderr at some point in a pipeline
|
42
|
-
PVC.new("echo hello && ls doesnotexist").only_err.to("wc -l").run.stdout # => " 1\n"
|
42
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").only_err.to("wc", "-l").run.stdout # => " 1\n"
|
43
43
|
|
44
44
|
# Insert one pipeline into another
|
45
|
-
upcase_unique_pipeline = PVC.new("tr a-z A-Z").to("uniq")
|
46
|
-
PVC.new.input("hello\nHeLlO\nworld\nWoRlD\n").to(upcase_unique_pipeline).to("sort -r").run.stdout # => "WORLD\nHELLO"
|
45
|
+
upcase_unique_pipeline = PVC.new("tr", "a-z", "A-Z").to("uniq")
|
46
|
+
PVC.new.input("hello\nHeLlO\nworld\nWoRlD\n").to(upcase_unique_pipeline).to("sort", "-r").run.stdout # => "WORLD\nHELLO"
|
47
47
|
|
48
48
|
## Synopsis - unimplemented
|
49
49
|
|
50
50
|
# Kill run if it does not finish in time (miliseconds)
|
51
|
-
PVC.new("sleep 2").run(:timeout => 1000)
|
51
|
+
PVC.new("sleep", "2").run(:timeout => 1000)
|
52
52
|
|
53
53
|
## Compatibility
|
54
54
|
|
data/lib/pvc/process_piece.rb
CHANGED
data/lib/pvc/version.rb
CHANGED
@@ -5,36 +5,36 @@ describe "pvc" do
|
|
5
5
|
describe "(synopsis tests)" do
|
6
6
|
|
7
7
|
it "should run a single process" do
|
8
|
-
PVC.new("echo hello").run.stdout.should == "hello\n"
|
8
|
+
PVC.new("echo", "hello").run.stdout.should == "hello\n"
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should pipe from one process to another" do
|
12
|
-
PVC.new("echo hello").to(
|
12
|
+
PVC.new("echo", "hello").to(*%w{tr h H}).run.stdout.should == "Hello\n"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should let you get stdout" do
|
16
|
-
PVC.new("echo hello && ls doesnotexist").run.stdout.should == "hello\n"
|
16
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stdout.should == "hello\n"
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should let you get stderr" do
|
20
|
-
PVC.new("echo hello && ls doesnotexist").run.stderr.should == "ls: doesnotexist: No such file or directory\n"
|
20
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stderr.should == "ls: doesnotexist: No such file or directory\n"
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should let you get stdout and stderr together" do
|
24
|
-
PVC.new("echo hello && ls doesnotexist").run.stdboth.should == "hello\nls: doesnotexist: No such file or directory\n"
|
24
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.stdboth.should == "hello\nls: doesnotexist: No such file or directory\n"
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should let you get the exit code of the last process" do
|
28
|
-
PVC.new("echo hello").run.code.should == 0
|
29
|
-
PVC.new("echo hello && ls doesnotexist").run.code.should == 1
|
28
|
+
PVC.new("echo", "hello").run.code.should == 0
|
29
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.code.should == 1
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should let you get several outputs from the final result" do
|
33
|
-
PVC.new("echo hello && ls doesnotexist").run.get(:stderr, :code).should == ["ls: doesnotexist: No such file or directory\n", 1]
|
33
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").run.get(:stderr, :code).should == ["ls: doesnotexist: No such file or directory\n", 1]
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should let you input into the stdin" do
|
37
|
-
PVC.new.input("one\ntwo\nthree\n").to("sort -r").run.stdout.should == "two\nthree\none\n"
|
37
|
+
PVC.new.input("one\ntwo\nthree\n").to("sort", "-r").run.stdout.should == "two\nthree\none\n"
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should let you process intermediate results with Ruby" do
|
@@ -44,17 +44,17 @@ describe "pvc" do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should let you mix stderr and stdin at some point in a pipeline" do
|
47
|
-
PVC.new("echo hello && ls doesnotexist").with_err.to("wc -l").run.stdout.should == " 2\n"
|
47
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").with_err.to("wc", "-l").run.stdout.should == " 2\n"
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should let you pass on only stderr at some point in a pipeline" do
|
51
|
-
PVC.new("echo hello && ls doesnotexist").only_err.to("wc -l").run.stdout.should == " 1\n"
|
51
|
+
PVC.new("bash", "-c", "echo hello && ls doesnotexist").only_err.to("wc", "-l").run.stdout.should == " 1\n"
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should let you insert one pipeline into another" do
|
55
|
-
upcase_unique_pipeline = PVC.new("tr a-z A-Z").to("uniq")
|
55
|
+
upcase_unique_pipeline = PVC.new("tr", "a-z", "A-Z").to("uniq")
|
56
56
|
string = "hello\nHeLlO\nworld\nWoRlD\n"
|
57
|
-
PVC.new.input(string).to(upcase_unique_pipeline).to("sort -r").run.stdout.should == "WORLD\nHELLO\n"
|
57
|
+
PVC.new.input(string).to(upcase_unique_pipeline).to("sort", "-r").run.stdout.should == "WORLD\nHELLO\n"
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|
@@ -65,7 +65,7 @@ describe "pvc" do
|
|
65
65
|
|
66
66
|
it "should work with 2 shell commands and a block" do
|
67
67
|
PVC.new.
|
68
|
-
to("echo BBB && echo AAA").
|
68
|
+
to("bash", "-c", "echo BBB && echo AAA").
|
69
69
|
to("sort").
|
70
70
|
to do |input, output|
|
71
71
|
input.each_line { |line| log << line.chomp }
|
@@ -76,7 +76,7 @@ describe "pvc" do
|
|
76
76
|
|
77
77
|
it "should work with sevearal blocks" do
|
78
78
|
PVC.new.
|
79
|
-
to("echo BBB && echo AAA").
|
79
|
+
to("bash", "-c", "echo BBB && echo AAA").
|
80
80
|
to("sort").
|
81
81
|
to do |input, output|
|
82
82
|
input.each_line { |line| output.write line }
|
@@ -90,7 +90,7 @@ describe "pvc" do
|
|
90
90
|
|
91
91
|
it "should work with sevearal blocks separated by a shell command" do
|
92
92
|
PVC.new.
|
93
|
-
to("echo BBB && echo AAA").
|
93
|
+
to("bash", "-c", "echo BBB && echo AAA").
|
94
94
|
to("sort").
|
95
95
|
to do |input, output|
|
96
96
|
input.each_line { |line| output.write line }
|