| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|\
| |
| |
| |
| |
| |
| |
| |
| | |
Enable number_to_percentage to keep the number's precision by allowing :precision option value to be nil
Conflicts:
activesupport/CHANGELOG.md
activesupport/lib/active_support/number_helper.rb
activesupport/test/number_helper_test.rb
|
| |
| |
| |
| |
| |
| | |
:precision to be nil
number_helper.number_to_percentage(1000, precision: nil) # => "1000%"
|
| |
| |
| |
| |
| | |
The character "*" is unnecessary in option candidates.
This incorrect markup was injected in e8c9aeca .
|
| | |
|
| | |
|
| |
| |
| |
| | |
These classes are not meant to be public.
|
| | |
|
| | |
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | | |
Refactor and clean up number helpers
Conflicts:
activesupport/lib/active_support/number_helper.rb
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Due to the overall complexity of each method individually as well as the
global shared private module methods, this pulls each helper into it's
own converter class inheriting from a generic `NumberBuilder` class.
* The `NumberBuilder` class contains the private methods needed for each helper
method an eliminates the need for special definition of specialized private
module methods.
* The `ActiveSupport::NumberHelper::DEFAULTS` constant has been moved
into the `NumberBuilder` class because the `NumberBuilder` is the only
class which needs access to it.
* For each of the builders, the `#convert` method is broken down to
smaller parts and extracted into private methods for clarity of purpose.
* Most of the mutation that once was necessary has now been eliminated.
* Several of the mathematical operations for percentage, delimited, and
rounded have been moved into private methods to ease readability and
clarity.
* Internationalization is still a bit crufty, and definitely could be
improved, but it is functional and a bit easier to follow.
The following helpers were extracted into their respective classes.
* `#number_to_percentage` -> `NumberToPercentageConverter`
* `#number_to_delimited` -> `NumberToDelimitedConverter`
* `#number_to_phone` -> `NumberToPhoneConverter`
* `#number_to_currency` -> `NumberToCurrencyConverter`
* `#number_to_rounded` -> `NumberToRoundedConverter`
* `#number_to_human_size` -> `NumberToHumanSizeConverter`
* `#number_to_human` -> `NumberToHumanConverter`
|
| | |
| | |
| | |
| | |
| | | |
* Use destructive `map` and `sort_by` to save extra object creation.
* Create `INVERTED_DECIMAL_UNITS.invert` constant instead of repeatedly doing `DECIMAL_UNITS.invert`
|
| |/
|/| |
|
|/
|
|
| |
[ci skip]
|
| |
|
|
|
|
|
|
| |
ActiveSupport::NumberHelper#number_to_human now returns the number unaltered when
the units hash does not contain the needed key, e.g. when the number provided is less
than the largest key provided.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Always merge I18n format values, namespaced or not, over the default
ones, to ensure I18n format defaults will have precedence over our
namespaced values.
Precedence should happen like this:
default :format
default :namespace :format
i18n :format
i18n :namespace :format
Because we cannot allow our namespaced default to override a I18n
:format config - ie precision in I18n :format should always have higher
precedence than our default precision for a particular :namespace.
Also simplify default format options logic.
|
|
|
|
|
|
|
|
| |
Action Pack already comes with a default locale fine for :en, that is
always loaded. We can just fallback to this locale for defaults, if
values for the current locale cannot be found.
Closes #4420, #2802, #2890.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Some of these requires are now only necessary in
ActiveSupport::NumberHelper. Add hash/keys require due to symbolize_keys
usage in number helpers. Also remove some whitespaces.
Closes #6414
|
| |
|
|
|