ruby on rails - Colon in the front: YAML syntax -


i'm using sidekiq in project , have following yaml config file:

:concurrency: 5 :pidfile: /tmp/pids/sidekiq.pid :logfile: log/sidekiq.log staging:   :concurrency: 10 production:   :concurrency: 20 queues:   - default 

i haven't seen having colon in front of key before omitting colon produces interesting results. in case of :pidfile: example, colon in front creates/overrides destination file without it, uses 1 there , not write it.

is documented somewhere or how sidekiq expects keys?

yaml keys starting colon generate symbolized keys in ruby, whereas keys without colon generate stringified keys:

require 'yaml'  string =<<-end_of_yaml :concurrency: 5 :pidfile: /tmp/pids/sidekiq.pid :logfile: log/sidekiq.log staging:   :concurrency: 10 production:   :concurrency: 20 queues:   - default end_of_yaml  yaml.load(string) # { #     :concurrency => 5, #     :pidfile     => "/tmp/pids/sidekiq.pid", #     :logfile     => "log/sidekiq.log", #     "staging"    => { #         :concurrency => 10 #     }, #     "production" => { #         :concurrency => 20 #     }, #     "queues"     => [ #         [0] "default" #     ] # } 

note: if gem depends on symbolized keys stringified keys not override defaults.


Comments

Post a Comment

Popular posts from this blog

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

yii2 - Yii 2 Running a Cron in the basic template -

android - Crash when clicking button with custom theme -