fileutils 1.8.0 → 1.8.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fileutils.rb +54 -29
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86c6c5b356b1a4609616761dd686d3fef6611d3e60bb6cef6b44c624454a2e2f
4
- data.tar.gz: ec91ec1155d38977abefbfa963d6c5bdc6ebadaf22481a70f6359a4e5a3a4b6d
3
+ metadata.gz: 119ccdad9a61fd3b8d32a10a9737c25a71aa74c89af88793ddcd8f9dc08c7bd3
4
+ data.tar.gz: c84c86999eb6506a4d9b2115b1829d2820766ebbecf604aa07b8071320803e2d
5
5
  SHA512:
6
- metadata.gz: 14affe38fe72bee2de39d9cf4897361ab1fcfd47a8e25f9faae47f563f283491826525a170d01e86bb3423a17cd43477daeceb1ac6c64d6dff6483cab36da702
7
- data.tar.gz: 174d36e824096f64e63db03c42631d0f3511cbdf48be425cf922ddbe711956404b1b39bc8d2f7d9241d218beba4c0fca7b40d9a5bbb15b29a7980db5db10cde2
6
+ metadata.gz: f33cafc4d2e0b7ec187909b6ee8f6396a08cbc7216cc135062e7d8d43f72195186e97cb8b085b107f31997f36542894ab52b86f634be881b4ad3f807521b246b
7
+ data.tar.gz: be31fb0185c76372fed0fdb585f37e67a875dafa63497c2095f40ae791228e8c0e5cc96bf6e44870c32652a9ccfc1f3d7bacdc4244084bdfdeb93675e8264077
data/lib/fileutils.rb CHANGED
@@ -181,7 +181,7 @@ end
181
181
  #
182
182
  module FileUtils
183
183
  # The version number.
184
- VERSION = "1.8.0"
184
+ VERSION = "1.8.1"
185
185
 
186
186
  def self.private_module_function(name) #:nodoc:
187
187
  module_function name
@@ -279,38 +279,67 @@ module FileUtils
279
279
  end
280
280
  private_module_function :remove_trailing_slash
281
281
 
282
+ # :markup: markdown
282
283
  #
283
- # Creates directories at the paths in the given +list+
284
- # (a single path or an array of paths);
285
- # returns +list+ if it is an array, <tt>[list]</tt> otherwise.
284
+ # call-seq:
285
+ # FileUtils.mkdir(*paths, mode: 0775, noop: nil, verbose: nil) -> array_of_paths or nil
286
286
  #
287
- # Argument +list+ or its elements
288
- # should be {interpretable as paths}[rdoc-ref:FileUtils@Path+Arguments].
287
+ # Argument `paths` may be one path or an array of paths;
288
+ # each must be {interpretable as a path}[rdoc-ref:FileUtils@Path+Arguments].
289
289
  #
290
- # With no keyword arguments, creates a directory at each +path+ in +list+
291
- # by calling: <tt>Dir.mkdir(path, mode)</tt>;
292
- # see {Dir.mkdir}[https://docs.ruby-lang.org/en/master/Dir.html#method-c-mkdir]:
290
+ # By default, creates a directory entry at each of the given `paths`;
291
+ # each directory has permissions `0775`;
292
+ # returns an array of the paths:
293
293
  #
294
- # FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"]
295
- # FileUtils.mkdir('tmp4') # => ["tmp4"]
294
+ # ```ruby
295
+ # FileUtils.mkdir('foo') # => ["foo"]
296
+ # FileUtils.mkdir(%w[bar baz]) # => ["bar", "baz"]
297
+ # File.stat(Dir.new('foo')).mode.to_s(8) # => "40775"
298
+ # File.stat(Dir.new('bar')).mode.to_s(8) # => "40775"
299
+ # File.stat(Dir.new('baz')).mode.to_s(8) # => "40775"
300
+ # FileUtils.rmdir(%w[foo bar baz]) # => ["foo", "bar", "baz"]
301
+ # ```
296
302
  #
297
- # Keyword arguments:
303
+ # Raises an exception if for any reason a directory cannot be created;
304
+ # a common reason is that the directory already exists.
298
305
  #
299
- # - <tt>mode: <i>mode</i></tt> - also calls <tt>File.chmod(mode, path)</tt>;
300
- # see {File.chmod}[https://docs.ruby-lang.org/en/master/File.html#method-c-chmod].
301
- # - <tt>noop: true</tt> - does not create directories.
302
- # - <tt>verbose: true</tt> - prints an equivalent command:
306
+ # With keyword argument `mode` given,
307
+ # creates directories with the given permissions:
303
308
  #
304
- # FileUtils.mkdir(%w[tmp0 tmp1], verbose: true)
305
- # FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true)
309
+ # ```ruby
310
+ # FileUtils.mkdir('bar', mode: 0664)
311
+ # File.stat(Dir.new('bar')).mode.to_s(8) # => "40664"
312
+ # FileUtils.rmdir('bar')
313
+ # ```
306
314
  #
307
- # Output:
315
+ # With keyword argument `noop` given as `true`,
316
+ # does not create directories;
317
+ # returns `nil`
318
+ #
319
+ # ```ruby
320
+ # FileUtils.mkdir('foo', noop: true) # => nil
321
+ # Dir.exist?('foo') # => false
322
+ # ```
323
+ #
324
+ # With keyword argument `verbose` given as `true`,
325
+ # prints a shell command:
308
326
  #
309
- # mkdir tmp0 tmp1
310
- # mkdir -m 700 tmp2 tmp3
327
+ # ```ruby
328
+ # FileUtils.mkdir('foo', verbose: true)
329
+ # FileUtils.mkdir(%w[bar baz], mode: 0644, verbose: true)
330
+ # FileUtils.mkdir(%w[bar baz], mode: 0644, verbose: true, noop: true)
331
+ # ```
311
332
  #
312
- # Raises an exception if any path points to an existing
313
- # file or directory, or if for any reason a directory cannot be created.
333
+ # Output:
334
+ #
335
+ # ```text
336
+ # mkdir foo
337
+ # mkdir -m 644 bar baz
338
+ # mkdir -m 644 bar baz
339
+ # ```
340
+ #
341
+ # Note that in the last call above (containing `noop: true`)
342
+ # the existence of the directory is not checked.
314
343
  #
315
344
  # Related: FileUtils.mkdir_p.
316
345
  #
@@ -686,7 +715,7 @@ module FileUtils
686
715
  # Keyword arguments:
687
716
  #
688
717
  # - <tt>force: true</tt> - overwrites +dest+ if it exists.
689
- # - <tt>relative: false</tt> - create links relative to +dest+.
718
+ # - <tt>relative: true</tt> - create links relative to +dest+.
690
719
  # - <tt>noop: true</tt> - does not create links.
691
720
  # - <tt>verbose: true</tt> - prints an equivalent command:
692
721
  #
@@ -754,7 +783,7 @@ module FileUtils
754
783
  n = real_ddirs.size - i
755
784
  n -= 1 unless target_directory
756
785
  link2 = fu_clean_components(*Array.new([n, 0].max, '..'), *real_sdirs[i..-1])
757
- link1 = link2 if link1.size > link2.size
786
+ link1 = link2 if !link2.empty? and link1.size > link2.size
758
787
  end
759
788
  s = File.join(link1)
760
789
  fu_output_message [cmd, s, d].flatten.join(' ') if verbose
@@ -2037,10 +2066,6 @@ module FileUtils
2037
2066
  def fu_windows?; false end #:nodoc:
2038
2067
  end
2039
2068
 
2040
- def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
2041
- IO.copy_stream(src, dest)
2042
- end
2043
-
2044
2069
  def fu_stream_blksize(*streams) #:nodoc:
2045
2070
  streams.each do |s|
2046
2071
  next unless s.respond_to?(:stat)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fileutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki