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

Add File.touch and FileUtils.touch methods #4069

Merged
merged 2 commits into from Mar 17, 2017

Conversation

Sija
Copy link
Contributor

@Sija Sija commented Feb 23, 2017

As in the title. Low hanging fruit since File.utime is now in stdlib.

src/file.cr Outdated
unless exists?(filename)
File.open(filename, "a") { }
end
time ||= Time.now
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put = Time.now as the default argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this way you might still pass a nil as an argument.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would someone pass nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong opinion about it, might as well change it to = Time.now.

# ```
# FileUtils.touch(["foo", "bar"])
# ```
def touch(paths : Enumerable(String), time : Time? = nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a *paths version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, though I'm just following convention from FileUtils here.

@Sija
Copy link
Contributor Author

Sija commented Mar 3, 2017

Ping? Anything actionable here?

@luislavena
Copy link
Contributor

@Sija I think the removal of the support for nil should be enough. Either you provide a Time reference or let the default Time.now be used.

@Sija Sija force-pushed the file-touch branch 2 times, most recently from 315eaf5 to 6690f74 Compare March 3, 2017 21:14
@Sija
Copy link
Contributor Author

Sija commented Mar 3, 2017

@luislavena 'fair nuff, done!

@Sija
Copy link
Contributor Author

Sija commented Mar 17, 2017

Is this PR is ready to 🚢 ?

@bcardiff bcardiff merged commit e747c3d into crystal-lang:master Mar 17, 2017
@bcardiff bcardiff added this to the Next milestone Mar 17, 2017
@bcardiff
Copy link
Member

So, should we redo some changes applied on #3986 since there is a built in touch?

@Sija
Copy link
Contributor Author

Sija commented Mar 18, 2017

@bcardiff its usage is part of a broader Process.exec method testing and thus using here File.touch would make the test miss its point.

@bcardiff
Copy link
Member

@Sija yes, you are right.

@rdp
Copy link
Contributor

rdp commented Oct 20, 2018

File feels like the right place for this, thank you for fixing another ruby oddity :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants