{"id":62537,"date":"2018-08-17T08:01:17","date_gmt":"2018-08-16T23:01:17","guid":{"rendered":"https:\/\/www.softantenna.com\/wp\/?p=62537"},"modified":"2018-08-17T08:01:17","modified_gmt":"2018-08-16T23:01:17","slug":"rb","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/rb\/","title":{"rendered":"rb - Ruby\u3092\u4e07\u80fd\u30c4\u30fc\u30eb\u306b\u5909\u63db\u3067\u304d\u308b10\u884c\u306e\u30b9\u30af\u30ea\u30d7\u30c8"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2018\/08\/s_20180816_173158.jpg\" alt=\"S 20180816 173158\" title=\"s_20180816_173158.jpg\" border=\"0\" width=\"817\" height=\"540\" \/><\/p>\n<p>\u65e5\u672c\u751f\u307e\u308c\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u300cRuby\u300d\u3002<\/p>\n<p>Rails\u3092\u304d\u3063\u304b\u3051\u306bWeb\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u5206\u91ce\u3067\u5927\u304d\u306a\u4eba\u6c17\u3092\u96c6\u3081\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u4ed6\u306b\u3082\u30b7\u30b9\u30c6\u30e0\u7ba1\u7406\u3084\u30c6\u30ad\u30b9\u30c8\u51e6\u7406\u7528\u306e\u8a00\u8a9e\u3068\u3057\u3066\u3082\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u672c\u65e5\u7d39\u4ecb\u3059\u308b\u300c<a href=\"https:\/\/github.com\/thisredone\/rb\">rb<\/a>\u300d\u306f\u305d\u306e\u3088\u3046\u306a\u7528\u9014\u306b\u4fbf\u5229\u306a\u3001Ruby\u3092\u4ed6\u306eUNIX\u30b3\u30de\u30f3\u30c9\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u969b\u306b\u52b9\u679c\u3092\u767a\u63ee\u3059\u308b\u308f\u305a\u304b10\u884c\u3067\u69cb\u6210\u3055\u308c\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<\/p>\n<p>\u6a19\u6e96\u5165\u529b\u304b\u3089\u53d7\u3051\u53d6\u3063\u305f\u60c5\u5831\u3092\u3001Ruby\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3057\u3066\u52a0\u5de5\u3057\u3001\u6a19\u6e96\u51fa\u529b\u306b\u66f8\u304d\u51fa\u3059\u3053\u3068\u304c\u53ef\u80fd\u3067\u3001\u4eca\u307e\u3067awk\u3084sed\u306a\u3069\u3055\u307e\u3056\u307e\u306a\u30c4\u30fc\u30eb\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u51e6\u7406\u3092\u7c21\u6f54\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>rb\u306e\u4f7f\u7528\u65b9\u6cd5<\/h2>\n<p>rb\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u306b\u3088\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>sudo curl https:\/\/raw.githubusercontent.com\/thisredone\/rb\/master\/rb -o \/usr\/local\/bin\/rb && sudo chmod +x \/usr\/local\/bin\/rb\n<\/pre>\n<p>\u5358\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u5b9f\u884c\u30d3\u30c3\u30c8\u3092\u7acb\u3066\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5834\u6240\u3092\/usr\/local\/bin\u4ee5\u5916\u306b\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u3001\u624b\u52d5\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30b3\u30d4\u30fc\u3059\u308c\u3070\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>rb\u306f\u57fa\u672c\u7684\u306b\u6a19\u6e96\u5165\u529b\u304b\u3089\u8aad\u307f\u8fbc\u3093\u3060\u60c5\u5831\u3092\u914d\u5217\u3068\u3057\u3066\u51e6\u7406\u3057\u307e\u3059\u304c\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u300c-l\u300d\u3092\u6307\u5b9a\u3057\u305f\u30b7\u30f3\u30b0\u30eb\u30e9\u30a4\u30f3\u30e2\u30fc\u30c9\u3067\u306f\u3001\u6a19\u6e96\u5165\u529b\u306e\u5404\u884c\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u300cls -l\u300d\u306e\u51fa\u529b\u3092\u52a0\u5de5\u3059\u308b\u5834\u5408\u3092\u8003\u3048\u307e\u3059\u3002\u305d\u306e\u307e\u307e\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>$ ls -l\ntotal 16\ndrwxr-xr-x  3 sora  staff  102  8 14 22:18 cgi-bin\/\n-rw-r--r--  1 sora  staff  512  8 14 22:33 index.html\n-rw-r--r--  1 sora  staff  542  8 14 22:22 test.html<\/pre>\n<p>\u5148\u982d\u306e\u300ctotal\u300d\u884c\u3092\u524a\u9664\u3057\u305f\u3044\u5834\u5408\u3001\u300cdrop 1\u300d\u3092\u6307\u5b9a\u3057\u3066\u914d\u5217\u306e\u5148\u982d\u8981\u7d20\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<pre>$ ls -l | rb drop 1\ndrwxr-xr-x  3 sora  staff  102  8 14 22:18 cgi-bin\/\n-rw-r--r--  1 sora  staff  512  8 14 22:33 index.html\n-rw-r--r--  1 sora  staff  542  8 14 22:22 test.html\n<\/pre>\n<p>\u3055\u3089\u306b\u3053\u306e\u5404\u884c\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u540d\u3060\u3051\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u3001\u30b7\u30f3\u30b0\u30eb\u30e9\u30a4\u30f3\u30e2\u30fc\u30c9\u3067split\u3057\u3001\u6700\u5f8c\u306e\u8981\u7d20\u3092\u53d6\u5f97\u3059\u308c\u3070\u826f\u3044\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>$ ls -l | rb drop 1 | rb -l \"split[-1]\"\ncgi-bin\/\nindex.html\ntest.html\n<\/pre>\n<p>\u306a\u305c\u3053\u3046\u306a\u308b\u306e\u3001Ruby\u958b\u767a\u8005\u306e\u65b9\u306a\u3089\u3070\u30b9\u30af\u30ea\u30d7\u30c8\u672c\u4f53\u3092\u89e3\u8aad\u3057\u3066\u307f\u308b\u306e\u3092\u304a\u3059\u3059\u3081\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"ruby\">#!\/usr\/bin\/env ruby\n\ndef execute(_, code)\n  puts _.instance_eval(&code)\nrescue Errno::EPIPE\n  exit\nend\n\nsingle_line = ARGV[0] == '-l'\nexpr = ARGV.drop(single_line ? 1 : 0).join(' ')\ncode = eval(\"Proc.new { #{expr} }\")\nsingle_line ? STDIN.each { |l| execute(l.chomp, code) } : execute(STDIN.readlines, code)<\/code><\/pre>\n<p>\u30b7\u30f3\u30b0\u30eb\u30e9\u30a4\u30f3\u30e2\u30fc\u30c9\u306e\u5834\u5408\u6a19\u6e96\u5165\u529b\u306e\u5404\u884c\u306e\u6587\u5b57\u5217\u306b\u5bfe\u3057\u3066\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u3001\u305d\u308c\u4ee5\u5916\u306e\u901a\u5e38\u30e2\u30fc\u30c9\u306e\u5834\u5408\u3001\u8aad\u307f\u8fbc\u3093\u3060\u6a19\u6e96\u5165\u529b\u5168\u4f53\u304c\u914d\u5217\u306b\u683c\u7d0d\u3055\u308c\u30b3\u30fc\u30c9\u304c\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>rb\u3092\u5229\u7528\u3059\u308c\u3070\u6a19\u6e96\u5165\u529b\u304b\u3089\u53d7\u3051\u53d6\u3063\u305f\u60c5\u5831\u3092\u52a0\u5de5\u3057\u3066\u3001\u6a19\u6e96\u51fa\u529b\u306b\u66f8\u304d\u51fa\u3059\u3001\u3044\u308f\u3086\u308b\u30d5\u30a3\u30eb\u30bf\u7684\u306a\u51e6\u7406\u3092\u7c21\u5358\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002Ruby\u3092\u666e\u6bb5\u304b\u3089\u4f7f\u7528\u3057\u3066\u3044\u308b\u65b9\u306f\u3061\u3087\u3063\u3068\u3057\u305f\u51e6\u7406\u304c\u4fbf\u5229\u306b\u3067\u304d\u306a\u3044\u304b\u8a66\u3057\u3066\u307f\u3066\u306f\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65e5\u672c\u751f\u307e\u308c\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u300cRuby\u300d\u3002 Rails\u3092\u304d\u3063\u304b\u3051\u306bWeb\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306e\u5206\u91ce\u3067\u5927\u304d\u306a\u4eba\u6c17\u3092\u96c6\u3081\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u4ed6\u306b\u3082\u30b7\u30b9\u30c6\u30e0\u7ba1\u7406\u3084\u30c6\u30ad\u30b9\u30c8\u51e6\u7406\u7528\u306e\u8a00\u8a9e\u3068\u3057\u3066\u3082\u5e83\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002 \u672c\u65e5\u7d39\u4ecb\u3059\u308b\u300crb\u300d\u306f\u305d\u306e [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":62539,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[3459],"tags":[154],"class_list":["post-62537","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-review","tag-ruby"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/62537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=62537"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/62537\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/62539"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=62537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=62537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=62537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}