Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Configuration 如何从Yaml配置文件的初始化脚本调用变量_Configuration_Initialization_Yaml_Erb - Fatal编程技术网

Configuration 如何从Yaml配置文件的初始化脚本调用变量

Configuration 如何从Yaml配置文件的初始化脚本调用变量,configuration,initialization,yaml,erb,Configuration,Initialization,Yaml,Erb,我正在尝试运行一个初始化脚本来帮助我从config.yml文件中检索数据 config.yml当前看起来如下所示: production: &default log_server: log_server deploy_to: /path/to/deploy unicorn: port: 8080 uid: user gid: group development: &dev <<: *default deploy_to:p

我正在尝试运行一个初始化脚本来帮助我从config.yml文件中检索数据

config.yml当前看起来如下所示:

production: &default
  log_server: log_server
  deploy_to: /path/to/deploy
  unicorn:
    port: 8080
    uid: user 
    gid: group
 development: &dev
  <<: *default
  deploy_to:path/to/deploy
  unicorn:
    port: 80
    uid: unicorn 
    gid: unicorngroup
{"production"=>{"log_server"=>"log_server", "deploy_to"=>"path/to/deploy",  "unicorn"=>{"port"=>8080, "uid"=>"user", "gid"=>"group"}}, "development"=>{"log_server"=>"log_server", "deploy_to"=>"path/to/deploy", "unicorn"=>{"port"=>80, "uid"=>"unicorn", "gid"=>"unicorn group"}}
如果我“放置配置”,则输出如下所示:

production: &default
  log_server: log_server
  deploy_to: /path/to/deploy
  unicorn:
    port: 8080
    uid: user 
    gid: group
 development: &dev
  <<: *default
  deploy_to:path/to/deploy
  unicorn:
    port: 80
    uid: unicorn 
    gid: unicorngroup
{"production"=>{"log_server"=>"log_server", "deploy_to"=>"path/to/deploy",  "unicorn"=>{"port"=>8080, "uid"=>"user", "gid"=>"group"}}, "development"=>{"log_server"=>"log_server", "deploy_to"=>"path/to/deploy", "unicorn"=>{"port"=>80, "uid"=>"unicorn", "gid"=>"unicorn group"}}
如果我只想从prod或development中获取某些变量,那么我将如何调用这些变量呢?我的目标是能够根据我使用的环境调用任何变量