Skip to content

Commit

Permalink
Merge fileutils-1.2.0 from ruby/fileutils.
Browse files Browse the repository at this point in the history
  It includes the following updates:

  * ruby/fileutils#26
  * ruby/fileutils#27
  * ruby/fileutils#29
  * ruby/fileutils#34

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
hsbt committed Mar 27, 2019
1 parent c92c0a5 commit 191b99c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions lib/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,14 @@ def pwd
#
# Changes the current directory to the directory +dir+.
#
# If this method is called with block, resumes to the old
# working directory after the block execution finished.
# If this method is called with block, resumes to the previous
# working directory after the block execution has finished.
#
# FileUtils.cd('/', :verbose => true) # chdir and report it
# FileUtils.cd('/') # change directory
#
# FileUtils.cd('/') do # chdir
# FileUtils.cd('/', :verbose => true) # change directory and report it
#
# FileUtils.cd('/') do # change directory
# # ... # do something
# end # return to original directory
#
Expand Down Expand Up @@ -1080,11 +1082,6 @@ def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
end
module_function :chown_R

begin
require 'etc'
rescue LoadError # rescue LoadError for miniruby
end

def fu_get_uid(user) #:nodoc:
return nil unless user
case user
Expand All @@ -1093,6 +1090,7 @@ def fu_get_uid(user) #:nodoc:
when /\A\d+\z/
user.to_i
else
require 'etc'
Etc.getpwnam(user) ? Etc.getpwnam(user).uid : nil
end
end
Expand All @@ -1106,6 +1104,7 @@ def fu_get_gid(group) #:nodoc:
when /\A\d+\z/
group.to_i
else
require 'etc'
Etc.getgrnam(group) ? Etc.getgrnam(group).gid : nil
end
end
Expand Down Expand Up @@ -1275,8 +1274,15 @@ def door?
def entries
opts = {}
opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
Dir.children(path, opts)\
.map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }

files = if Dir.respond_to?(:children)
Dir.children(path, opts)
else
Dir.entries(path(), opts)
.reject {|n| n == '.' or n == '..' }
end

files.map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
end

def stat
Expand Down
2 changes: 1 addition & 1 deletion lib/fileutils/fileutils.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.description = "Several file utility methods for copying, moving, removing, etc."

s.require_path = %w{lib}
s.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "fileutils.gemspec", "lib/fileutils.rb", "lib/fileutils/version.rb"]
s.files = ["LICENSE.txt", "README.md", "Rakefile", "fileutils.gemspec", "lib/fileutils.rb", "lib/fileutils/version.rb"]
s.required_ruby_version = ">= 2.3.0"

s.authors = ["Minero Aoki"]
Expand Down

0 comments on commit 191b99c

Please sign in to comment.