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

Implement RRule::Rule#humanize #49

Merged
merged 10 commits into from
Jan 3, 2023
Merged

Conversation

craigmcnamara
Copy link
Contributor

@craigmcnamara craigmcnamara commented Nov 29, 2022

I got jealous of https://github.com/jakubroztocil/rrule being able to print a human understandable version of RRule and decided to take a run at making it work.

Are you at all interested in this or should I keep it in my own fork? This is a bit incomplete, but it's actually all I need for my app. If you'd take the pull request I'd go through the motions to complete the port.

@rmitchell-sq
Copy link
Collaborator

I got jealous of https://github.com/jakubroztocil/rrule being able to print a human understandable version of RRule and decided to take a run at making it work.

Are you at all interested in this or should I keep it in my own fork? This is a bit incomplete, but it's actually all I need for my app. If you'd take the pull request I'd go through the motions to complete the port.

Sure, happy to add this, just left one comment.

Ideally this would be i18n-able, but I can imagine that'd be more complicated than just swapping out the words, and that non-English languages likely have different sentence structures that change the way you need to humanize the rule, so fine to leave that for a potential future improvement.

@craigmcnamara craigmcnamara reopened this Nov 29, 2022
craigmcnamara added a commit to mes-amis/ruby-rrule that referenced this pull request Dec 17, 2022
@craigmcnamara
Copy link
Contributor Author

Ok I think it's ready for a review and merge. The highlights are

  • Humanizer is self contained now.
  • No more Seattle Style or JS idioms to make RuboCop happy.
  • Implemented more cases that can be humanized.

@@ -12,7 +12,7 @@ def initialize(index, ordinal = nil)
def self.parse(weekday)
match = /([+-]?\d+)?([A-Z]{2})/.match(weekday)
index = RRule::WEEKDAYS.index(match[2])
ordinal = match[1] ? match[1].to_i : nil
ordinal = match[1]&.to_i
Copy link
Contributor Author

@craigmcnamara craigmcnamara Dec 17, 2022

Choose a reason for hiding this comment

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

I didn't mean to change this, but RuboCop was complaining about it. Since safe nav has been around since Ruby 2.3 it should be fairly safe to change. I didn't notice any official Ruby versions listed as supported anywhere.

@craigmcnamara
Copy link
Contributor Author

craigmcnamara commented Dec 17, 2022

Ideally this would be i18n-able, but I can imagine that'd be more complicated than just swapping out the words, and that non-English languages likely have different sentence structures that change the way you need to humanize the rule, so fine to leave that for a potential future improvement.

I now have a morbid curiosity about what it would take to make this string slamming be more in line with i18n. I'll be looking in to that a bit more as a followup pull request.

@rmitchell-sq
Copy link
Collaborator

LGTM, thanks for the PR!

@rmitchell-sq rmitchell-sq merged commit 819a4ae into square:master Jan 3, 2023
@bahriddin
Copy link
Contributor

Thanks for the great gem and nice PR 👏🏼
Are you planning to release a new tag with latest changes?
Regards!

@rmitchell-sq
Copy link
Collaborator

Thanks for the great gem and nice PR 👏🏼 Are you planning to release a new tag with latest changes? Regards!

Yep, makes sense - maybe once #55 lands, just to get all caught up?

@rmitchell-sq
Copy link
Collaborator

Thanks for the great gem and nice PR 👏🏼 Are you planning to release a new tag with latest changes? Regards!

Released as 0.6.0 🎉

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