Skip to content

Commit 9ca81c0

Browse files
coderifousJim Garvin
authored and
Jim Garvin
committed
Added command line utility for ruby string manip.
1 parent 0e9e88d commit 9ca81c0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

string

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'rubygems'
4+
5+
begin
6+
require 'active_support'
7+
require 'active_support/core_ext/string'
8+
rescue LoadError => e
9+
STDERR.puts "Warning: gem install activesupport if you want more advanced manipulations."
10+
end
11+
12+
$command = ARGV.shift
13+
14+
def process(input)
15+
puts input.send($command)
16+
end
17+
18+
if ARGV.length > 0
19+
ARGV.each { |i| process(i.chomp) }
20+
else
21+
while i = gets
22+
process(i.chomp)
23+
end
24+
end

0 commit comments

Comments
 (0)