{"action":"created","issue":{"url":"https://api.github.com/repos/rurema/doctree/issues/433","repository_url":"https://api.github.com/repos/rurema/doctree","labels_url":"https://api.github.com/repos/rurema/doctree/issues/433/labels{/name}","comments_url":"https://api.github.com/repos/rurema/doctree/issues/433/comments","events_url":"https://api.github.com/repos/rurema/doctree/issues/433/events","html_url":"https://github.com/rurema/doctree/issues/433","id":243746892,"number":433,"title":"コピペ可能なサンプルコードを整備する","user":{"login":"tbpgr","id":4787509,"avatar_url":"https://avatars3.githubusercontent.com/u/4787509?v=4","gravatar_id":"","url":"https://api.github.com/users/tbpgr","html_url":"https://github.com/tbpgr","followers_url":"https://api.github.com/users/tbpgr/followers","following_url":"https://api.github.com/users/tbpgr/following{/other_user}","gists_url":"https://api.github.com/users/tbpgr/gists{/gist_id}","starred_url":"https://api.github.com/users/tbpgr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbpgr/subscriptions","organizations_url":"https://api.github.com/users/tbpgr/orgs","repos_url":"https://api.github.com/users/tbpgr/repos","events_url":"https://api.github.com/users/tbpgr/events{/privacy}","received_events_url":"https://api.github.com/users/tbpgr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":111,"created_at":"2017-07-18T14:59:05Z","updated_at":"2018-05-05T18:02:53Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## 貢献希望者\r\n貢献希望者はruremaの活動に関する情報共有をするesaにおいでください 🐾 \r\n下記の招待URLから参加できます。\r\n\r\nhttps://rurema.esa.io/\r\n\r\nhttps://rurema.esa.io/team/invitations/member-003dab4dfc293b59bcdf01a2627024e6\r\n\r\n## 組み込みクラスサンプル追加対象リスト\r\n自分が担当するクラスのヨコに名前を書いてください。\r\n優先度の高いものから作りたい場合は、以下のアクセス解析結果で上位のものから\r\nはじめるとよいです。\r\n\r\n* [Analytics-201709.xlsx](https://files.gitter.im/rurema-dev/Lobby/k27A/Analytics-_________________-_____-20170901-20170930.xlsx)\r\n* [Analytics-201710.xlsx](https://github.com/rurema/doctree/files/1475074/Analytics-20171031.xlsx)\r\n* [Analytics-20171130.xlsx](https://github.com/rurema/doctree/files/1535503/Analytics-20171130.xlsx)\r\n* [Analytics-20171231.xlsx](https://github.com/rurema/doctree/files/1619156/Analytics-20171231.xlsx)\r\n* [SearchAnalytics-20171231.xlsx](https://github.com/rurema/doctree/files/1619158/SearchAnalytics-20171231.xlsx)\r\n\r\n- [ ] [ARGF](https://docs.ruby-lang.org/ja/latest/class/ARGF=2eclass.html)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆[Array](https://docs.ruby-lang.org/ja/latest/class/Array.html)\r\n    - 🐙 [yklitter](https://github.com/yklitter)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆[:tv: tbpgr](https://github.com/tbpgr) - [BasicObject](https://docs.ruby-lang.org/ja/latest/class/BasicObject.html)\r\n- [ ] [Class](https://docs.ruby-lang.org/ja/latest/class/Class.html)\r\n    - [:computer: ysksn](https://github.com/ysksn)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆[:computer: ysksn](https://github.com/ysksn) - [Comparable](https://docs.ruby-lang.org/ja/latest/class/Comparable.html)\r\n- [x] 🏆⭐️ [swamp09](https://github.com/swamp09) - [Complex](https://docs.ruby-lang.org/ja/latest/class/Complex.html)\r\n- [x] 🏆[dir](https://docs.ruby-lang.org/ja/latest/class/Dir.html)    \r\n    - [:computer: ysksn](https://github.com/ysksn) \r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [ ] [encoding=3a=3aConverter](https://docs.ruby-lang.org/ja/latest/class/Encoding=3a=3aConverter.html)\r\n- [ ] [encoding=3a=3aInvalidbytesequenceerror](https://docs.ruby-lang.org/ja/latest/class/Encoding=3a=3aInvalidByteSequenceError.html)\r\n- [ ] [encoding=3a=3aUndefinedconversionerror](https://docs.ruby-lang.org/ja/latest/class/Encoding=3a=3aUndefinedConversionError.html)\r\n- [ ] [encoding](https://docs.ruby-lang.org/ja/latest/class/Encoding.html)\r\n- [x] 🏆  [:tv: tbpgr](https://github.com/tbpgr) - [enumerable](https://docs.ruby-lang.org/ja/latest/class/Enumerable.html)\r\n- [x] 🏆 [:tv: tbpgr](https://github.com/tbpgr) - [enumerator=3a=3aLazy](https://docs.ruby-lang.org/ja/latest/class/Enumerator=3a=3aLazy.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [exception](https://docs.ruby-lang.org/ja/latest/class/Exception.html)\r\n- [x] 🏆⭐️ [swamp09](https://github.com/swamp09) - [falseclass](https://docs.ruby-lang.org/ja/latest/class/FalseClass.html)\r\n- [ ] 💃 [unasuke](https://github.com/unasuke) [ENV](https://docs.ruby-lang.org/ja/latest/class/ENV.html)\r\n- [x] 🏆 [file](https://docs.ruby-lang.org/ja/latest/class/File.html)\r\n    - 🆓 [tzmfreedom](https://github.com/tzmfreedom)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆 [filetest](https://docs.ruby-lang.org/ja/latest/class/FileTest.html)\r\n    - 🆓 [tzmfreedom](https://github.com/tzmfreedom)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆⭐️ [swamp09](https://github.com/swamp09) - [float](https://docs.ruby-lang.org/ja/latest/class/Float.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [gc=3a=3aProfiler](https://docs.ruby-lang.org/ja/latest/class/GC=3a=3aProfiler.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [gc](https://docs.ruby-lang.org/ja/latest/class/GC.html)\r\n- [x] 🏆[:tv: tbpgr](https://github.com/tbpgr) - [hash](https://docs.ruby-lang.org/ja/latest/class/Hash.html)\r\n- [ ] [integer](https://docs.ruby-lang.org/ja/latest/class/Integer.html)\r\n    - ⭐️ [swamp09](https://github.com/swamp09)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [ ] [io](https://docs.ruby-lang.org/ja/latest/class/IO.html)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆 [kernel](https://docs.ruby-lang.org/ja/latest/class/Kernel.html)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n    - 👓  [sho-h](https://github.com/sho-h)\r\n- [ ] 🐙 [yklitter](https://github.com/yklitter) - [matchdata](https://docs.ruby-lang.org/ja/latest/class/MatchData.html)\r\n- [ ] [math](https://docs.ruby-lang.org/ja/latest/class/Math.html)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [ ] [method](https://docs.ruby-lang.org/ja/latest/class/Method.html)\r\n    - 🆓 [tzmfreedom](https://github.com/tzmfreedom)\r\n- [ ] [module](https://docs.ruby-lang.org/ja/latest/class/Module.html)\r\n    - 🆓 [tzmfreedom](https://github.com/tzmfreedom)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆🌊  [u5surf](https://github.com/u5surf) - [nameerror](https://docs.ruby-lang.org/ja/latest/class/NameError.html)\r\n- [x] 🏆 🌊  [u5surf](https://github.com/u5surf) - [nilclass](https://docs.ruby-lang.org/ja/latest/class/NilClass.html)\r\n- [x] 🏆⭐️ [swamp09](https://github.com/swamp09) - [numeric](https://docs.ruby-lang.org/ja/latest/class/Numeric.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [object](https://docs.ruby-lang.org/ja/latest/class/Object.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [objectspace=3a=3aWeakmap](https://docs.ruby-lang.org/ja/latest/class/ObjectSpace=3a=3aWeakMap.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [objectspace](https://docs.ruby-lang.org/ja/latest/class/ObjectSpace.html)\r\n- [x] 🏆[:tv: tbpgr](https://github.com/tbpgr) - [proc](https://docs.ruby-lang.org/ja/latest/class/Proc.html)\r\n- [ ] [process=3a=3aStatus](https://docs.ruby-lang.org/ja/latest/class/Process=3a=3aStatus.html)\r\n- [ ] [process=3a=3aSys](https://docs.ruby-lang.org/ja/latest/class/Process=3a=3aSys.html)\r\n- [ ] [process](https://docs.ruby-lang.org/ja/latest/class/Process.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [random](https://docs.ruby-lang.org/ja/latest/class/Random.html)\r\n- [x] 🏆 [:computer: ysksn](https://github.com/ysksn) - [range](https://docs.ruby-lang.org/ja/latest/class/Range.html)\r\n- [x] 🏆☕️ [hisas](https://github.com/hisas) - [rational](https://docs.ruby-lang.org/ja/latest/class/Rational.html)\r\n- [x] 🏆 [:tv: tbpgr](https://github.com/tbpgr) - [regexp](https://docs.ruby-lang.org/ja/latest/class/Regexp.html)\r\n- [ ] [:tv: tbpgr](https://github.com/tbpgr) - [rubyvm=3a=3aInstructionsequence](https://docs.ruby-lang.org/ja/latest/class/RubyVM=3a=3aInstructionSequence.html)\r\n- [ ] [signalexception](https://docs.ruby-lang.org/ja/latest/class/SignalException.html)\r\n    - 🌊  [u5surf](https://github.com/u5surf) \r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [x] 🏆  [:tv: tbpgr](https://github.com/tbpgr) - [string](https://docs.ruby-lang.org/ja/latest/class/String.html)\r\n- [x] 🏆 [:tv: tbpgr](https://github.com/tbpgr) - [struct](https://docs.ruby-lang.org/ja/latest/class/Struct.html)\r\n- [x] 🏆⭐️ [swamp09](https://github.com/swamp09) - [symbol](https://docs.ruby-lang.org/ja/latest/class/Symbol.html)\r\n- [ ] [thread=3a=3aBacktrace=3a=3aLocation](https://docs.ruby-lang.org/ja/latest/class/Thread=3a=3aBacktrace=3a=3aLocation.html)\r\n- [ ] [thread=3a=3aConditionvariable](https://docs.ruby-lang.org/ja/latest/class/Thread=3a=3aConditionVariable.html)\r\n- [ ] [thread=3a=3aMutex](https://docs.ruby-lang.org/ja/latest/class/Thread=3a=3aMutex.html)\r\n- [ ] [thread=3a=3aQueue](https://docs.ruby-lang.org/ja/latest/class/Thread=3a=3aQueue.html)\r\n- [ ] [thread=3a=3aSizedqueue](https://docs.ruby-lang.org/ja/latest/class/Thread=3a=3aSizedQueue.html)\r\n- [ ] ⭐️ [swamp09](https://github.com/swamp09) - [thread](https://docs.ruby-lang.org/ja/latest/class/Thread.html)\r\n- [ ] [threadgroup](https://docs.ruby-lang.org/ja/latest/class/ThreadGroup.html)\r\n- [x] 🏆 [time](https://docs.ruby-lang.org/ja/latest/class/Time.html)    \r\n    - [katsumata-ryo](https://github.com/katsumata-ryo)\r\n    - [m-nakamura145](https://github.com/m-nakamura145)\r\n    - [igaiga](https://github.com/igaiga)\r\n    - [moguno](https://github.com/moguno)\r\n    - :computer: [ysksn](https://github.com/ysksn)\r\n    - [jinco13](https://github.com/jinco13)\r\n    - [Watson1978](https://github.com/Watson1978)\r\n    - [:tv: tbpgr](https://github.com/tbpgr)\r\n- [ ] [tracepoint](https://docs.ruby-lang.org/ja/latest/class/TracePoint.html)\r\n- [x] 🏆[:computer: ysksn](https://github.com/ysksn) - [trueclass](https://docs.ruby-lang.org/ja/latest/class/TrueClass.html)\r\n- [ ] ⭐️ [swamp09](https://github.com/swamp09) - [unboundmethod](https://docs.ruby-lang.org/ja/latest/class/UnboundMethod.html)\r\n- [x] 🏆[:tv: tbpgr](https://github.com/tbpgr) - [uncaughtthrowerror](https://docs.ruby-lang.org/ja/latest/class/UncaughtThrowError.html)\r\n- [x] 🏆 [:tv: tbpgr](https://github.com/tbpgr) - [main](https://docs.ruby-lang.org/ja/latest/class/main.html)\r\n\r\n## 背景\r\n結城先生から、Twitterで以下のような指摘がありました。\r\n\r\n>Rubyのドキュメントは、  \r\n>「そのままコピペして動く典型的なコードを最初に見せてほしい」  \r\n>という点だけが要望。requireが抜けてたり、そもそも典型的コード例がなかったり、\r\n\r\nなお、以下の関連ツイートの流れ上「るりま」に対する指摘であることを確認済みです。  \r\n(ruby-doc ではない、という意味)\r\n\r\n>RubyでSecureRandomを使いたいと思い、Googleで\"SecureRandom Ruby\"を検索しました。  \r\n>一番上に来るのは Ruby 2.4.0 の module SecureRandom のページでした  \r\n>そこに書かれた例を試してみると動きません。require 'securerandom' を追加したら動きました  。  \r\n>例には書かれてないけど「SecureRandomを使うには require 'securerandom'を書く」は当然の知識>なのかしら。\r\n\r\n※なお、上記のIssueは修正済(ありがとうございます)\r\n\r\n### 関連ツイート\r\n* https://twitter.com/hyuki/status/885435631802777601\r\n* https://twitter.com/hyuki/status/885713894819250176\r\n* https://twitter.com/hyuki/status/840915566374223872\r\n\r\n## 前提\r\n結城先生がいうところの\r\n\r\n「そのままコピペして動く典型的なコード」\r\n\r\nというのは SSCCE に近いものではないか、と考えています。  \r\n\r\n>Short (Small) - Minimise bandwidth for the example, do not bore the audience.  \r\n>Self Contained - Ensure everything is included, ready to go.  \r\n>Correct - Copy, paste, (compile,) see is the aim.  \r\n>Example - Displays the problem we are trying to solve.  \r\n\r\nhttp://sscce.org/ より\r\n\r\n以降、 SSCCE として表記します。\r\n\r\n### なぜ SSCCE が大切か？\r\nSSCCE は StackOverflow などでプログラムの例を示す際の好ましい形式を明文化したものですが、  \r\nその利点はプログラムのリファレンスに付属するサンプルに関しても適用されそうです。\r\n\r\n* 誰でも同じコードをコピペするだけで動かして確認できる\r\n* 最小の手間で対象を理解できる\r\n\r\n仮にこれらの恩恵が無かった場合は\r\n\r\n* コピペして動かない部分に関して各自が予測して理解する必要がある\r\n* 理解に手間がかかる\r\n\r\nということになります。\r\n\r\n## 現状\r\n現状、るりまのドキュメントにおいて各メソッドに対するサンプルコードは  \r\n以下のような状態のいずれかになっています。\r\n\r\n* サンプルがあり、SSCCEになっている\r\n* サンプルがあり、SSCCEになっていない\r\n* サンプルがない\r\n\r\n### 例\r\n#### サンプルがあり、SSCCEになっていない\r\n* [instance method CGI#header (Ruby 2.4.0)](https://docs.ruby-lang.org/ja/latest/method/CGI/i/header.html)\r\n\r\n```ruby\r\nheader\r\n  # Content-Type: text/html\r\n\r\nheader(\"text/plain\")\r\n  # Content-Type: text/plain\r\n\r\nheader({\"nph\"        => true,\r\n        \"status\"     => \"OK\",  # == \"200 OK\"\r\n          # \"status\"     => \"200 GOOD\",\r\n        \"server\"     => ENV['SERVER_SOFTWARE'],\r\n        \"connection\" => \"close\",\r\n        \"type\"       => \"text/html\",\r\n        \"charset\"    => \"iso-2022-jp\",\r\n          # Content-Type: text/html; charset=iso-2022-jp\r\n        \"language\"   => \"ja\",\r\n        \"expires\"    => Time.now + 30,\r\n        \"cookie\"     => [cookie1, cookie2],\r\n        \"my_header1\" => \"my_value\"\r\n        \"my_header2\" => \"my_value\"})\r\n```\r\n\r\n* `\"my_header1\" => \"my_value\"` の行末に半角カンマがない\r\n* require \"cgi\" がない\r\n* header を実際に使う場合は cgi のインスタンスが必要だが省略してある\r\n* cookie1, cookie2 が未宣言\r\n\r\n#### サンプルがない\r\n* [singleton method CGI.accept_charset (Ruby 2.4.0)](https://docs.ruby-lang.org/ja/latest/method/CGI/s/accept_charset.html)\r\n\r\n* サンプルを作るとしたら\r\n```ruby\r\nrequire \"cgi\"\r\nCGI.accept_charset # => UTF-8\r\nCGI.accept_charset=(\"ascii-8bit\")\r\nCGI.accept_charset # => ascii-8bit\r\n```\r\n\r\n## 議題\r\n* サンプルが SSCCE になっていないものを SSCCE にする？\r\n* サンプルがないものに SSCCE なサンプルを追加する？\r\n* 対象はすべてなのか、何か基準をもうけたうえで一部に適用するのか？\r\n\r\n## その他 懸念点\r\n* どの Version を対象とするか？\r\n\r\n## 意思表明\r\n実際に着手するとしたら以下のような手順になると思っています。\r\n\r\n1. 対応が必要かどうか判断するためドキュメント化されている全メソッドのリストを作る\r\n1. 1のリストに対してサンプル記載状況をまとめていく\r\n    * SSCCEになっている\r\n    * SSCCEになっていない\r\n    * サンプルがない\r\n1. メソッドに付属するサンプルコードを記載ガイドライン（SSCCE的なもの）を wiki にまとめる\r\n    * 今後の運用の基準にする\r\n1. リストアップ結果の量に応じて協力者を集う\r\n1. 協力者と手分けしてSSCCEを仕上げていく\r\n    * 個別に Pull Request をしていく\r\n\r\n2の作業は自動化できると嬉しいですが、おそらく手動（人の目で判断）になると思っています。  \r\n5の作業についても同様です。\r\n\r\n実際に対応するという意思決定をした場合、\r\n上記の全体に関して手を動かす気持ちがあります。"},"comment":{"url":"https://api.github.com/repos/rurema/doctree/issues/comments/386824130","html_url":"https://github.com/rurema/doctree/issues/433#issuecomment-386824130","issue_url":"https://api.github.com/repos/rurema/doctree/issues/433","id":386824130,"user":{"login":"tbpgr","id":4787509,"avatar_url":"https://avatars3.githubusercontent.com/u/4787509?v=4","gravatar_id":"","url":"https://api.github.com/users/tbpgr","html_url":"https://github.com/tbpgr","followers_url":"https://api.github.com/users/tbpgr/followers","following_url":"https://api.github.com/users/tbpgr/following{/other_user}","gists_url":"https://api.github.com/users/tbpgr/gists{/gist_id}","starred_url":"https://api.github.com/users/tbpgr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbpgr/subscriptions","organizations_url":"https://api.github.com/users/tbpgr/orgs","repos_url":"https://api.github.com/users/tbpgr/repos","events_url":"https://api.github.com/users/tbpgr/events{/privacy}","received_events_url":"https://api.github.com/users/tbpgr/received_events","type":"User","site_admin":false},"created_at":"2018-05-05T18:02:53Z","updated_at":"2018-05-05T18:02:53Z","author_association":"CONTRIBUTOR","body":"`RubyVM::InstructionSequence` 終了。 `ThreadGroup` をやります"}}
{"actor":{"display_login":"tbpgr"}}