xargs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/xargs.rb +63 -0
- metadata +45 -0
data/lib/xargs.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Skeleton module for the 'xargs' routine.
|
3
|
+
#
|
4
|
+
# Ideally, one would do this in their code to import the "xargs" call
|
5
|
+
# directly into their current namespace:
|
6
|
+
#
|
7
|
+
# require 'xargs'
|
8
|
+
# include XArgs
|
9
|
+
# # do something with xargs()
|
10
|
+
#
|
11
|
+
#
|
12
|
+
# It is recommended that you look at the documentation for the xargs()
|
13
|
+
# call directly for specific usage.
|
14
|
+
#
|
15
|
+
#--
|
16
|
+
#
|
17
|
+
# The compilation of software known as xargs.rb is distributed under the
|
18
|
+
# following terms:
|
19
|
+
# Copyright (C) 2005-2006 Erik Hollensbe. All rights reserved.
|
20
|
+
#
|
21
|
+
# Redistribution and use in source form, with or without
|
22
|
+
# modification, are permitted provided that the following conditions
|
23
|
+
# are met:
|
24
|
+
# 1. Redistributions of source code must retain the above copyright
|
25
|
+
# notice, this list of conditions and the following disclaimer.
|
26
|
+
#
|
27
|
+
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
28
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
29
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
31
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
33
|
+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
34
|
+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
35
|
+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
36
|
+
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
37
|
+
# SUCH DAMAGE.
|
38
|
+
#
|
39
|
+
#++
|
40
|
+
|
41
|
+
module XArgs
|
42
|
+
#
|
43
|
+
# Emulate the 'xargs' shell utility.
|
44
|
+
#
|
45
|
+
# Takes a program to execute, and a block. The block is fed a line
|
46
|
+
# of input, which the code can do anything it wishes with.
|
47
|
+
#
|
48
|
+
# Ex:
|
49
|
+
# XArgs.xargs("find . -type f") { |line| puts line }
|
50
|
+
#
|
51
|
+
def xargs(program, &block)
|
52
|
+
io = IO.popen("/usr/bin/env " + program)
|
53
|
+
io.each_line { |line| yield line }
|
54
|
+
io.close
|
55
|
+
end
|
56
|
+
|
57
|
+
module_function :xargs
|
58
|
+
end
|
59
|
+
|
60
|
+
if $0 == File.basename(__FILE__)
|
61
|
+
include XArgs
|
62
|
+
xargs("find . -type f") { |f| puts f }
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: xargs
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2006-04-09 00:00:00 -07:00
|
8
|
+
summary: Module to emulate the 'xargs' utility from a unix system
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: erik@hollensbe.org
|
12
|
+
homepage:
|
13
|
+
rubyforge_project: shell-tools
|
14
|
+
description:
|
15
|
+
autorequire: xargs
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- Erik Hollensbe
|
30
|
+
files:
|
31
|
+
- lib/xargs.rb
|
32
|
+
test_files: []
|
33
|
+
|
34
|
+
rdoc_options: []
|
35
|
+
|
36
|
+
extra_rdoc_files: []
|
37
|
+
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
requirements: []
|
43
|
+
|
44
|
+
dependencies: []
|
45
|
+
|