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

Use ActiveSupport’s #days. #4920

Merged
merged 5 commits into from
Oct 8, 2018
Merged

Conversation

reitermarkus
Copy link
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

@ghost ghost assigned reitermarkus Sep 17, 2018
@ghost ghost added the in progress Maintainers are working on this label Sep 17, 2018
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Can you check out how adding this increases the time of brew ruby -e puts' (once includes are in global.rb`)?

@@ -1,10 +1,11 @@
require "active_support/core_ext/numeric/time"
Copy link
Member

Choose a reason for hiding this comment

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

I've been including all of these in global.rb to avoid confusion with methods existing depending on the files that have been included already.

#
# %w( a b c d e ).third # => "c"
def third
self[2]
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to use these globally.

#
# %w( a b c d e ).second # => "b"
def second
self[1]
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to use these globally (ideally with a RuboCop to enforce).

#
# %w( a b c d e ).fourth # => "d"
def fourth
self[3]
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to use these globally.

#
# %w( a b c d e ).fifth # => "e"
def fifth
self[4]
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to use these globally.

#
# %w( a b c d e ).second_to_last # => "d"
def second_to_last
self[-2]
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to use these globally.

#
# ['uno', 'dos', 'tres'].to_sentence(locale: :es)
# # => "uno o dos o al menos tres"
def to_sentence(options = {})
Copy link
Member

Choose a reason for hiding this comment

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

Could use this where .join(", ") is currently used.


class Array
# The human way of thinking about adding stuff to the end of a list is with append.
alias_method :append, :push unless [].respond_to?(:append)
Copy link
Member

Choose a reason for hiding this comment

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

Might be nice to use this (ideally with a RuboCop to enforce it)

alias_method :append, :push unless [].respond_to?(:append)

# The human way of thinking about adding stuff to the beginning of a list is with prepend.
alias_method :prepend, :unshift unless [].respond_to?(:prepend)
Copy link
Member

Choose a reason for hiding this comment

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

Might be nice to use this (ideally with a RuboCop to enforce it)

#
# The differences with <tt>Kernel#Array</tt> explained above
# apply to the rest of <tt>object</tt>s.
def self.wrap(object)
Copy link
Member

Choose a reason for hiding this comment

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

Could replace some Array() or .to_a with this.

@reitermarkus reitermarkus merged commit 7cb1ceb into Homebrew:master Oct 8, 2018
@reitermarkus reitermarkus deleted the days branch October 8, 2018 13:14
@lock lock bot added the outdated PR was locked due to age label Nov 7, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Nov 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in progress Maintainers are working on this outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants