Skip to content

Append leap instructions to instruct user not use Ruby Date class#1752

Merged
kotp merged 1 commit into
exercism:mainfrom
PatrickMcSweeny:leap
May 21, 2025
Merged

Append leap instructions to instruct user not use Ruby Date class#1752
kotp merged 1 commit into
exercism:mainfrom
PatrickMcSweeny:leap

Conversation

@PatrickMcSweeny
Copy link
Copy Markdown
Contributor

@PatrickMcSweeny PatrickMcSweeny commented May 19, 2025

The discussion in #1532 called for appending the instructions for leap to instruct the user not to use the Date class in Ruby.

Discussion on forums is: Append Ruby leap instructions to instruct user not use Date class.

@github-actions github-actions Bot closed this May 19, 2025
Comment thread exercises/practice/leap/.docs/instructions.md Outdated
@PatrickMcSweeny
Copy link
Copy Markdown
Contributor Author

I updated my commit to create a separate append file and instruct the user not to use the date class specifically.

@@ -0,0 +1,3 @@
# Restrictions

Create your own implementation rather than using the Date class from the Ruby standard library.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might also work:

Suggested change
Create your own implementation rather than using the Date class from the Ruby standard library.
Avoid using `Date#leap?` from the Standard Library.

Simpler English, and uses syntax that you would see to reference the exact method.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I like that. Out of curiosity, is standard library supposed to be capitalized in Ruby circles? Google search seems to have search results for it both being capitalized and not capitalized. Generally, standard library doesn't refer to something specifically with that name so I don't see it capitalized typically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably Ruby standard library is good. The link provides a direct link to the specific thing in the standard library.

Copy link
Copy Markdown
Contributor Author

@PatrickMcSweeny PatrickMcSweeny May 20, 2025

Choose a reason for hiding this comment

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

The tests also prevent the user from using the 'gregorian_leap' or 'julian_leap' methods, so I updated it to be 'Avoid using the Date class from the Standard Library.'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That does not do what you think it does (if you think it prevents the user from using those).

You can see this if you test it, by writing this code in the example.rb file, and run rake test:leap:

  def leap?
    Date.gregorian_leap?(number)
  end

I always thought it was just there to be informative to the reader, but never thought it was meant to be "effective code".

There are trivial ways to get around it, even if it might work in certain circumstances.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I would suggest doing, I think, is to leave the advice to the analyzer, and suggest to not use Date#leap? explicitly here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I updated my commit to what you suggested earlier.

@BNAndras
Copy link
Copy Markdown
Member

BNAndras commented May 20, 2025

It seems the OS for the CI needs to be bumped in a separate PR. Ubuntu 20.04 hasn't been supported by GHA for about a month so it should be bumped to 22.04 or 24.04.

Copy link
Copy Markdown
Member

@kotp kotp left a comment

Choose a reason for hiding this comment

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

I will approve it, but consider the case of "Standard Library" and make a judgement call to leave it or change it to Standard library or standard library. I think the Core and Standard libraries may be title cased as they are the names given to each library, collection of classes and modules, in Ruby that are supplied when installed.

@PatrickMcSweeny
Copy link
Copy Markdown
Contributor Author

This docs site uses title case, so I will go with that.

https://docs.ruby-lang.org/en/3.3/standard_library_rdoc.html

@kotp kotp merged commit 4baf4a5 into exercism:main May 21, 2025
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants