lucie-cmd 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucie-cmd/commands.rb +30 -5
- data/lucie-cmd.gemspec +2 -1
- data/test/functional/sh_test.rb +35 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5d8773ea556b86dec92d17eac1fa1cc5aa3e06b
|
4
|
+
data.tar.gz: a803646cf421dc375bf02d75f83eb380fd5e0353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dc123d998ee7961f9b1563d3eac2ebfe982a6c140e4bf2088ea8cbb5e2a10c099c82d006d52c34d7b1334ae222a9d81c51ebe78e50ddea24029adc69e950914
|
7
|
+
data.tar.gz: e45baf99b2e45c1509842571bd8401feea221d79015095e621e8d8805e56c948803880d4153b56c41e1d3a64a290a10689d4a0a104663d89031d8634fce033da
|
data/lib/lucie-cmd/commands.rb
CHANGED
@@ -24,15 +24,36 @@ module Lucie
|
|
24
24
|
@commands_helper.status
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def set(opts = [])
|
28
28
|
@commands_helper ||= CommandsHelper.new
|
29
|
-
@commands_helper.
|
29
|
+
@commands_helper.set(Array(opts))
|
30
|
+
end
|
31
|
+
|
32
|
+
def unset(opts = [])
|
33
|
+
@commands_helper ||= CommandsHelper.new
|
34
|
+
@commands_helper.unset(Array(opts))
|
35
|
+
end
|
36
|
+
|
37
|
+
def red(text)
|
38
|
+
puts colorize(text, 31)
|
39
|
+
end
|
40
|
+
|
41
|
+
def green(text)
|
42
|
+
puts colorize(text, 32)
|
43
|
+
end
|
44
|
+
|
45
|
+
def yellow(text)
|
46
|
+
puts colorize(text, 33)
|
47
|
+
end
|
48
|
+
|
49
|
+
def colorize(text, color_code)
|
50
|
+
"\e[#{color_code}m#{text}\e[0m"
|
30
51
|
end
|
31
52
|
|
32
53
|
private
|
33
54
|
|
34
55
|
class CommandsHelper
|
35
|
-
|
56
|
+
attr_reader :pwd
|
36
57
|
|
37
58
|
def initialize
|
38
59
|
@stderr = $stderr
|
@@ -52,7 +73,7 @@ module Lucie
|
|
52
73
|
@output = ""
|
53
74
|
if !stdout.eof()
|
54
75
|
new_content = stdout.read
|
55
|
-
if @opts.include? :
|
76
|
+
if @opts.include? :live_output
|
56
77
|
print new_content
|
57
78
|
end
|
58
79
|
@output << new_content
|
@@ -72,9 +93,13 @@ module Lucie
|
|
72
93
|
@pwd = File.expand_path(val, @pwd)
|
73
94
|
end
|
74
95
|
|
75
|
-
def
|
96
|
+
def set(opts = [])
|
76
97
|
@opts = @opts | opts
|
77
98
|
end
|
99
|
+
|
100
|
+
def unset(opts = [])
|
101
|
+
opts.each { |opt| @opts.delete(opt) }
|
102
|
+
end
|
78
103
|
end
|
79
104
|
end
|
80
105
|
end
|
data/lucie-cmd.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
2
|
+
require File.expand_path("../../lucie-lib/lib/lucie/version", __FILE__)
|
3
|
+
version = Lucie::VERSION
|
3
4
|
lib = File.expand_path('../lib', __FILE__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
6
|
|
data/test/functional/sh_test.rb
CHANGED
@@ -55,19 +55,50 @@ class ShTest < MiniTest::Spec
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should be able to put the output realtime" do
|
58
|
-
|
59
|
-
out,
|
58
|
+
set :live_output
|
59
|
+
out, _ = capture_io do
|
60
60
|
sh "echo test"
|
61
61
|
end
|
62
62
|
assert_equal "test\n", out
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should be able to show the command" do
|
66
|
-
|
67
|
-
out,
|
66
|
+
set :show_command
|
67
|
+
out, _ = capture_io do
|
68
68
|
sh "echo test"
|
69
69
|
end
|
70
70
|
assert_equal "$ echo test\n", out
|
71
71
|
end
|
72
72
|
|
73
|
+
it "should have an unset to turn off realtime output" do
|
74
|
+
set :live_output
|
75
|
+
unset :live_output
|
76
|
+
out, _ = capture_io do
|
77
|
+
sh "echo test"
|
78
|
+
end
|
79
|
+
assert_equal "", out
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should be able to use green color for output" do
|
83
|
+
out, _ = capture_io do
|
84
|
+
green "Hello world"
|
85
|
+
end
|
86
|
+
assert_equal "\e[32mHello world\e[0m\n", out
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should be able to use red color for output" do
|
90
|
+
out, _ = capture_io do
|
91
|
+
red "Hello world"
|
92
|
+
end
|
93
|
+
assert_equal "\e[31mHello world\e[0m\n", out
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should be able to use yellow color for output" do
|
97
|
+
out, _ = capture_io do
|
98
|
+
yellow "Hello world"
|
99
|
+
end
|
100
|
+
assert_equal "\e[33mHello world\e[0m\n", out
|
101
|
+
end
|
102
|
+
|
103
|
+
|
73
104
|
end
|