Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ruby keyword parameter deprecation warnings #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions lib/pathutil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,10 @@ def safe_copy(to, root: nil, ignore: [])
to = self.class.new(to)

if directory?
safe_copy_directory(to, {
:root => root, :ignore => ignore
})
safe_copy_directory(to, root: root, ignore: ignore)

else
safe_copy_file(to, {
:root => root
})
safe_copy_file(to, root: root)
end
end

Expand Down Expand Up @@ -494,14 +490,10 @@ def read(*args, **kwd)
kwd[:encoding] ||= encoding

if normalize[:read]
File.read(self, *args, kwd).encode({
:universal_newline => true
})
File.read(self, *args, **kwd).encode(universal_newline: true)

else
File.read(
self, *args, kwd
)
File.read(self, *args, **kwd)
end
end

Expand Down Expand Up @@ -534,13 +526,13 @@ def readlines(*args, **kwd)
kwd[:encoding] ||= encoding

if normalize[:read]
File.readlines(self, *args, kwd).encode({
File.readlines(self, *args, **kwd).encode({
:universal_newline => true
})

else
File.readlines(
self, *args, kwd
self, *args, **kwd
)
end
end
Expand All @@ -556,11 +548,11 @@ def write(data, *args, **kwd)
if normalize[:write]
File.write(self, data.encode(
:crlf_newline => true
), *args, kwd)
), *args, **kwd)

else
File.write(
self, data, *args, kwd
self, data, *args, **kwd
)
end
end
Expand Down Expand Up @@ -670,9 +662,7 @@ def expanded_paths(path)
private
def safe_copy_file(to, root: nil)
raise Errno::EPERM, "#{self} not in #{root}" unless in_path?(root)
FileUtils.cp(self, to, {
:preserve => true
})
FileUtils.cp(self, to, preserve: true)
end

# --
Expand All @@ -697,15 +687,11 @@ def safe_copy_directory(to, root: nil, ignore: [])
}"

elsif file.file?
FileUtils.cp(file, to, {
:preserve => true
})
FileUtils.cp(file, to, preserve: true)

else
path = file.realpath
path.safe_copy(to.join(file.basename), {
:root => root, :ignore => ignore
})
path.safe_copy(to.join(file.basename), root: root, ignore: ignore)
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions spec/tests/lib/pathutil/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@
#

after do
described_class.load_yaml("hello: world", {
:aliases => true
})
described_class.load_yaml("hello: world", aliases: true)
end
end

Expand Down
13 changes: 4 additions & 9 deletions spec/tests/lib/pathutil_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,7 @@

context "with an encoding argument" do
before do
file.write("hello", {
:encoding => "ASCII"
})
file.write("hello", encoding: "ASCII")
end

#
Expand Down Expand Up @@ -1050,11 +1048,10 @@
name1.join(name2.basename, name1.basename).touch
name1.join(name1.basename).touch

name1.safe_copy(name2, {
:root => tmpdir1, :ignore => [
name1.safe_copy(name2, root: tmpdir1, ignore: [
name1.join(name2.basename, name1.basename)
]
})
)
end

#
Expand All @@ -1077,9 +1074,7 @@
name1.join(name2.basename, name1.basename).touch
name1.join(name1.basename).touch

name1.safe_copy(name2, {
:root => tmpdir1
})
name1.safe_copy(name2, root: tmpdir1)
end

#
Expand Down