summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2016-03-02 14:44:19 -0800
committerTim Smith <tsmith@chef.io>2016-03-02 14:44:19 -0800
commitc7f892947eec2d286bba34b014071b330991e773 (patch)
tree8d3b4cbbc91f0c19fe3c4713dff499a2b1f23db8
parentb892ec418ffe63c4bdd6f84c61fd016c65e09e68 (diff)
parent3a8640ad0c1b080d0acd491ae29d019b00e9ab34 (diff)
downloadmixlib-shellout-c7f892947eec2d286bba34b014071b330991e773.tar.gz
Merge pull request #122 from tas50/master
Improve documentation + misc fixes
-rw-r--r--.travis.yml13
-rw-r--r--README.md85
-rw-r--r--lib/mixlib/shellout.rb4
-rw-r--r--lib/mixlib/shellout/unix.rb4
-rw-r--r--lib/mixlib/shellout/windows.rb8
-rw-r--r--lib/mixlib/shellout/windows/core_ext.rb10
-rw-r--r--mixlib-shellout.gemspec6
7 files changed, 85 insertions, 45 deletions
diff --git a/.travis.yml b/.travis.yml
index 39aa782..532f415 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,14 @@
+language: ruby
+cache: bundler
+
+sudo: false
+
rvm:
- - 1.9.3
- - 2.0.0
- - 2.1.2
+ - 2.0
+ - 2.1
+ - 2.2
+ - 2.3.0
+
before_install:
- gem update bundler
diff --git a/README.md b/README.md
index 2cfe5b0..85146d8 100644
--- a/README.md
+++ b/README.md
@@ -1,54 +1,87 @@
# Mixlib::ShellOut
-Provides a simplified interface to shelling out yet still collecting both
-standard out and standard error and providing full control over environment,
-working directory, uid, gid, etc.
+[![Build Status Master](https://travis-ci.org/chef/mixlib-shellout.svg?branch=master)](https://travis-ci.org/chef/mixlib-shellout) [![Build Status Master](https://ci.appveyor.com/api/projects/status/github/chef/mixlib-shellout?branch=master&svg=true&passingText=master%20-%20Ok&pendingText=master%20-%20Pending&failingText=master%20-%20Failing)](https://ci.appveyor.com/project/Chef/mixlib-shellout/branch/master) [![Gem Version](https://badge.fury.io/rb/mixlib-shellout.svg)](https://badge.fury.io/rb/mixlib-shellout)
+
+Provides a simplified interface to shelling out while still collecting both standard out and standard error and providing full control over environment, working directory, uid, gid, etc.
No means for passing input to the subprocess is provided.
## Example
+### Simple Shellout
Invoke find(1) to search for .rb files:
- find = Mixlib::ShellOut.new("find . -name '*.rb'")
- find.run_command
+```ruby
+ require 'mixlib/shellout'
+ find = Mixlib::ShellOut.new("find . -name '*.rb'")
+ find.run_command
+```
If all went well, the results are on `stdout`
- puts find.stdout
+```ruby
+ puts find.stdout
+```
`find(1)` prints diagnostic info to STDERR:
- puts "error messages" + find.stderr
+```ruby
+ puts "error messages" + find.stderr
+```
Raise an exception if it didn't exit with 0
- find.error!
+```ruby
+ find.error!
+```
+
+### Advanced Shellout
+In addition to the command to run there are other options that can be set to change the shellout behavior. The complete list of options can be found here: https://github.com/chef/mixlib-shellout/blob/master/lib/mixlib/shellout.rb
-Run a command as the `www` user with no extra ENV settings from `/tmp`
+Run a command as the `www` user with no extra ENV settings from `/tmp` with a 1s timeout
- cmd = Mixlib::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp')
- cmd.run_command # etc.
+```ruby
+ cmd = Mixlib::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp', :timeout => 1)
+ cmd.run_command # etc.
+```
-## STDIN Example
+### STDIN Example
Invoke crontab to edit user cron:
- # :input only supports simple strings
- crontab_lines = [ "* * * * * /bin/true", "* * * * * touch /tmp/here" ]
- crontab = Mixlib::ShellOut.new("crontab -l -u #{@new_resource.user}", :input => crontab_lines.join("\n"))
- crontab.run_command
+```ruby
+ # :input only supports simple strings
+ crontab_lines = [ "* * * * * /bin/true", "* * * * * touch /tmp/here" ]
+ crontab = Mixlib::ShellOut.new("crontab -l -u #{@new_resource.user}", :input => crontab_lines.join("\n"))
+ crontab.run_command
+```
-## Windows Impersonation Example
+### Windows Impersonation Example
Invoke "whoami.exe" to demonstrate running a command as another user:
- whoami = Mixlib::ShellOut.new("whoami.exe", :user => "username", :domain => "DOMAIN", :password => "password")
- whoami.run_command
+```ruby
+ whoami = Mixlib::ShellOut.new("whoami.exe", :user => "username", :domain => "DOMAIN", :password => "password")
+ whoami.run_command
+```
## Platform Support
-Mixlib::ShellOut does a standard fork/exec on Unix, and uses the Win32
-API on Windows. There is not currently support for JRuby.
-
-## License
-Apache 2 Licensed. See LICENSE for full details.
+Mixlib::ShellOut does a standard fork/exec on Unix, and uses the Win32 API on Windows. There is not currently support for JRuby.
## See Also
-* `Process.spawn` in Ruby 1.9
-* [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn)
+- `Process.spawn` in Ruby 1.9
+- [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn)
+
+## License
+- Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
+- License:: Apache License, Version 2.0
+
+```text
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb
index 6f8730f..2fdbcfd 100644
--- a/lib/mixlib/shellout.rb
+++ b/lib/mixlib/shellout.rb
@@ -1,6 +1,6 @@
#--
-# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2010, 2011 Opscode, Inc.
+# Author:: Daniel DeLeo (<dan@chef.io>)
+# Copyright:: Copyright (c) 2010-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lib/mixlib/shellout/unix.rb b/lib/mixlib/shellout/unix.rb
index dd22cbe..734a597 100644
--- a/lib/mixlib/shellout/unix.rb
+++ b/lib/mixlib/shellout/unix.rb
@@ -1,6 +1,6 @@
#--
-# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2010, 2011 Opscode, Inc.
+# Author:: Daniel DeLeo (<dan@chef.io>)
+# Copyright:: Copyright (c) 2010-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb
index 14aca55..fd8039b 100644
--- a/lib/mixlib/shellout/windows.rb
+++ b/lib/mixlib/shellout/windows.rb
@@ -1,8 +1,8 @@
#--
-# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Author:: John Keiser (<jkeiser@opscode.com>)
-# Author:: Ho-Sheng Hsiao (<hosh@opscode.com>)
-# Copyright:: Copyright (c) 2011, 2012 Opscode, Inc.
+# Author:: Daniel DeLeo (<dan@chef.io>)
+# Author:: John Keiser (<jkeiser@chef.io>)
+# Author:: Ho-Sheng Hsiao (<hosh@chef.io>)
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lib/mixlib/shellout/windows/core_ext.rb b/lib/mixlib/shellout/windows/core_ext.rb
index ab54a9e..2fe2bf2 100644
--- a/lib/mixlib/shellout/windows/core_ext.rb
+++ b/lib/mixlib/shellout/windows/core_ext.rb
@@ -1,7 +1,7 @@
#--
-# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Author:: John Keiser (<jkeiser@opscode.com>)
-# Copyright:: Copyright (c) 2011, 2012 Opscode, Inc.
+# Author:: Daniel DeLeo (<dan@chef.io>)
+# Author:: John Keiser (<jkeiser@chef.io>)
+# Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -268,8 +268,8 @@ module Process
# If running in the service windows station must do a log on to get
# to the interactive desktop. Running process user account must have
# the 'Replace a process level token' permission. This is necessary as
- # the logon (which happens with CreateProcessWithLogon) must have an
- # interactive windows station to attach to, which is created with the
+ # the logon (which happens with CreateProcessWithLogon) must have an
+ # interactive windows station to attach to, which is created with the
# LogonUser cann with the LOGON32_LOGON_INTERACTIVE flag.
if winsta_name =~ /^Service-0x0-.*$/i
token = FFI::MemoryPointer.new(:ulong)
diff --git a/mixlib-shellout.gemspec b/mixlib-shellout.gemspec
index e406c74..37b7cf2 100644
--- a/mixlib-shellout.gemspec
+++ b/mixlib-shellout.gemspec
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = ["README.md", "LICENSE" ]
s.summary = "Run external commands on Unix or Windows"
s.description = s.summary
- s.author = "Opscode"
- s.email = "info@opscode.com"
- s.homepage = "http://wiki.opscode.com/"
+ s.author = "Chef Software Inc."
+ s.email = "info@chef.io"
+ s.homepage = "https://www.chef.io/"
s.required_ruby_version = ">= 1.9.3"