sheller 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/sheller.rb +3 -2
  2. data/test/sheller_test.rb +16 -0
  3. metadata +3 -7
@@ -1,7 +1,7 @@
1
1
  require 'popen4'
2
2
 
3
3
  module Sheller
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
5
 
6
6
  INESCAPABLE = {}
7
7
 
@@ -27,6 +27,7 @@ module Sheller
27
27
  def command(*args)
28
28
  args.map { |a| arg_to_cmd(a) }.join(' ')
29
29
  end
30
+ alias :quote :command
30
31
 
31
32
  def execute(*args)
32
33
  stdout, stderr = nil
@@ -42,7 +43,7 @@ module Sheller
42
43
  def arg_to_cmd(arg)
43
44
  if INESCAPABLE[arg]
44
45
  arg.to_s
45
- elsif arg.empty? || SHELL_SAFE =~ arg
46
+ elsif SHELL_SAFE =~ arg.to_s
46
47
  "'%s'" % arg
47
48
  else
48
49
  result = ''
@@ -15,6 +15,22 @@ class ShellerTest < Test::Unit::TestCase
15
15
  Dir.chdir(@original_dir)
16
16
  end
17
17
 
18
+ def test_quote
19
+ assert_equal "'echo'", Sheller.quote("echo")
20
+ end
21
+
22
+ def test_quote_redirect
23
+ assert_equal ">", Sheller.quote(:>)
24
+ end
25
+
26
+ def test_quote_named_redirect
27
+ assert_equal ">", Sheller.quote(Sheller::STDOUT_TO_FILE)
28
+ end
29
+
30
+ def test_quote_numeric_argument
31
+ assert_equal "'8'", Sheller.quote(8)
32
+ end
33
+
18
34
  def test_command_no_arguments
19
35
  assert_equal "turtle\n", Sheller.execute('./fixtures/stdout_turtle').stdout
20
36
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sheller
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 4
10
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - Duncan Beevers
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-10-29 00:00:00 -07:00
17
+ date: 2011-01-14 00:00:00 -08:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 19
30
28
  segments:
31
29
  - 0
32
30
  - 1
@@ -64,7 +62,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
62
  requirements:
65
63
  - - ">="
66
64
  - !ruby/object:Gem::Version
67
- hash: 3
68
65
  segments:
69
66
  - 0
70
67
  version: "0"
@@ -73,7 +70,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
70
  requirements:
74
71
  - - ">="
75
72
  - !ruby/object:Gem::Version
76
- hash: 3
77
73
  segments:
78
74
  - 0
79
75
  version: "0"