laradji / zabbix

Zabbix chef cookbook
Apache License 2.0
91 stars 124 forks source link

Don't quote pure numbers #178

Closed ftclausen closed 10 years ago

ftclausen commented 10 years ago

Don't quote numbers otherwise the ruby underscore formatting (e.g. 100_000) is rendered in templates (should that formatting be added in the future or a wrapper cookbook).

I got bitten by this in a wrapper cookbook where, because the original attribute is quoted, it was rendered as text with an "_" which made the Zabbix server barf since that is not a valid number.

laradji commented 10 years ago

mmmm, this does not pass the test for the same reason ?

attributes/server.rb:12:57: C: Separate every 3 digits in the integer portion of a number with underscores(_).
default['zabbix']['server']['max_housekeeper_delete'] = 100000
                                                                                       ^^^^^^
laradji commented 10 years ago

Maybe we should "100_000".to_i ?

guilhem commented 10 years ago
100_000.to_s
=> "100000"

so 100_000 is a valid ruby integer. Can you change your commit to use it? (with squashing)

EDIT: more I read your PR, more I think I don't understand this problem xD So I may be wrong on what I'm saying.

ftclausen commented 10 years ago

The problem is that an integer quoted as a string such as

normal['some_attr'] = '100_000' 

gets rendered verbatim in in templates. By making it unquoted it is properly rendered as a number e.g.

normal['some_attr'] = 100_000
guilhem commented 10 years ago

@ftclausen ok, so can you please fix your commit to complain with rubocop?

ftclausen commented 10 years ago

@guilhem - yes, indeed, I'll fix this shortly.