arver 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/arver.rb CHANGED
@@ -1,4 +1,4 @@
1
- %w{singleton yaml fileutils rubygems active_support/secure_random highline/import gpgme escape openssl zlib}.each {|f| require f }
1
+ %w{singleton yaml fileutils rubygems active_support/secure_random highline/import gpgme openssl zlib}.each {|f| require f }
2
2
  $:.unshift(File.dirname(__FILE__)) unless
3
3
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
4
4
 
@@ -10,8 +10,27 @@ module Arver
10
10
  c
11
11
  end
12
12
 
13
+ # copy from shellwords.rb
14
+ def shellescape(str)
15
+ str = str.to_s
16
+
17
+ # An empty argument will be skipped, so return empty quotes.
18
+ return "''" if str.empty?
19
+
20
+ str = str.dup
21
+
22
+ # Treat multibyte characters as is. It is caller's responsibility
23
+ # to encode the string in the right encoding for the shell
24
+ # environment.
25
+ str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1")
26
+
27
+ # A LF cannot be escaped with a backslash because a backslash + LF
28
+ # combo is regarded as line continuation and simply ignored.
29
+ str.gsub(/\n/, "'\n'")
30
+ end
31
+
13
32
  def escaped_command
14
- Escape.shell_command([ command ] + arguments_array )
33
+ "#{shellescape(command)} " + arguments_array.collect{|c| shellescape(c)}.join(" ")
15
34
  end
16
35
 
17
36
  def execute( input = "" )
@@ -13,9 +13,8 @@ module Arver
13
13
  end
14
14
 
15
15
  def escaped_command
16
- return Escape.shell_command( [ "ssh", "-p #{host.port}", "#{host.username}@#{host.address}", "sudo", super ] ) if( as_root && host.username != "root" )
17
- Escape.shell_command( [ "ssh", "-p #{host.port}", "#{host.username}@#{host.address}", super ] )
16
+ sudo = if as_root && host.username != "root" then "sudo" else "" end
17
+ "ssh -p #{shellescape(host.port)} #{shellescape(host.username)}@#{shellescape(host.address)} #{sudo} #{super}"
18
18
  end
19
-
20
19
  end
21
20
  end
data/lib/arver/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arver
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-07-24 00:00:00.000000000 Z
14
+ date: 2012-07-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: gpgme
@@ -29,22 +29,6 @@ dependencies:
29
29
  - - ! '>='
30
30
  - !ruby/object:Gem::Version
31
31
  version: 2.0.0
32
- - !ruby/object:Gem::Dependency
33
- name: escape
34
- requirement: !ruby/object:Gem::Requirement
35
- none: false
36
- requirements:
37
- - - ! '>='
38
- - !ruby/object:Gem::Version
39
- version: 0.0.4
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
- requirements:
45
- - - ! '>='
46
- - !ruby/object:Gem::Version
47
- version: 0.0.4
48
32
  - !ruby/object:Gem::Dependency
49
33
  name: activesupport
50
34
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
174
  version: '0'
191
175
  segments:
192
176
  - 0
193
- hash: 4241994790696947
177
+ hash: 947642704890013429
194
178
  required_rubygems_version: !ruby/object:Gem::Requirement
195
179
  none: false
196
180
  requirements: