-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Conversation
There was a problem hiding this 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`)?
Library/Homebrew/cleanup.rb
Outdated
@@ -1,10 +1,11 @@ | |||
require "active_support/core_ext/numeric/time" |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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 = {}) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
38f67ee
to
1dd3477
Compare
brew style
with your changes locally?brew tests
with your changes locally?