unix_utils 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,3 +5,5 @@ gemspec
5
5
  # development dependencies
6
6
  gem 'minitest'
7
7
  gem 'minitest-reporters'
8
+ gem 'yard'
9
+ # gem 'ruby-prof'
data/History.txt CHANGED
@@ -1,3 +1,20 @@
1
+ == 0.0.4 / 2012-03-19
2
+
3
+ * Bug fixes
4
+
5
+ * NoMethodError when trying to print $stderr - thanks @leomao10 !
6
+
7
+ == 0.0.3 / 2012-03-19
8
+
9
+ * Enhancements
10
+
11
+ * Uses https://github.com/rtomayko/posix-spawn to make things faster - suggested by @jjb in https://github.com/seamusabshere/unix_utils/issues/1
12
+ * Depends less on chdir to work properly - expands file paths immediately
13
+
14
+ * Bug fixes
15
+
16
+ * Correctly use pipes (I hope) - imitate POSIX::Spawn::Child's use of IO.select
17
+
1
18
  == 0.0.2 / 2012-02-16
2
19
 
3
20
  * Bug fixes
data/README.markdown CHANGED
@@ -4,7 +4,27 @@ Like FileUtils, but provides zip, unzip, bzip2, bunzip2, tar, untar, sed, du, md
4
4
 
5
5
  Works in MRI 1.8.7+, MRI 1.9.2+, and JRuby 1.6.7+
6
6
 
7
- ## What to expect
7
+ ## Where it's used
8
+
9
+ * [Brighter Planet CM1 Impact Estimate web service](http://impact.brighterplanet.com)
10
+ * [Brighter Planet Reference Data web service](http://data.brighterplanet.com)
11
+ * Extracted from [`remote_table`](https://github.com/seamusabshere/remote_table)
12
+
13
+ ## Philosophy
14
+
15
+ Use a subprocess to perform a big task and then get out of memory.
16
+
17
+ <table>
18
+ <tr>
19
+ <td rowspan="2"><img src="https://raw.github.com/seamusabshere/unix_utils/master/unix-philosophy-cover.png" alt="cover of the Unix Philosophy book" /></td>
20
+ <td><img src="https://raw.github.com/seamusabshere/unix_utils/master/unix-philosophy-quote-pg1.png" alt="Tenet 2: Make Each Program Do One Thing Well. The best programs, like Cousteau's lake fly, does but one task in its life and does it well. The program is loaded into memory, accomplishes its function, and then gets out ot the way to allow" /></td>
21
+ </tr>
22
+ <tr>
23
+ <td><img src="https://raw.github.com/seamusabshere/unix_utils/master/unix-philosophy-quote-pg2.png" alt="the next single-minded program to begin. This sounds simple, yet it may surprise you how many software developers have difficulty sticking to this singular goal." /></td>
24
+ </tr>
25
+ </table>
26
+
27
+ ## Rules (what you can expect)
8
28
 
9
29
  For commands like zip, untar, sed, head, cut, dos2unix, etc.:
10
30
 
@@ -17,10 +37,6 @@ For commands like du, md5sum, shasum, etc.:
17
37
  1. Just returns the good stuff (the checksum, for example, not the filename that is listed after it in the standard command output)
18
38
  2. Never touches the input
19
39
 
20
- ## Philosophy
21
-
22
- Use a subprocess to perform a big task and then get out of memory.
23
-
24
40
  ## But I can just spawn these myself
25
41
 
26
42
  This lib was created to ease the pain of remembering command options for Gentoo, deciding which spawning method to use, possibly handling pipes...
@@ -39,6 +55,8 @@ is replaced safely with
39
55
 
40
56
  ## But I can just use `Digest::SHA256`
41
57
 
58
+ (Note: [Balazs Kutil](https://github.com/bkutil) pointed out [this is a bad example](https://gist.github.com/1950707)... I will replace it soon)
59
+
42
60
  This will load an entire file into memory before it can be processed...
43
61
 
44
62
  require 'digest'
@@ -60,13 +78,9 @@ You get the same low memory footprint with
60
78
 
61
79
  ## Compatibility
62
80
 
63
- Uses `open3` because it's in the Ruby stdlib and is consistent across MRI and JRuby.
64
-
65
- ## Where it's used
81
+ Now using [`posix-spawn`](https://github.com/rtomayko/posix-spawn) for speed. Thanks for the suggestion [jjb](https://github.com/jjb)!
66
82
 
67
- * [Brighter Planet Reference Data web service](http://data.brighterplanet.com)
68
- * [Brighter Planet Emission Estimate web service](http://impact.brighterplanet.com) aka CM1
69
- * [`remote_table` library](https://github.com/seamusabshere/remote_table)
83
+ Previously used `open3` because it's in the Ruby stdlib and is consistent across MRI and JRuby.
70
84
 
71
85
  ## Authors
72
86
 
data/Rakefile CHANGED
@@ -10,3 +10,6 @@ Rake::TestTask.new(:test) do |test|
10
10
  end
11
11
 
12
12
  task :default => :test
13
+
14
+ require 'yard'
15
+ YARD::Rake::YardocTask.new
@@ -1,3 +1,3 @@
1
1
  module UnixUtils
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/unix_utils.rb CHANGED
@@ -1,12 +1,15 @@
1
1
  require 'fileutils'
2
2
  require 'tmpdir'
3
3
  require 'uri'
4
- require 'open3'
4
+ require 'stringio'
5
+ require 'posix/spawn'
5
6
 
6
7
  require "unix_utils/version"
7
8
 
8
9
  module UnixUtils
9
10
 
11
+ BUFSIZE = 4_194_304
12
+
10
13
  def self.curl(url, form_data = nil)
11
14
  outfile = tmp_path url
12
15
  if url.start_with?('/') or url.start_with?('file://')
@@ -26,15 +29,16 @@ module UnixUtils
26
29
 
27
30
  #--
28
31
  # most platforms
29
- # $ openssl dgst -sha256 .bash_profile
32
+ # $ openssl dgst -sha256 .bash_profile
30
33
  # SHA256(.bash_profile)= ae12206aaa35dc96273ed421f4e85ca26a1707455e3cc9f054c7f5e2e9c53df6
31
34
  # ubuntu 11.04
32
- # $ shasum -a 256 --portable .mysql_history
35
+ # $ shasum -a 256 --portable .mysql_history
33
36
  # 856aa27deb0b80b41031c2ddf722af28ba2a8c4999ff9cf2d45f33bc67d992ba ?.mysql_history
34
37
  # fedora 7
35
- # $ sha256sum --binary .bash_profile
38
+ # $ sha256sum --binary .bash_profile
36
39
  # 01b1210962b3d1e5e1ccba26f93d98efbb7b315b463f9f6bdb40ab496728d886 *.bash_profile
37
40
  def self.shasum(infile, algorithm)
41
+ infile = ::File.expand_path infile
38
42
  if available?('shasum')
39
43
  argv = ['shasum', '--binary', '-a', algorithm.to_s, infile]
40
44
  stdout = spawn argv
@@ -45,15 +49,16 @@ module UnixUtils
45
49
  stdout.strip.split(' ').last
46
50
  end
47
51
  end
48
-
52
+
49
53
  #--
50
54
  # os x 10.6.8; most platforms
51
- # $ openssl dgst -md5 .bashrc
55
+ # $ openssl dgst -md5 .bashrc
52
56
  # MD5(.bashrc)= 88f464fb6d1d6fe9141135248bf7b265
53
57
  # ubuntu 11.04; fedora 7; gentoo
54
- # $ md5sum --binary .mysql_history
55
- # 8d01e54ab8142d6786850e22d55a1b6c *.mysql_history
58
+ # $ md5sum --binary .mysql_history
59
+ # 8d01e54ab8142d6786850e22d55a1b6c *.mysql_history
56
60
  def self.md5sum(infile)
61
+ infile = ::File.expand_path infile
57
62
  if available?('md5sum')
58
63
  argv = ['md5sum', '--binary', infile]
59
64
  stdout = spawn argv
@@ -64,22 +69,25 @@ module UnixUtils
64
69
  stdout.strip.split(' ').last
65
70
  end
66
71
  end
67
-
72
+
68
73
  def self.du(srcdir)
74
+ srcdir = ::File.expand_path srcdir
69
75
  argv = ['du', srcdir]
70
76
  stdout = spawn argv
71
77
  stdout.strip.split(/\s+/).first.to_i
72
78
  end
73
-
79
+
74
80
  def self.wc(infile)
81
+ infile = ::File.expand_path infile
75
82
  argv = ['wc', infile]
76
83
  stdout = spawn argv
77
84
  stdout.strip.split(/\s+/)[0..2].map { |s| s.to_i }
78
85
  end
79
86
 
80
87
  # --
81
-
88
+
82
89
  def self.unzip(infile)
90
+ infile = ::File.expand_path infile
83
91
  destdir = tmp_path infile
84
92
  ::FileUtils.mkdir destdir
85
93
  argv = ['unzip', '-qq', '-n', infile, '-d', destdir]
@@ -88,6 +96,7 @@ module UnixUtils
88
96
  end
89
97
 
90
98
  def self.untar(infile)
99
+ infile = ::File.expand_path infile
91
100
  destdir = tmp_path infile
92
101
  ::FileUtils.mkdir destdir
93
102
  argv = ['tar', '-xf', infile, '-C', destdir]
@@ -96,6 +105,7 @@ module UnixUtils
96
105
  end
97
106
 
98
107
  def self.gunzip(infile)
108
+ infile = ::File.expand_path infile
99
109
  outfile = tmp_path infile
100
110
  argv = ['gunzip', '--stdout', infile]
101
111
  spawn argv, :write_to => outfile
@@ -103,8 +113,9 @@ module UnixUtils
103
113
  end
104
114
 
105
115
  def self.bunzip2(infile)
116
+ infile = ::File.expand_path infile
106
117
  outfile = tmp_path infile
107
- argv = ['bunzip2', '--stdout', infile,]
118
+ argv = ['bunzip2', '--stdout', infile]
108
119
  spawn argv, :write_to => outfile
109
120
  outfile
110
121
  end
@@ -112,13 +123,15 @@ module UnixUtils
112
123
  # --
113
124
 
114
125
  def self.bzip2(infile)
126
+ infile = ::File.expand_path infile
115
127
  outfile = tmp_path infile, '.bz2'
116
128
  argv = ['bzip2', '--keep', '--stdout', infile]
117
129
  spawn argv, :write_to => outfile
118
130
  outfile
119
131
  end
120
-
132
+
121
133
  def self.tar(srcdir)
134
+ srcdir = ::File.expand_path srcdir
122
135
  outfile = tmp_path srcdir, '.tar'
123
136
  argv = ['tar', '-cf', outfile, '-C', srcdir, '.']
124
137
  spawn argv
@@ -126,46 +139,52 @@ module UnixUtils
126
139
  end
127
140
 
128
141
  def self.zip(srcdir)
142
+ srcdir = ::File.expand_path srcdir
129
143
  outfile = tmp_path srcdir, '.zip'
130
144
  argv = ['zip', '-rq', outfile, '.']
131
145
  spawn argv, :chdir => srcdir
132
146
  outfile
133
147
  end
134
-
148
+
135
149
  def self.gzip(infile)
150
+ infile = ::File.expand_path infile
136
151
  outfile = tmp_path infile, '.gz'
137
152
  argv = ['gzip', '--stdout', infile]
138
153
  spawn argv, :write_to => outfile
139
154
  outfile
140
155
  end
141
-
156
+
142
157
  # --
143
-
158
+
144
159
  def self.awk(infile, *expr)
160
+ infile = ::File.expand_path infile
145
161
  outfile = tmp_path infile
146
162
  bin = available?('gawk') ? 'gawk' : 'awk'
147
163
  argv = [bin, expr, infile].flatten
148
164
  spawn argv, :write_to => outfile
149
165
  outfile
150
166
  end
151
-
167
+
152
168
  # Yes, this is a very limited use of perl.
153
169
  def self.perl(infile, *expr)
170
+ infile = ::File.expand_path infile
154
171
  outfile = tmp_path infile
155
172
  argv = [ 'perl', expr.map { |e| ['-pe', e] } ].flatten
156
173
  spawn argv, :read_from => infile, :write_to => outfile
157
174
  outfile
158
175
  end
159
-
176
+
160
177
  def self.unix2dos(infile)
178
+ infile = ::File.expand_path infile
161
179
  if available?('gawk') or available?('awk')
162
180
  awk infile, '{ sub(/\r/, ""); printf("%s\r\n", $0) }'
163
181
  else
164
182
  perl infile, 's/\r\n|\n|\r/\r\n/g'
165
183
  end
166
184
  end
167
-
185
+
168
186
  def self.dos2unix(infile)
187
+ infile = ::File.expand_path infile
169
188
  if available?('gawk') or available?('awk')
170
189
  awk infile, '{ sub(/\r/, ""); printf("%s\n", $0) }'
171
190
  else
@@ -174,6 +193,7 @@ module UnixUtils
174
193
  end
175
194
 
176
195
  def self.sed(infile, *expr)
196
+ infile = ::File.expand_path infile
177
197
  outfile = tmp_path infile
178
198
  bin = available?('gsed') ? 'gsed' : 'sed'
179
199
  argv = [ bin, expr.map { |e| ['-e', e] } ].flatten
@@ -182,13 +202,15 @@ module UnixUtils
182
202
  end
183
203
 
184
204
  def self.tail(infile, lines)
205
+ infile = ::File.expand_path infile
185
206
  outfile = tmp_path infile
186
207
  argv = ['tail', '-n', lines.to_s, infile]
187
208
  spawn argv, :write_to => outfile
188
209
  outfile
189
210
  end
190
-
211
+
191
212
  def self.head(infile, lines)
213
+ infile = ::File.expand_path infile
192
214
  outfile = tmp_path infile
193
215
  argv = ['head', '-n', lines.to_s, infile]
194
216
  spawn argv, :write_to => outfile
@@ -197,6 +219,7 @@ module UnixUtils
197
219
 
198
220
  # specify character_positions as a string like "3-5" or "3,9-10"
199
221
  def self.cut(infile, character_positions)
222
+ infile = ::File.expand_path infile
200
223
  outfile = tmp_path infile
201
224
  argv = ['cut', '-c', character_positions, infile]
202
225
  spawn argv, :write_to => outfile
@@ -204,12 +227,13 @@ module UnixUtils
204
227
  end
205
228
 
206
229
  def self.iconv(infile, to, from)
230
+ infile = ::File.expand_path infile
207
231
  outfile = tmp_path infile
208
232
  argv = ['iconv', '-t', to, '-f', from, infile]
209
233
  spawn argv, :write_to => outfile
210
234
  outfile
211
235
  end
212
-
236
+
213
237
  def self.available?(bin) # :nodoc:
214
238
  bin = bin.to_s
215
239
  return @@available_query[bin] if defined?(@@available_query) and @@available_query.is_a?(::Hash) and @@available_query.has_key?(bin)
@@ -226,51 +250,76 @@ module UnixUtils
226
250
  end
227
251
 
228
252
  def self.spawn(argv, options = {}) # :nodoc:
229
- if options[:chdir]
230
- old_pwd = ::Dir.pwd
231
- ::Dir.chdir options[:chdir]
253
+ options = options.dup
254
+
255
+ input = if (read_from = options.delete(:read_from))
256
+ ::File.open(read_from, 'r')
232
257
  end
258
+
259
+ output = if (write_to = options.delete(:write_to))
260
+ output_redirected = true
261
+ ::File.open(write_to, 'wb')
262
+ else
263
+ output_redirected = false
264
+ ::StringIO.new
265
+ end
266
+
267
+ error = ::StringIO.new
268
+
269
+ pid, stdin, stdout, stderr = ::POSIX::Spawn.popen4(*(argv+[options]))
233
270
 
234
- whole_stdout = nil
235
- whole_stderr = nil
236
-
237
- ::Open3.popen3(*argv) do |stdin, stdout, stderr|
238
- # deal with STDIN
239
- if options[:read_from]
240
- ::File.open(options[:read_from], 'r') do |in_f|
241
- while chunk = in_f.read(4_194_304)
242
- stdin.write chunk
243
- end
271
+ # lifted from posix-spawn
272
+ # https://github.com/rtomayko/posix-spawn/blob/master/lib/posix/spawn/child.rb
273
+ readers = [stdout, stderr]
274
+ writers = if input
275
+ [stdin]
276
+ else
277
+ stdin.close
278
+ []
279
+ end
280
+ while readers.any? or writers.any?
281
+ ready = ::IO.select(readers, writers, readers + writers)
282
+ # write to stdin stream
283
+ ready[1].each do |fd|
284
+ begin
285
+ boom = nil
286
+ size = fd.write_nonblock(input.read(BUFSIZE))
287
+ rescue ::Errno::EPIPE => boom
288
+ rescue ::Errno::EAGAIN, ::Errno::EINTR
289
+ end
290
+ if boom || size < BUFSIZE
291
+ stdin.close
292
+ input.close
293
+ writers.delete(stdin)
244
294
  end
245
295
  end
246
- stdin.close
247
-
248
- # deal with STDOUT
249
- if options[:write_to]
250
- ::File.open(options[:write_to], 'wb') do |out_f|
251
- while chunk = stdout.read(4_194_304)
252
- out_f.write chunk
253
- end
296
+ # read from stdout and stderr streams
297
+ ready[0].each do |fd|
298
+ buf = (fd == stdout) ? output : error
299
+ begin
300
+ buf << fd.readpartial(BUFSIZE)
301
+ rescue ::Errno::EAGAIN, ::Errno::EINTR
302
+ rescue ::EOFError
303
+ readers.delete(fd)
304
+ fd.close
254
305
  end
255
- whole_stdout = "Redirected to #{options[:write_to]}"
256
- else
257
- whole_stdout = stdout.read
258
306
  end
259
-
260
- # deal with STDERR
261
- whole_stderr = stderr.read
262
307
  end
308
+ # thanks @tmm1 and @rtomayko for showing how it's done!
309
+
310
+ ::Process.waitpid pid
263
311
 
264
- unless whole_stderr.empty?
312
+ error.rewind
313
+ unless (whole_error = error.read).empty?
265
314
  $stderr.puts "[unix_utils] `#{argv.join(' ')}` STDERR:"
266
- $stderr.puts whole_stderr
315
+ $stderr.puts whole_error
267
316
  end
268
317
 
269
- whole_stdout
270
-
271
- ensure
272
- if options[:chdir]
273
- ::Dir.chdir old_pwd
318
+ unless output_redirected
319
+ output.rewind
320
+ output.read
274
321
  end
322
+ ensure
323
+ [stdin, stdout, stderr, input, output, error].each { |io| io.close if io and not io.closed? }
275
324
  end
276
325
  end
data/test/helper.rb CHANGED
@@ -11,6 +11,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
11
11
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
12
  require 'unix_utils'
13
13
 
14
+ require 'stringio'
14
15
  require 'fileutils'
15
16
  require 'tmpdir'
16
17
  require 'tempfile'
@@ -36,7 +37,7 @@ module TestHelper
36
37
  UnixUtils.du(infile_or_srcdir).must_equal size
37
38
  end
38
39
  end
39
-
40
+
40
41
  def assert_unpack_dir(method_id, infile)
41
42
  destdir = UnixUtils.send method_id, infile
42
43
  File.directory?(destdir).must_equal true
@@ -44,7 +45,7 @@ module TestHelper
44
45
  File.dirname(destdir).start_with?(Dir.tmpdir).must_equal true
45
46
  safe_delete destdir
46
47
  end
47
-
48
+
48
49
  def assert_unpack_file(method_id, infile)
49
50
  outfile = UnixUtils.send method_id, infile
50
51
  File.file?(outfile).must_equal true
@@ -52,7 +53,7 @@ module TestHelper
52
53
  File.dirname(outfile).start_with?(Dir.tmpdir).must_equal true
53
54
  safe_delete outfile
54
55
  end
55
-
56
+
56
57
  def assert_pack(method_id, infile)
57
58
  outfile = UnixUtils.send method_id, infile
58
59
  File.file?(outfile).must_equal true
@@ -60,7 +61,7 @@ module TestHelper
60
61
  File.dirname(outfile).start_with?(Dir.tmpdir).must_equal true
61
62
  safe_delete outfile
62
63
  end
63
-
64
+
64
65
  def safe_delete(path)
65
66
  path = File.expand_path path
66
67
  raise "Refusing to rm -rf #{path} because it's not in #{Dir.tmpdir}" unless File.dirname(path).start_with?(Dir.tmpdir)
@@ -6,11 +6,26 @@ describe UnixUtils do
6
6
  @old_pwd = Dir.pwd
7
7
  Dir.chdir File.expand_path('../target', __FILE__)
8
8
  end
9
-
9
+
10
10
  after do
11
11
  Dir.chdir @old_pwd
12
12
  end
13
-
13
+
14
+ describe "errors" do
15
+ it "gets printed to stderr" do
16
+ begin
17
+ old_stderr = $stderr
18
+ capture = StringIO.new
19
+ $stderr = capture
20
+ UnixUtils.unzip(__FILE__)
21
+ capture.rewind
22
+ capture.read.must_match %r{End-of-central-directory signature not found}
23
+ ensure
24
+ $stderr = old_stderr
25
+ end
26
+ end
27
+ end
28
+
14
29
  describe :curl do
15
30
  it "downloads to a temp file" do
16
31
  outfile = UnixUtils.curl('http://brighterplanet.com')
@@ -18,7 +33,7 @@ describe UnixUtils do
18
33
  safe_delete outfile
19
34
  end
20
35
  end
21
-
36
+
22
37
  describe :shasum do
23
38
  it "checksums a file with SHA-1" do
24
39
  UnixUtils.shasum('directory.zip', 1).must_equal 'c0abb36c923ed7bf87ebb8d7097cb8e264e528d2'
@@ -26,8 +41,14 @@ describe UnixUtils do
26
41
  it "checksums a file with SHA-256" do
27
42
  UnixUtils.shasum('directory.zip', 256).must_equal '661af2b7b0993088263228b071b649a88d82a6a655562162c32307d1e127f27a'
28
43
  end
44
+ it "works just as well with absolute paths" do
45
+ target_path = File.join(Dir.pwd, 'directory.zip')
46
+ Dir.chdir('/') do
47
+ UnixUtils.shasum(target_path, 256).must_equal '661af2b7b0993088263228b071b649a88d82a6a655562162c32307d1e127f27a'
48
+ end
49
+ end
29
50
  end
30
-
51
+
31
52
  describe :md5sum do
32
53
  it "checksums a file" do
33
54
  UnixUtils.md5sum('directory.zip').must_equal 'd6e15da798ae19551da6c49ec09afaef'
@@ -39,7 +60,7 @@ describe UnixUtils do
39
60
  UnixUtils.du('directory').must_equal 16
40
61
  end
41
62
  end
42
-
63
+
43
64
  describe :unzip do
44
65
  before do
45
66
  @infile = 'directory.zip'
@@ -55,7 +76,7 @@ describe UnixUtils do
55
76
  assert_does_not_touch :unzip, @infile
56
77
  end
57
78
  end
58
-
79
+
59
80
  describe :untar do
60
81
  before do
61
82
  @infile = 'directory.tar'
@@ -71,7 +92,7 @@ describe UnixUtils do
71
92
  assert_does_not_touch :untar, @infile
72
93
  end
73
94
  end
74
-
95
+
75
96
  describe :bunzip2 do
76
97
  before do
77
98
  @infile = 'file.bz2'
@@ -87,7 +108,7 @@ describe UnixUtils do
87
108
  assert_does_not_touch :bunzip2, @infile
88
109
  end
89
110
  end
90
-
111
+
91
112
  describe :gunzip do
92
113
  before do
93
114
  @infile = 'file.gz'
@@ -103,7 +124,7 @@ describe UnixUtils do
103
124
  assert_does_not_touch :gunzip, @infile
104
125
  end
105
126
  end
106
-
127
+
107
128
  describe :bzip2 do
108
129
  before do
109
130
  @infile = 'directory.tar'
@@ -120,7 +141,7 @@ describe UnixUtils do
120
141
  safe_delete outfile
121
142
  end
122
143
  end
123
-
144
+
124
145
  describe :gzip do
125
146
  before do
126
147
  @infile = 'directory.tar'
@@ -137,7 +158,7 @@ describe UnixUtils do
137
158
  safe_delete outfile
138
159
  end
139
160
  end
140
-
161
+
141
162
  describe :zip do
142
163
  before do
143
164
  @srcdir = 'directory'
@@ -154,7 +175,7 @@ describe UnixUtils do
154
175
  safe_delete outfile
155
176
  end
156
177
  end
157
-
178
+
158
179
  describe :tar do
159
180
  before do
160
181
  @srcdir = 'directory'
@@ -171,7 +192,7 @@ describe UnixUtils do
171
192
  safe_delete outfile
172
193
  end
173
194
  end
174
-
195
+
175
196
  describe :perl do
176
197
  before do
177
198
  @f = Tempfile.new('perl.txt')
@@ -196,7 +217,7 @@ describe UnixUtils do
196
217
  safe_delete outfile
197
218
  end
198
219
  end
199
-
220
+
200
221
  describe :awk do
201
222
  before do
202
223
  @f = Tempfile.new('awk.txt')
@@ -221,7 +242,7 @@ describe UnixUtils do
221
242
  safe_delete outfile
222
243
  end
223
244
  end
224
-
245
+
225
246
  describe :unix2dos do
226
247
  before do
227
248
  @f = Tempfile.new('unix2dos.txt')
@@ -239,7 +260,7 @@ describe UnixUtils do
239
260
  safe_delete outfile
240
261
  end
241
262
  end
242
-
263
+
243
264
  describe :dos2unix do
244
265
  before do
245
266
  @f = Tempfile.new('dos2unix.txt')
@@ -257,7 +278,7 @@ describe UnixUtils do
257
278
  safe_delete outfile
258
279
  end
259
280
  end
260
-
281
+
261
282
  describe :wc do
262
283
  before do
263
284
  @f = Tempfile.new('wc.txt')
@@ -297,7 +318,7 @@ describe UnixUtils do
297
318
  File.extname(outfile).must_equal File.extname(@infile)
298
319
  safe_delete outfile
299
320
  end
300
-
321
+
301
322
  end
302
323
 
303
324
  describe :tail do
@@ -322,7 +343,7 @@ describe UnixUtils do
322
343
  safe_delete outfile
323
344
  end
324
345
  end
325
-
346
+
326
347
  describe :head do
327
348
  before do
328
349
  @a2z = ('a'..'z').to_a
@@ -340,7 +361,7 @@ describe UnixUtils do
340
361
  safe_delete outfile
341
362
  end
342
363
  end
343
-
364
+
344
365
  describe :cut do
345
366
  before do
346
367
  @a2z = ('a'..'z').to_a
@@ -367,7 +388,7 @@ describe UnixUtils do
367
388
  safe_delete outfile
368
389
  end
369
390
  end
370
-
391
+
371
392
  describe :iconv do
372
393
  it 'converts files from utf-8 to latin1' do
373
394
  outfile = UnixUtils.iconv('utf8.txt', 'ISO-8859-1', 'UTF-8')
Binary file
Binary file
Binary file
data/unix_utils.gemspec CHANGED
@@ -15,4 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.name = "unix_utils"
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = UnixUtils::VERSION
18
+
19
+ gem.add_runtime_dependency 'posix-spawn'
18
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unix_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,19 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-17 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-03-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: posix-spawn
16
+ requirement: &2154399440 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2154399440
14
25
  description: Like FileUtils, but provides zip, unzip, bzip2, bunzip2, tar, untar,
15
26
  sed, du, md5sum, shasum, cut, head, tail, wc, unix2dos, dos2unix, iconv, curl, perl,
16
27
  etc.
@@ -41,6 +52,9 @@ files:
41
52
  - test/target/iso-8859-1.txt
42
53
  - test/target/utf8.txt
43
54
  - test/test_unix_utils.rb
55
+ - unix-philosophy-cover.png
56
+ - unix-philosophy-quote-pg1.png
57
+ - unix-philosophy-quote-pg2.png
44
58
  - unix_utils.gemspec
45
59
  homepage: https://github.com/seamusabshere/unix_utils
46
60
  licenses: []