scutil 0.4.6 → 0.4.7

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.
@@ -1,6 +1,13 @@
1
1
 
2
2
  ==Changelog
3
3
 
4
+ ===0.4.7 | 2013-04-26
5
+
6
+ * Better handling of binary streams in Ruby 1.9+.
7
+ * Add option to not throw exceptions when there's data on STDERR.
8
+ Thanks @mclazarus!
9
+ * Some never ending doc clean-up.
10
+
4
11
  ===0.4.6 | 2012-08-23
5
12
 
6
13
  * Handle connection timeouts with a Scutil::Error.
@@ -34,8 +34,13 @@ Scutil.exec_command, as an instantiable class with Scutil::Exec, or as a mixin
34
34
  with the module Scutil.
35
35
 
36
36
  You can now you scutil to manage you Net::SCP connections as well. Two wrapper
37
- functions will be defined if you have Net::SCP installed. Still in early steps,
38
- see Scutil::Exec.
37
+ functions will be defined if you have Net::SCP installed.
38
+
39
+ See Scutil::Exec for more details.
40
+
41
+ Scutil works great with {Rails}[http://rubyonrails.org/] to perform tasks via SSH.
42
+ Particularly when used with {Delayed::Job}[https://github.com/collectiveidea/delayed_job],
43
+ {Resque}[https://github.com/resque/resque] et al.
39
44
 
40
45
  ==Synopsis:
41
46
 
@@ -44,7 +49,7 @@ You can use scutil in a few different ways, for more usage examples see Scutil.
44
49
  require 'scutil'
45
50
 
46
51
  # Class method executed immediately:
47
- Scutil.exec_command('servername1', 'username', nil,
52
+ Scutil.exec_command('servername1', 'username', 'command', nil,
48
53
  {
49
54
  :keys => '~mas/.ssh/id_rsa',
50
55
  :scutil_verbose => true
@@ -52,8 +57,7 @@ You can use scutil in a few different ways, for more usage examples see Scutil.
52
57
 
53
58
 
54
59
  # Object to be used and reused:
55
- exec = Scutil::Exec.new('servername2', 'mas',
56
- { :password => 'myPassw0rd' })
60
+ exec = Scutil::Exec.new('servername2', 'mas')
57
61
  exec.exec_command("ls -l /")
58
62
 
59
63
  return_value = exec.exec_command("grep -q ...")
@@ -73,7 +77,8 @@ You can use scutil in a few different ways, for more usage examples see Scutil.
73
77
  require 'stringio'
74
78
 
75
79
  command_output = StringIO.new
76
- Scutil.exec_command('servername1', 'sudo cat /root/secrets.txt', command_output)
80
+ Scutil.exec_command('servername1', 'sudo cat /root/secrets.txt', command_output, nil,
81
+ { :password => 'myPassw0rd' })
77
82
  puts command_output.string
78
83
 
79
84
  == Installation:
@@ -84,7 +89,7 @@ You can use scutil in a few different ways, for more usage examples see Scutil.
84
89
 
85
90
  The MIT License (MIT)
86
91
 
87
- Copyright (c) 2012 by Marc Soda
92
+ Copyright (c) 2013 by Marc Soda
88
93
 
89
94
  Permission is hereby granted, free of charge, to any person obtaining a copy of
90
95
  this software and associated documentation files (the "Software"), to deal in
@@ -2,7 +2,7 @@
2
2
  =begin
3
3
  The MIT License (MIT)
4
4
 
5
- Copyright (C) 2012 by Marc Soda
5
+ Copyright (C) 2013 by Marc Soda
6
6
 
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy of
8
8
  this software and associated documentation files (the "Software"), to deal in
@@ -29,7 +29,7 @@ require 'scutil/connection_cache'
29
29
  require 'scutil/system_connection'
30
30
 
31
31
  module Scutil
32
- SCUTIL_VERSION = '0.4.6'
32
+ SCUTIL_VERSION = '0.4.7'
33
33
 
34
34
  # By default, buffer 10M of data before writing.
35
35
  DEFAULT_OUTPUT_BUFFER_SIZE = 0xA00000
@@ -98,12 +98,13 @@ module Scutil
98
98
  #
99
99
  # Scutil.exec_command takes the following options:
100
100
  #
101
- # * :scutil_verbose => Extra output.
102
- # * :scutil_force_pty => Force a PTY request (or not) for every channel.
103
- # * :scutil_pty_regex => Specific a custom regex here for use when scutil decides whether or not to request a PTY.
104
- # * :scutil_sudo_passwd_regex => If sudo requires a password you can specify the prompt to look for, e.g., _Password:_ .
105
- # * :scutil_sudo_passwd_failed_regex => Regular expression for a sudo password failure.
106
- # * :scutil_sudo_passwd => The sudo password.
101
+ # * :scutil_verbose => Extra output.
102
+ # * :scutil_force_pty => Force a PTY request (or not) for every channel.
103
+ # * :scutil_pty_regex => Specific a custom regex here for use when scutil decides whether or not to request a PTY.
104
+ # * :scutil_sudo_passwd_regex => If sudo requires a password you can specify the prompt to look for, e.g., _Password:_ .
105
+ # * :scutil_sudo_passwd_failed_regex => Regular expression for a sudo password failure.
106
+ # * :scutil_sudo_passwd => The sudo password.
107
+ # * :scutil_suppress_stderr_exception => Prevent exception if we get data on stderr.
107
108
  #
108
109
  # In addition, any other options passed Scutil.exec_command will be passed
109
110
  # on to Net::SSH, _except_ those prefixed with _scutil__.
@@ -131,7 +132,7 @@ module Scutil
131
132
  elsif (output.respond_to? :write) # XXX: This may not be a safe assumuption...
132
133
  fh = output
133
134
  elsif (output.class == String)
134
- fh = File.open(output, 'w') unless output.empty?
135
+ fh = File.open(output, 'wb') unless output.empty?
135
136
  else
136
137
  raise Scutil::Error.new("Invalid output object type: #{output.class}.", hostname)
137
138
  end
@@ -233,7 +234,7 @@ Define in :scutil_sudo_passwd or check :scutil_sudo_failed_passwd for the correc
233
234
  fh.close unless fh == $stdout
234
235
 
235
236
  # If extended_data was recieved there was a problem...
236
- raise Scutil::Error.new("Error: #{edata}", hostname, exit_status) unless (edata.empty?)
237
+ raise Scutil::Error.new("Error: #{edata}", hostname, exit_status) unless (edata.empty?) || options[:scutil_suppress_stderr_exception]
237
238
 
238
239
  # The return value of the remote command.
239
240
  return exit_status
@@ -1,8 +1,8 @@
1
1
 
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'scutil'
4
- s.version = '0.4.6'
5
- s.date = '2012-08-23'
4
+ s.version = '0.4.7'
5
+ s.date = '2013-04-26'
6
6
  s.summary = 'SSH Command UTILity'
7
7
  s.description = <<-EOF
8
8
  Scutil is a library for conveniently executing commands
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/ruby -I../lib -I.
2
2
 
3
- if RUBY_VERSION =~ /^1.8/
4
- require 'rubygems'
5
- end
3
+ require 'rubygems' if RUBY_VERSION =~ /^1.8/
4
+
6
5
  require 'test/unit'
7
6
  require 'scutil'
8
7
  require 'stringio'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scutil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-23 00:00:00.000000000 Z
12
+ date: 2013-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 1.8.24
75
+ rubygems_version: 1.8.25
76
76
  signing_key:
77
77
  specification_version: 3
78
78
  summary: SSH Command UTILity