=encoding utf8 =head1 NAME =begin original Config::Pit - Manage settings =end original Config::Pit - 設定管理 =head1 SYNOPSIS =begin original use Config::Pit; my $config = pit_get("example.com", require => { "username" => "your username on example", "password" => "your password on example" }); # if the fields are not set, open setting by $EDITOR # with YAML-dumped default values (specified at C). # use $config->{username}, $config->{password} =end original use Config::Pit; my $config = pit_get("example.com", require => { "username" => "your username on example", "password" => "your password on example" }); # フィールドがセットされていなければ, デフォルト値(Cで指定)を # YAML形式にしたものが, $EDITORで開かれます. # use $config->{username}, $config->{password} =head1 DESCRIPTION =begin original Config::Pit is account setting management library. This library automates editing settings used in scripts. Original library is written in Ruby and published as pit gem with management command. You can install it by rubygems: $ sudo gem install pit $ pit set example.com # open setting of example.com with $EDITOR. And Config::Pit provides ppit command which is pit command written in Perl. See: $ ppit help =end original Config::Pitはアカウント設定を管理するライブラリです. このライブラリはスクリプト内で利用される設定の編集を自動化します. オリジナルのものは Rubyで記述され, 管理コマンド pitとして gem形式で公開されています. それは rubygemsからインストールができます. $ sudo gem install pit $ pit set example.com # open setting of example.com with $EDITOR. Config::Pitは pitコマンドを Perlで実装した ppitも提供しています. 参照: $ ppit help =head1 FUNCTIONS =begin original =head2 Config::Pit::get(setting_name, opts) Get setting named C from current profile. my $config = Config::Pit::get("example.com"); This is same as below: my $config = pit_get("example.com"); opts: =over =item B Specify fields you want as key and hint (description or default value) of the field as value. my $config = pit_get("example.com", require => { "username" => "your username on example.com", "password" => "your password on example.com" }); C specified, module check the required fields all exist in setting. If not exist, open the setting by $EDITOR with merged setting with current setting. =back =head2 Config::Pit::set(setting_name, opts) Set setting named C to current profile. Config::Pit::set("example.com"); #=> will open setting with $EDITOR opts: =over =item B Config::Pit::set("example.com", data => { username => "foobar", password => "barbaz", }); When C specified, will not open C<$EDITOR> and set the data directly. =item B Config::Pit::set("example.com", config => { username => "config description or default value", password => "same as above", }); Open C<$EDITOR> with merged setting with specified config. =back =head2 Config::Pit::switch(profile_name); Switch profile to C. Profile is setting set: $ pit get foobar # foo bar... $ pit switch devel Switch profile to devel $ pit get foobar # bar baz $ pit switch Switch profile to default $ pit get foobar # foo bar... =end original =head2 Config::Pit::get(setting_name, opts) Cという名前の設定を現在のプロファイルから取得する. my $config = Config::Pit::get("example.com"); 以下の場合も同様のことを行います. my $config = pit_get("example.com"); opts: =over =item B キーとして必要となるフィールドとフィールドの値のヒント(説明かデフォルト値)を指定します. my $config = pit_get("example.com", require => { "username" => "your username on example.com", "password" => "your password on example.com" }); Cが指定されたとき, モジュールは設定に必要となるフィールドがすべて存在するかを確認します.もしフィールドが存在しなければ, 指定した設定を $EDITORで開き, 現在の設定にマージします. =back =head2 Config::Pit::set(setting_name, opts) Cという名前の設定を, 現在のプロファイルにセットします. Config::Pit::set("example.com"); #=> $EDITORで設定が開かれます. opts: =over =item B Config::Pit::set("example.com", data => { username => "foobar", password => "barbaz", }); Cが指定されたとき, C<$EDITOR>を使わずに値を直接セットします. =item B Config::Pit::set("example.com", config => { username => "config description or default value", password => "same as above", }); 指定した設定を C<$EDITOR>で開き, 現在の設定にマージします. =back =head2 Config::Pit::switch(profile_name); Cにプロファイルを切り替えます. プロファイルは設定の集合です: $ pit get foobar # foo bar... $ pit switch devel プロファイルを develに切り替える. $ pit get foobar # bar baz $ pit switch プロファイルをデフォルトのものに切り替える. $ pit get foobar # foo bar... =head1 AUTHOR cho45 Echo45@lowreal.netE =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =begin original L is pit in Ruby. F is pit command in Perl. =end original Lは pitの Rubyによる実装です. Fは pitコマンドの Perlによる実装です. =cut