Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

2014-05-01から1ヶ月間の記事一覧

Ruby | CLI | Be Helpful | Documenting Options

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Helpful 詳細 各フラグ、スイッチに1センテンスの短い要約を記述します。 端末で折り返さない程度の長さにします。(60文字以内)フラグが引数をとる場合は、短い単語で記述する。 (もし…

Ruby | CLI | Be Helpful | Documenting an App's Description and Invocation Syntax

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Helpful 詳細 ユーザーが最初に期待するのは1行の要約を記した banner を見ることです。 コマンドを持たないシンプルなアプリケーション 典型的なフォーマットは下記のようになります exe…

Ruby | CLI | Be Helpful | Writing Good Help Text and Documentation

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Helpful 詳細 ヘルプテキストや明確で、簡潔で、正確で、便利なドキュメントは重要。 ヘルプや、ドキュメントにはいくつかの決まりごとがある。1センテンスにまとめられた概要である bann…

Ruby | CLI | Be Helpful | Documenting a Command Suit

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Helpful 詳細 Command suit は各コマンドごとのドキュメントが必要になる。 これは2段階のヘルプシステムで提供する。まず、1段階目として command -h で、globalなオプション・コマンド…

Ruby | CLI | Be Helpful | Adding a Brief Description for a CLI Apps

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Helpful 詳細 CLIアプリケーションをどういった目的に利用するのか、ヘルプに含めること。例として ls コマンドの日本語ヘルプを見てみます。 $ ls --help 使用法: ls [オプション]... […

Ruby | CLI | Be Helpful | Documenting a Command-Line Arguments

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Helpful 詳細 引数の情報を OptionParser の bannar に追加してみます。 下記記事のサンプルをベースに設定を追加します。Ruby | CLI | Be Easy to Use | Ruby | CLI | Be Easy to Use | …

Ruby | CLI | Be Helpful | Documenting a Command-Line Interface

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Helpful 詳細 コマンドラインの経験のあるユーザーは、コマンドラインをどう使うか知るために 次のことを試します。彼らは引数なしでコマンドを実行するか、 help スイッチを呼び出す。(…

Ruby | Kernel | rand

概要 Kernel#rand(max = 0) -> Integer | Float Kernel#rand(range) -> Integer | Float | nil 詳細 擬似乱数を発生させる。・Kernel#rand(max = 0) max が 0 の場合は 0.0 以上 1.0 未満の実数を、正の整数の場合は 0 以上 max 未満の整数を返す。 それ以外…

TbpgrUtils | 追加要件 AttrEnumerable#at_attr 追加

概要 追加要件 AttrEnumerable#at_attr 追加 詳細 追加要件 AttrEnumerable#at_attr 仕様 ・規約により、クラス名をスネークケースにしたArrayのAttributesを持つこと ・Attributesの指定したindexのメンバ変数を取得する ※より詳細についてはGitHubのREADME…

JavaScript | カンマ演算子(Comma Operator)

概要 カンマ演算子(Comma Operator) 詳細 カンマ演算子(Comma Operator)は、カンマで区切られた値の2番目の要素を返却します。 主に単一の式でなければならない位置で複数の式を記述したい場合に、カンマ演算子を使う。頻出例:for ループ サンプルコード1 f…

Ruby | CLI | Be Easy to Use | Thorを利用した使いやすいCommand suitインターフェース

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Easy to Use 詳細 「OptionParserを利用した使いやすいCLIインターフェース(http://d.hatena.ne.jp/tbpg/20140526/1401109608)」で紹介したOptionParserは シンプルなCLIツールを作るには…

Ruby | CLI | Be Easy to Use | OptionParserを利用した使いやすいCLIインターフェース

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Easy to Use 詳細 ほとんどのCLIアプリケーションは慣習に従って作られている。 慣習に従っておけばユーザーにとって覚えるのが簡単なツールになる。 そこで、慣習に従ったCLIを作る助力…

Ruby | Kernel | raise

概要 Kernel#raise -> () Kernel#raise(message) -> () Kernel#raise(error_type, message = nil, backtrace = caller(0)) -> () 詳細 例外を発生させる。 発生した例外は変数 $! に格納される。 また例外が 発生した時のスタックトレースは変数 $@ に格納さ…

CodeIQ | 『第4回デスマコロシアム』問題 QA @tbpgr #CodeIQ

概要 『第4回デスマコロシアム』問題 QA 詳細 『第4回デスマコロシアム』問題 QAです。 Q1 Q 解答コードの文字数はどのように数えますか?A Byteではなく文字数で数えます。 具体的にはRubyのString#sizeメソッドで数えます。 (Ruby1.9以上。1.8以前のString…

CodeIQ | 『第4回デスマコロシアム』問題 集計報告 @tbpgr #CodeIQ

概要 『第4回デスマコロシアム』問題 詳細 『第4回デスマコロシアム』問題 の参加状況集計です。 https://codeiq.jp/ace/tbpgr_colosseum_manager/q915 残言語 挑戦者0名の言語は以下です。 Ada Assembler (gcc-4.8.1) bc C# C++ 4.3.2 C++ 4.8.1 CLIPS Cloj…

CodeIQ | 『第4回デスマコロシアム』問題 @tbpgr #CodeIQ

概要 『第4回デスマコロシアム』問題 詳細 『第4回デスマコロシアム』問題 の出題を2014年6月2日 AM8時からxx月xx日 AM10時まで行っています。 https://codeiq.jp/ace/tbpgr_colosseum_manager/q915 どんな問題? 簡単な問題に好きな言語(ideoneの範囲)で…

TbpgrUtils | 追加要件 AttrEnumerable#reverse_attr 追加

概要 追加要件 AttrEnumerable#reverse_attr 追加 詳細 追加要件 AttrEnumerable#reverse_attr 仕様 ・規約により、クラス名をスネークケースにしたArrayのAttributesを持つこと ・Attributesの任意のメンバ変数を逆順にした配列を返却する ※より詳細につい…

Ruby | Kernel | putc

概要 Kernel#putc(ch) -> object 詳細 文字 ch を 標準出力 $stdout に出力する。 ch が数値なら 0 〜 255 の範囲の対応する文字を出力する。 ch が文字列なら、その先頭 1byte を出力する。 どちらでもない場合は、ch.to_int で整数に変換する。 サンプルコ…

TbpgrUtils | 追加要件 AttrEnumerable#each_attr_with_index 追加

概要 追加要件 AttrEnumerable#each_attr_with_index 追加 詳細 追加要件 AttrEnumerable#each_attr_with_index 仕様 ・規約により、クラス名をスネークケースにしたArrayのAttributesを持つこと ・ArrayのAttributesの各クラスが持つAttributesへのイテレー…

Ruby | Kernel | printf

概要 Kernel#printf(format, *arg) -> nil[permalink][rdoc] Kernel#printf(port, format, *arg) -> nil 詳細 C 言語の printf と同じように、format に従い引数を文字列に変換して port に出力します。 port を省略した場合は標準出力 $stdout に出力します…

TbpgrUtils | 追加要件 AttrEnumerable#each_attr 追加

概要 追加要件 AttrEnumerable#each_attr 追加 詳細 追加要件 AttrEnumerable#each_attr 仕様 ・規約により、クラス名をスネークケースにしたArrayのAttributesを持つこと ・ArrayのAttributesの各クラスが持つAttributesへのイテレータを提供する ※より詳細…

Ruby | CLI | Be Easy to Use | CommandLineを理解する | Commands

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Easy to Use | CommandLineを理解する 詳細 CommandLineの構成要素を理解する | Commands Commands シンプルなコマンドラインアプリケーションは Options と Arguments だけで済む。 しか…

Ruby | CLI | Be Easy to Use | CommandLineを理解する | Arguments

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 CommandLineを理解する 詳細 Be Easy to Use | CommandLineの構成要素を理解する | Arguments Arguments Arguments はコマンドラインで扱う対象を表す。 典型的な例としては、ファイル名やデ…

Ruby | CLI | Be Easy to Use | CommandLineを理解する | Options

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 CommandLineを理解する 詳細 Be Easy to Use | CommandLineの構成要素を理解する | Options Options Optionsはユーザーがアプリケーションの動作を変えるための方法です。・Short-Form Short…

Ruby | CLI | Be Easy to Use | CommandLineを理解する

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Easy to Use | CommandLineを理解する 詳細 CommandLineの構成要素を理解する 基本構成 例えば ls コマンドで rb のファイルを更新日付の降順で詳細表示したい場合 ls -ltr *.rb のように…

Ruby | CLI | Be Easy to Use

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Be Easy to Use 詳細 自分のアプリケーションをインストール後、Userが初めに経験するのはCLIだろう。 CLIが難しく、直観的ではなく、醜くければ多くの信頼を得られないだろう。 逆に、もし…

Ruby | CLI | Have a Clear Concise Purpose | 素晴らしいCLI Appを作るには

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Have a Clear Concise Purposee | 素晴らしいCLI Appを作るには 素晴らしいCLI Appの特徴 ・Easy to user ・Helpful ・Plays well with others ・Has sensible defaults but is configurable…

Ruby | CLI | Have a Clear Concise Purpose | サブセットを持つコマンド

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Have a Clear Concise Purposee | サブセットを持つコマンド サブセットを持つコマンド例:仕様 ※書籍に載っていたものとは全く別のものです。 同じような内容を自分独自の仕様で考えました…

Ruby | CLI | Have a Clear Concise Purpose | 単一目的のシンプルなケースへの変更例

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Have a Clear Concise Purposee | 単一目的のシンプルなケースへの変更例 ツールの単純化例:仕様 ※書籍に載っていたものとは全く別のものです。 同じような内容を自分独自の仕様で考えまし…

Ruby | CLI | Have a Clear Concise Purpose

概要 書籍 Build Awesome Command-Line Applications in Ruby2 章 Have a Clear Concise Purpose 詳細 単一目的のコマンドラインアプリケーションが望ましい。 入力を受け取り、出力を提供する。驚くほどシンプルな手法。単一目的のツールは、覚えるのが簡単…