| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
| |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| |
|
|
|
|
|
|
|
|
|
| |
Previously apply_inflections would only use the :en uncountables
rather then the ones for the locale that was passed to pluralize or
singularize.
This changes apply_inflections to take a locale which it will use to
find the uncountables.
|
|\
| |
| |
| |
| |
| | |
mubashirhanif/add_keep_id_suffix_option_to_humanize_new
Add keep id suffix option to humanize new
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
some documentation
remove extra whitespace.
Added id in the middle test case and corrected some testcases.
Some Coding standard guidelines corrections as suggested by codeclimate.
Some more corrections suggested by codeclimate.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
% ruby -ve "p 'ほげ'.encode(Encoding::UTF_8_MAC)"
jruby 1.7.26 (1.9.3p551) 2016-08-26 69763b8 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 +jit [darwin-x86_64]
"\u307B\u3052"
% ruby -ve "p 'ほげ'.encode(Encoding::UTF_8_MAC)"
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
"\u307B\u3051\u3099"
% ruby -ve "p 'ほげ'.encode(Encoding::UTF_8_MAC)"
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin14]
"\u307B\u3051\u3099"
|
| | |
|
|\ \
| |/
|/|
| |
| |
| | |
Fix ActiveSupport::Inflector.pluralize behavior for words that consist of non-ASCII characters
(test only; the original bug was fixed by 1bf50badd943e684a56a03392ef0ddafefca0ad7)
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The code below returns "猫" in 3.2, but "猫s" in 4.0.
```ruby
ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable "猫"
end
"猫".pluralize
```
|
| | |
|
| |
| |
| |
| |
| |
| | |
All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772.
But comments was still kept absolute position. This commit aligns
comments with method definitions for consistency.
|
| | |
|
| |
| |
| |
| |
| | |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Added test cases
Using kwargs instead of three seperate functions
Updated parameterize in transliterate.rb
Updated parameterize in transliterate.rb
Added deprecation warnings and updating RDoc+Guide
Misspelled separtor. Fixed.
Deprecated test cases and added support to parameterize with keyword parameters
Squashing commits.
Fixed test cases and added deprecated test cases
Small changes to Gemfile.lock and CHANGELOG
Update Gemfile.lock
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is not something that is failing at the moment, but can do it
eventually. I had the issue with db62081 as the HEAD and with the
following change:
```
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -101,6 +101,7 @@ class InflectorTest < ActiveSupport::TestCase
def test_acronyms
ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym("API")
+ inflect.acronym("HTM")
inflect.acronym("HTML")
inflect.acronym("HTTP")
inflect.acronym("RESTful")
```
I was expecting only `test_acronyms` to fail, but with a specific `seed`
others were also failing: `ruby -w -I"lib:test" test/inflector_test.rb
--seed 4313`.
Now, `inflections` instance is duplicated on `setup` and restored on
`teardown`.
I decided to benchmark and check the impact of the patch and it seems
to me to be fine.
```
Calculating -------------------------------------
without changes 1.000 i/100ms
with setup dup 1.000 i/100ms
with block dup 1.000 i/100ms
-------------------------------------------------
without changes 0.817 (± 0.0%) i/s - 5.000 in
6.119916s
with setup dup 0.784 (± 0.0%) i/s - 4.000
with block dup 0.797 (± 0.0%) i/s - 4.000
```
Where `with setup dup` duplicates on setup for each test and `with block`
duplicates for just for tests that actually modify `inflections`.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I suspect that positive lookbehind would have been used in the
original implementation had it been available in supported Ruby
versions at the time. Now that Rails requires Ruby 1.9.2 or above,
this is no longer an issue.
This fixes #14146 for acronyms such as APIRESTful. This technique also
addresses namespaced acronyms that are not entirely uppercased. This
was broken when the commit was originally written but has since been
fixed in ccbb481. The latter does not deal with adjacent acronyms so
this commit wins.
|
|
|
|
|
|
| |
Fixes #8015, #9756.
[Fred Wu & Matthew Draper]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since d3071db1, the apply_inflections method check if the downcased
version of a string is contained inside the "whitelist" of uncountable
words. However, if the word is composed of capital letters, it won't be
matched in the list while it should.
We can't simply revert to the previous behavior as there is a
performance concern (benchmarked over /usr/share/dict/words):
Before d3071db1 135.610000 0.290000 135.900000 (137.807081)
Since d3071db1 22.170000 0.020000 22.190000 ( 22.530005)
With the patch 22.060000 0.020000 22.080000 ( 22.125771)
Benchmarked with http://git.io/aFnWig
This way, the solution is to put the down-case version of words inside
the @uncountables array.
|
|\
| |
| |
| | |
Fix test cases for inflector.rb
|
|/
|
|
|
|
| |
`yield` was missing in #with_dup, due to which 57 assertions were not running
in real, and all tests were passing by default.
Error was introduced in commit - 31ceb5e.
|
| |
|
| |
|
|
|
|
|
|
|
| |
So strings can be humanized without being capitalized:
'employee_salary'.humanize # => "Employee salary"
'employee_salary'.humanize(capitalize: false) # => "employee salary"
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When we call define_method with non-english chars like ¿por qué? it
errors out on JRuby as of 1.7.4 & would leave out the following error
invalid byte sequence in US-ASCII
To work around this issue, I have switched to define_test method call
define method with fixed string & the index of the hash. the index was
added because otherwise, ruby will raise method redefined warning.
As far as I can see there are no side-effect of this change for
other implementations. For readbility I have added a message to
asssert_equal informing for which word/phase the test has passed.
Before this Change:
JRuby:
Tests terminated suddenly with an error. no reported of Failues
or errors
MRI:
All Green.
After this Change,
JRuby:
the `ActiveSupport` TestsSuite gracefully fails with report at the end which test failed & why.
MRI:
All Green(no change)
|
| |
|
|
|
|
|
|
|
|
| |
This reverts commit fa3ef8e82ab2f96cf15ef9bc885b2468fad77621, reversing
changes made to e0af93dd3a5eeee2e2a67b05f34afb66cc80c00b.
Reason: Routes, Active Record and the rendering stack should not depend
on the default locale
|
|
|
|
|
|
|
|
| |
The inflector was made aware of locales in 7db0b073fec6bc3e6f213b58c76e7f43fcc2ab97,
but it defaulted to :en. That should actually be our default
locale instead.
Fixes #10125
|
| |
|
|
|
|
|
|
|
|
|
| |
This reverts commit 867dc1700f32aae6f98c4651bd501597e6b52bc0, reversing
changes made to 9a421aaa8285cf2a7ecb1af370748b0337818930.
This breaks anyone who's using ForceSSL: https://travis-ci.org/rails-api/rails-api/jobs/5556065
Please see comments on #8156 for some discussion.
|
|
|
|
| |
disregarding specified acronyms, fixes #8015
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The Inflector is currently not very supportive of internationalized
websites. If a user wants to singularize and/or pluralize words based on
any locale other than English, they must define each case in locale
files. Rather than create large locale files with mappings between
singular and plural words, why not allow the Inflector to accept a
locale?
This patch makes ActiveSupport::Inflector locale aware and uses `:en`` unless
otherwise specified. Users will still be provided a list of English (:en)
inflections, but they may additionally define inflection rules for other
locales. Each list is kept separately and permanently. There is no reason to
limit users to one list of inflections:
ActiveSupport::Inflector.inflections(:es) do |inflect|
inflect.plural(/$/, 's')
inflect.plural(/([^aeéiou])$/i, '\1es')
inflect.plural(/([aeiou]s)$/i, '\1')
inflect.plural(/z$/i, 'ces')
inflect.plural(/á([sn])$/i, 'a\1es')
inflect.plural(/é([sn])$/i, 'e\1es')
inflect.plural(/í([sn])$/i, 'i\1es')
inflect.plural(/ó([sn])$/i, 'o\1es')
inflect.plural(/ú([sn])$/i, 'u\1es')
inflect.singular(/s$/, '')
inflect.singular(/es$/, '')
inflect.irregular('el', 'los')
end
'ley'.pluralize(:es) # => "leyes"
'ley'.pluralize(:en) # => "leys"
'avión'.pluralize(:es) # => "aviones"
'avión'.pluralize(:en) # => "avións"
A multilingual Inflector should be of use to anybody that is tasked with
internationalizing their Rails application.
Signed-off-by: David Celis <david@davidcelis.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a follow up to #4719. It appears that singularize and pluralize
are supposed to be idempotent - i.e. when you call singularize or
pluralize multiple times on the same string, you should get the same
result. (At least for the "officially supported" cases that the stock
inflector is designed to handle.) #4719 added the missing tests for
regular cases, and this commit added the missing tests for the
irregularities.
While I'm at that, I also synced up the irregularity test cases with
the current set of irregularity cases that we ship out-of-the-box.
|
|
|
|
|
|
|
|
| |
Trying alternative implementations of the inflections
is hard because the suite is coupled with the current
one, setting ivars by hand etc. This commit relies on
initialize_dup, as long as you maintain that one you
can tweak the implementation.
|
|\
| |
| | |
Add Inflection test (and fixes) to ensure singularizing a singular actually give you the correct singular in more cases
|
| |
| |
| |
| | |
give you the correct singular in more cases
|
|/ |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This commit also implements a faster version of #demodulize I was unable
to isolate with git add --patch.
Not a big fan of the name #deconstantize. It complements #demodulize
getting rid of the rightmost constant, hence the name, but it is
unrelated to the well-known #constantize. So unsure. Could not come
with anything better, please feel free to rename.
|
|
|
|
| |
This is also faster on 1.9.
|
|
|
|
| |
refactored common constantize tests into ConstantizeTestCases
|
| |
|
| |
|
| |
|