I am upgrading my Rails 4.2 app to 5.1. One of the tests I have, is to verify that all the English i18n strings have a counterpart in my other languages.
I noticed that this test fails now, since it seems like Rails 5.1 changed / moved some of the locale keys in the errors section. Here are some of my missing keys for example:
- errors.messages.required: 'must exist'
- errors.or: 'or'
- errors.array?: 'must be an array'
- errors.excludes?: 'must not include %{value}'
- errors.excluded_from?.arg.default: 'must not be one of: %{list}'
- errors.excluded_from?.arg.range: 'must not be one of: %{list_left} - %{list_right}'
So my question is: Does the question mark in the key name (like errors.excludes?) have a special meaning? Or should I just implement it verbatim in my other languages. For a key like errors.excluded_from?.arg.range - should my YAML just be like this?:
errors:
excluded_from?:
arg:
range: ...
default: ...
Thanks in advance.
Related
recently I have a problem with rubocop. It says:
service/job/some_module.rb:80:37: C: Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.
def job_capabilize(*fields, of: [], autodefine: false)
^^
so I updated my .rubocop.yml file with
Naming/UncommunicativeMethodParamName:
AllowedNames:
- of
after that my rubocop started to argue on:
another_service/another_service_mod.rb:13:24: C: Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.
def create(at:)
^^
"at" is a name from rubocop gem by default.
So the question is how to add "of" to AllowedNames, to use both names from gem and names I allowed without duplicating them all in my yml?
UPDATE
Thanks to #Siim Liiser I resolved this by:
[...snipet...]
inherit_mode:
merge:
- AllowedNames
Naming/UncommunicativeMethodParamName:
AllowedNames:
- of
- as
[...snipet...]
inherit_mode:
merge:
- AllowedNames
See rubocop docs
I can upgrade php 5.2 in my server. I have to make this server work today (the vacation I have planned tomorrow is under question because of this error) with new testlink. I am stuck with following error i.e Paamayim nekudotayims.
What changes I should do to resolve it?
This link contains the file with the bug.
The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.
SO may be in your codes you try to call static method or properties with wrong operator.
From Wikipedia:
In PHP, the scope resolution operator is also called Paamayim
Nekudotayim (Hebrew: פעמיים נקודתיים), which means “double colon” in
Hebrew.
The name "Paamayim Nekudotayim" was introduced in the
Israeli-developed Zend Engine 0.5 used in PHP 3. Although it has been
confusing to many developers who do not speak Hebrew, it is still
being used in PHP 5, as in this sample error message:
$ php -r :: Parse error: syntax error, unexpected
T_PAAMAYIM_NEKUDOTAYIM
As of PHP 5.4, error messages concerning the scope resolution operator
still include this name, but have clarified its meaning somewhat:
$ php -r :: Parse error: syntax error, unexpected '::'
(T_PAAMAYIM_NEKUDOTAYIM)
I am using a REXML Ruby parser to parse an XML file. But on a 64 bit AIX box with 64 bit Ruby, I am getting the following error:
REXML::ParseException: #<REXML::ParseException: #<RegexpError: Stack overflow in
regexp matcher:
/^<((?>(?:[\w:][\-\w\d.]*:)?[\w:][\-\w\d.]*))\s*((?>\s+(?:[\w:][\-\w\d.]*:)?[\w:][\-\w\d.]*\s*=\s*(["']).*?\3)*)\s*(\/)?>/mu>
The call for the same is something like this:
REXML::Document.new(File.open(actual_file_name, "r"))
Does anyone have an idea regarding how to solve this issue?
I've had several issues for REXML, it doesn't seem to be the most mature library. Usually I use Nokogiri for Ruby XML parsing stuff, it should be faster and more stable than REXML. After installing it with sudo gem install nokogiri, you can use something like this to get a DOM instance:
doc = Nokogiri.XML(File.open(actual_file_name, 'rb'))
# => #<Nokogiri::XML::Document:0xf1de34 name="document" [...] >
The documentation on the official webpage is also much better than that of REXML, IMHO.
I almost immediately found the answer.
The first thing I did was to search in the ruby source code for the error being thrown.
I found that regex.h was responsible for this.
In regex.h, the code flow is something like this:
/* Maximum number of duplicates an interval can allow. */
#ifndef RE_DUP_MAX
#define RE_DUP_MAX ((1 << 15) - 1)
#endif
Now the problem here is RE_DUP_MAX. On AIX box, the same constant has been defined somewhere in /usr/include.
I searched for it and found in
/usr/include/NLregexp.h
/usr/include/sys/limits.h
/usr/include/unistd.h
I am not sure which of the three is being used(most probably NLregexp.h).
In these headers, the value of RE_DUP_MAX has been set to 255! So there is a cap placed on the number of repetitions of a regex!
In short, the reason is the compilation taking the system defined value than that we define in regex.h!
This also answers my question which i had asked recently:
Regex limit in ruby 64 bit aix compilation
I was not able to answer it immediately as i need to have min of 100 reputation :D :D
Cheers!
i found a ruby encryption library which is using this function.
def process(text)
0.upto(text.length-1) {|i| text[i] = text[i] ^ round}
text
end
in ruby 1.9.x it throws an error - undefined method ^' for "\x1A":String__
is there any work around in ruby 1.9.x?
after googling i came to know that "In Ruby 1.9 string[index] returns character not code of the character (like it was in 1.8)." (https://rails.lighthouseapp.com/projects/8994/tickets/3144-undefined-method-for-string-ror-234)
Thanks in advance
Try text[i].ord ^ round. See Getting an ASCII character code in Ruby using `?` (question mark) fails for more info.
I am upgrading my app from rails 2 to 3 and when i 'require' this file that has an email address validator i get an 'invalid multibyte escape' error with:
dtext = '[^\\\\x80]'
pattern = /\A#{dtext}\z/
Any thoughts?
Try using:
pattern = /\A#{dtext}\z/, nil, 'n'
Check out details on encodings and regexp for more.
And I use and recommend this awesome article on encodings in Ruby.
Modify the rfc822.rb file and change the addr_spec line to the following:
addr_spec = Regexp.new("#{local_part}\\x40#{domain}", nil, 'n')
That should resolve the issue. I got the solution from another gem, see https://github.com/saepia/rfc822/blob/master/lib/rfc822.rb