{"id":423,"date":"2013-11-11T17:10:41","date_gmt":"2013-11-11T08:10:41","guid":{"rendered":"https:\/\/blog.id774.net\/entry\/?p=423"},"modified":"2014-05-14T15:03:04","modified_gmt":"2014-05-14T06:03:04","slug":"stdout-%e3%81%a8%e3%81%84%e3%81%86-gem-%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%82%92%e3%81%a4%e3%81%8f%e3%81%a3%e3%81%9f","status":"publish","type":"post","link":"https:\/\/harpuia.id774.net\/entry\/2013\/11\/11\/423\/","title":{"rendered":"\u6a19\u6e96\u51fa\u529b\u3092\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u3064\u304f\u3063\u305f"},"content":{"rendered":"<p>puts \u3084 print \u306a\u3069\u306e\u6a19\u6e96\u51fa\u529b\u306b\u6587\u5b57\u5217\u3092\u51fa\u529b\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306f\u3061\u3087\u3063\u3068\u3057\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u898f\u6a21\u306e\u5927\u304d\u3044\u30d7\u30ed\u30c0\u30af\u30c8\u307e\u3067\u5e45\u5e83\u304f\u4f7f\u308f\u308c\u308b\u3002\u3053\u308c\u3089\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u51fa\u529b\u30e1\u30bd\u30c3\u30c9\u306f\u4f7f\u3046\u306e\u306f\u304a\u624b\u8efd\u3060\u304c\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u3092\u8003\u3048\u308b\u3068\u610f\u5916\u3068\u9762\u5012\u306b\u306a\u308b\u3002\u305d\u3053\u3067\u6a19\u6e96\u51fa\u529b\u306e\u5185\u5bb9\u3092\u7c21\u5358\u306b\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e gem \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f5c\u3063\u305f\u3002<\/p>\n<p>stdout<br \/>\n<a href=\"https:\/\/rubygems.org\/gems\/stdout\">https:\/\/rubygems.org\/gems\/stdout<\/a><\/p>\n<p>\u30bf\u30fc\u30df\u30ca\u30eb\u304b\u3089\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6295\u5165\u3059\u308c\u3070\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u308b\u3002<\/p>\n<div class=\"codecolorer-container text geshi\" style=\"overflow:auto;white-space:nowrap;width:1000px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"text codecolorer\" style=\"white-space:nowrap\">gem install stdout<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u4f3c\u305f\u3088\u3046\u306a\u6a5f\u80fd\u306e\u3082\u306e\u306f\u7121\u304f\u3082\u306a\u304b\u3063\u305f\u304c\u3001\u8981\u4ef6\u306b\u30a4\u30de\u30a4\u30c1\u5408\u308f\u306a\u304b\u3063\u305f\u306e\u3067\u4f5c\u3063\u305f\u307b\u3046\u304c\u65e9\u3044\u3068\u601d\u3063\u305f\u3002\u601d\u60f3\u3068\u3057\u3066\u306f 1) \u6a19\u6e96\u51fa\u529b\u306b\u51fa\u529b\u3055\u308c\u308b\u306f\u305a\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u4e00\u884c\u3054\u3068\u306b\u914d\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u53d6\u5f97\u3067\u304d\u308b 2) \u5c0f\u3055\u304f\u3066\u30b7\u30f3\u30d7\u30eb\u304a\u624b\u8efd\u3001\u3067\u3042\u308b\u3002\u3061\u306a\u307f\u306b <a href=\"http:\/\/hadoop.apache.org\/docs\/r1.1.2\/streaming.html\">Hadoop Streaming<\/a> \u3067\u3082\u6a19\u6e96\u51fa\u529b\u3092\u4f7f\u3046\u306e\u3067 Ruby \u3067 Hadoop \u3092\u5229\u7528\u3059\u308b\u969b\u306e\u30c7\u30d0\u30c3\u30b0\u306b\u3082\u4f7f\u3048\u308b\u3068\u601d\u3046\u3002\u8a73\u7d30\u306f <a href=\"https:\/\/github.com\/id774\/stdout\">GitHub \u306e\u30ea\u30dd\u30b8\u30c8\u30ea<\/a>\u306b\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3084<a href=\"https:\/\/github.com\/id774\/stdout\/blob\/master\/demo2.rb\">\u30c7\u30e2<\/a>\u3084<a href=\"https:\/\/github.com\/id774\/stdout\/blob\/master\/spec\/lib\/stdout\/output_spec.rb\">\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9<\/a>\u304c\u3042\u308b\u306e\u3067\u305d\u3061\u3089\u3092\u898b\u305f\u307b\u3046\u304c\u65e9\u3044\u3068\u306f\u601d\u3046\u304c\u3001\u65e5\u672c\u8a9e\u3067\u3082\u8aac\u660e\u3092\u66f8\u3044\u3066\u304a\u304f\u3002<\/p>\n<p><strong>\u8aac\u660e<\/strong><\/p>\n<p>\u305f\u3068\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u4e09\u56de\u51fa\u529b\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u3063\u305f\u3068\u3059\u308b\u3002<\/p>\n<div class=\"codecolorer-container text geshi\" style=\"overflow:auto;white-space:nowrap;width:1000px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/><\/div><\/td><td><div class=\"text codecolorer\" style=\"white-space:nowrap\">&nbsp; def some_method<br \/>\n&nbsp; &nbsp; puts &quot;\u51e6\u7406\u958b\u59cb&quot;<br \/>\n&nbsp; &nbsp; # \u306a\u3093\u304b\u3059\u308b<br \/>\n&nbsp; &nbsp; puts &quot;\u73fe\u5728\u51e6\u7406\u4e2d\u3067\u3059&quot;<br \/>\n&nbsp; &nbsp; # \u306a\u3093\u304b\u3059\u308b<br \/>\n&nbsp; &nbsp; puts &quot;\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\uff01&quot;<br \/>\n&nbsp; end<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u4e0a\u8a18\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30d6\u30ed\u30c3\u30af\u3067\u56f2\u3080\u3068 result \u306b\u683c\u7d0d\u3055\u308c\u308b\u623b\u308a\u5024\u304c\u6587\u5b57\u5217\u306e\u914d\u5217\u306b\u306a\u308b\u3002<\/p>\n<div class=\"codecolorer-container text geshi\" style=\"overflow:auto;white-space:nowrap;width:1000px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/><\/div><\/td><td><div class=\"text codecolorer\" style=\"white-space:nowrap\">require 'stdout'<br \/>\n<br \/>\nresult = Stdout::Output.capture {<br \/>\n&nbsp; some_method<br \/>\n}\u3000<br \/>\n<br \/>\np result # =&gt; [&quot;\u51e6\u7406\u958b\u59cb\\n&quot;, &quot;\u73fe\u5728\u51e6\u7406\u4e2d\u3067\u3059\\n&quot;, &quot;\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\uff01\\n&quot;]<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>\u3042\u3068\u306f\u53d6\u5f97\u3057\u305f\u914d\u5217\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5bfe\u3057\u3066\u30c6\u30b9\u30c8\u3092\u66f8\u3051\u3070\u826f\u3044\u3002\u7c21\u5358\u3067\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>puts \u3084 print \u306a\u3069\u306e\u6a19\u6e96\u51fa\u529b\u306b\u6587\u5b57\u5217\u3092\u51fa\u529b\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306f\u3061\u3087\u3063\u3068\u3057\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u898f\u6a21\u306e\u5927\u304d\u3044\u30d7\u30ed\u30c0\u30af\u30c8\u307e\u3067\u5e45\u5e83\u304f\u4f7f\u308f\u308c\u308b\u3002\u3053\u308c\u3089\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u51fa\u529b\u30e1\u30bd\u30c3\u30c9\u306f\u4f7f\u3046\u306e\u306f\u304a\u624b\u8efd\u3060\u304c\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u3092\u8003\u3048\u308b\u3068 &#8230; <a title=\"\u6a19\u6e96\u51fa\u529b\u3092\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u3064\u304f\u3063\u305f\" class=\"read-more\" href=\"https:\/\/harpuia.id774.net\/entry\/2013\/11\/11\/423\/\" aria-label=\"\u6a19\u6e96\u51fa\u529b\u3092\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u3064\u304f\u3063\u305f \u306b\u3064\u3044\u3066\u3055\u3089\u306b\u8aad\u3080\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-423","post","type-post","status-publish","format-standard","hentry","category-diary"],"_links":{"self":[{"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/posts\/423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/comments?post=423"}],"version-history":[{"count":0,"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/posts\/423\/revisions"}],"wp:attachment":[{"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/media?parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/categories?post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/harpuia.id774.net\/entry\/wp-json\/wp\/v2\/tags?post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}