{"id":153,"date":"2017-06-22T20:03:43","date_gmt":"2017-06-22T11:03:43","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=153"},"modified":"2020-01-07T01:57:22","modified_gmt":"2020-01-06T16:57:22","slug":"yamlyml%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9-for-ruby","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=153","title":{"rendered":"YAML\u8a00\u8a9e\u3068\u306f\uff1fRuby\u3067\u306eYAML\u8a00\u8a9e\u306e\u4f7f\u3044\u65b9\u3092\u89e3\u8aac"},"content":{"rendered":"<pre><code class=\"yaml\">mysql2:\nhost: 'localhost'\nuser: 'root'\n<\/code><\/pre>\n<pre><code class=\"rb\">require 'yaml'\nfile=File.expand_path('..\/config.yaml', __FILE__)\n@config=YAML.load_file(file)\np mysql2=@config['mysql2']\n# =&gt;{\"host\"=&gt;\"localhost\", \"user\"=&gt;\"root\"}\np mysql2['host']\n# =&gt;localhost\n\n#dump\/yaml\u3078\u306e\u66f8\u304d\u8fbc\u307f\u30fb\u7de8\u96c6\nYAML.dump( @config ,\nFile.open(File.expand_path('..\/dump.yaml',\n__FILE__), 'w') )\n\n<\/code><\/pre>\n<h2>\u6539\u884c\u306f&#8221;|&#8221;<\/h2>\n<p>d1:<br \/>\naaa<br \/>\nbbb<br \/>\nccc<br \/>\nd2: |<br \/>\naaa<br \/>\nbbb<br \/>\nccc<\/p>\n<p>d3: &gt;<br \/>\nddd<br \/>\neee<br \/>\nfff<\/p>\n<p>\u51fa\u529b<br \/>\n{&#8220;d1&#8243;=&gt;&#8221;aaa bbb ccc&#8221;, &#8220;d2&#8243;=&gt;&#8221;aaa\\nbbb\\nccc\\n&#8221;, &#8220;d3&#8243;=&gt;&#8221;ddd eee fff\\n&#8221;}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql2: host: &#8216;localhost&#8217; user: &#8216;root&#8217; require &#8216;yaml&#8217; f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[78],"tags":[],"acf":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8Rxwo-2t","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/153"}],"collection":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=153"}],"version-history":[{"count":1,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/153\/revisions"}],"predecessor-version":[{"id":2087,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/153\/revisions\/2087"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}