Changeset 4243
- Timestamp:
- 01/09/08 03:42:45 (5 years ago)
- Location:
- lang/perl/Config-Pit/trunk
- Files:
-
- 2 modified
-
lib/Config/Pit.pm (modified) (2 diffs)
-
t/01_basic.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Config-Pit/trunk/lib/Config/Pit.pm
r4227 r4243 72 72 $YAML::Syck::SingleQuote = 1; 73 73 74 $name ||= "default"; 75 74 76 $profile_file = File::Spec->catfile($directory, "$name.yaml"); 75 77 76 78 my $config = _config(); 79 my $ret = $config->{profile}; 77 80 $config->{profile} = $name; 78 81 YAML::Syck::DumpFile($config_file, $config); 82 return $ret; 79 83 } 80 84 … … 164 168 =back 165 169 170 =item Config::Pit::set(setting_name, opts) 171 172 Set setting named C<setting_name> to current profile. 173 174 Config::Pit::set("twitter.com"); #=> will open setting with $EDITOR 175 176 opts: 177 178 =over 179 180 =item data 181 182 Config::Pit::set("twitter.com", data => { 183 username => "foobar", 184 password => "barbaz", 185 }); 186 187 When C<data> specified, will not open C<$EDITOR> and set the data directly. 188 189 =over 190 191 =item config 192 193 194 Config::Pit::set("twitter.com", config => { 195 username => "config description or default value", 196 password => "same as above", 197 }); 198 199 Open C<$EDITOR> with merged setting with specified config. 200 201 =back 202 203 =item Config::Pit::switch(profile_name); 204 205 Switch profile to C<profile_name>. 206 207 Profile is setting set: 208 209 $ pit get foobar 210 # foo bar... 211 212 $ pit switch devel 213 Switch profile to devel 214 215 $ pit get foobar 216 # bar baz 217 218 $ pit switch 219 Switch profile to default 220 221 $ pit get foobar 222 # foo bar... 223 224 =back 225 166 226 =back 167 227 -
lang/perl/Config-Pit/trunk/t/01_basic.t
r4238 r4243 2 2 use warnings; 3 3 4 use Test::More tests => 1 1;4 use Test::More tests => 17; 5 5 use File::Temp; 6 6 use Path::Class; … … 15 15 $Config::Pit::directory = dir($dir->dirname); 16 16 17 my $config;17 my ($config, $p); 18 18 19 19 $config = Config::Pit::get("test"); … … 36 36 is($config->{bar}, "baz", "get returned value (exported sub)"); 37 37 38 $p = Config::Pit::switch("profile"); 39 is($p, "default", "switch profile"); 40 $config = pit_get("test"); 41 is($config->{foo}, undef, "switch profile get value"); 42 is($config->{bar}, undef, "switch profile get value"); 43 44 $p = Config::Pit::switch(); 45 is($p, "profile", "switch profile"); 46 $config = pit_get("test"); 47 is($config->{foo}, "bar", "switch profile get value"); 48 is($config->{bar}, "baz", "switch profile get value"); 38 49 39 50 # EDITOR
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)