How do I parse a YAML file in Ruby?

前端 未结 3 852
时光取名叫无心
时光取名叫无心 2020-11-29 16:01

I would like to know how to parse a YAML file with the following contents:

--- 
javascripts: 
- fo_global:
  - lazyload-min
  - holla-min

C

3条回答
  •  情话喂你
    2020-11-29 16:57

    Here is the one liner i use, from terminal, to test the content of yml file(s):

    $ ruby  -r yaml -r pp  -e 'pp YAML.load_file("/Users/za/project/application.yml")'
    {"logging"=>
      {"path"=>"/var/logs/",
       "file"=>"TacoCloud.log",
       "level"=>
        {"root"=>"WARN", "org"=>{"springframework"=>{"security"=>"DEBUG"}}}}}
    

提交回复
热议问题