| 1 | package App::Standup::Diary; | ||
| 2 | |||
| 3 | 2 | ▶ | use v5.28; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 0 | ▶ | use Config::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 6 | use Object::Pad; | ||
| 7 | use Path::Tiny; | ||
| 8 | |||
| 9 | use App::Standup::Role::Project; | ||
| 10 | use App::Standup::Role::Date; | ||
| 11 | use App::Standup::Diary::Template; | ||
| 12 | |||
| 13 | our $VERSION = '0.08'; | ||
| 14 | |||
| 15 | class App::Standup::Diary :does( Date ) :does( Project ) { | ||
| 16 | |||
| 17 | no warnings 'experimental'; | ||
| 18 | |||
| 19 | field $config :accessor :param { Config::Tiny->read('diary.conf') }; | ||
| 20 | |||
| 21 | field $daily_data_path :accessor; | ||
| 22 | |||
| 23 | field $data_dir :param :reader; | ||
| 24 | |||
| 25 | field $template :writer :accessor; | ||
| 26 | |||
| 27 | method init_daily_data_path ($path) { | ||
| 28 | $daily_data_path = $data_dir ? | ||
| 29 | path( $data_dir . '/' . $path ) : | ||
| 30 | path( $config->{data}->{path} . '/' . $path ); | ||
| 31 | } | ||
| 32 | |||
| 33 | method write { | ||
| 34 | |||
| 35 | $self->set_template( App::Standup::Diary::Template->new( | ||
| 36 | date => $self->date, | ||
| 37 | project_name => $self->project_name | ||
| 38 | )); | ||
| 39 | |||
| 40 | if ( $self->should_create_dir ) { | ||
| 41 | say "$daily_data_path should be created"; | ||
| 42 | $self->create_directories_tree; | ||
| 43 | } else { | ||
| 44 | $self->init_daily_data_path($self->build_path($self->date->ymd('/'))); | ||
| 45 | } | ||
| 46 | |||
| 47 | my $file_path = path($self->build_full_file_path); | ||
| 48 | |||
| 49 | path($file_path)->spew_utf8($template->render) and say "Diary entry created $file_path" | ||
| 50 | unless $file_path->exists and say "Entry already exist"; | ||
| 51 | |||
| 52 | } | ||
| 53 | |||
| 54 | # TODO should have a App::Standup::Diary::Path object for those | ||
| 55 | method build_full_file_path { | ||
| 56 | return $daily_data_path . | ||
| 57 | '/' . | ||
| 58 | $self->date->ymd . | ||
| 59 | '_' . | ||
| 60 | lc $self->project_name . | ||
| 61 | '.md'; | ||
| 62 | } | ||
| 63 | |||
| 64 | method build_path ($date) { | ||
| 65 | my ($path) = $date =~ m/ \d{4} \/ \d{2} /gx ; | ||
| 66 | return $path; | ||
| 67 | } | ||
| 68 | |||
| 69 | method should_create_dir { | ||
| 70 | $self->init_daily_data_path($self->build_path($self->date->ymd('/'))); | ||
| 71 | return $daily_data_path->exists ? 0 : 1; | ||
| 72 | } | ||
| 73 | |||
| 74 | method create_directories_tree { | ||
| 75 | |||
| 76 | # Unimplemented, see #29 | ||
| 77 | if ($self->date->day_of_month == 1 ) { | ||
| 78 | # TODO if first day of the month | ||
| 79 | # Create a Priorities file | ||
| 80 | } | ||
| 81 | |||
| 82 | my @created = $daily_data_path->mkpath; | ||
| 83 | say "Created $daily_data_path" if @created; | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | =encoding utf8 | ||
| 88 | |||
| 89 | =head1 NAME | ||
| 90 | |||
| 91 | App::Standup::Diary - Manage a simple Markdown journal for your daily standups | ||
| 92 | |||
| 93 | =head1 SYNOPSIS | ||
| 94 | |||
| 95 | # From command line | ||
| 96 | diary --data-dir /home/smonff/diary/ --project-name SeriousWork | ||
| 97 | |||
| 98 | # In your Perl code | ||
| 99 | my $diary = App::Standup::Diary | ||
| 100 | ->new( | ||
| 101 | data_dir => $data_dir, | ||
| 102 | project_name => $project_name | ||
| 103 | ); | ||
| 104 | |||
| 105 | $diary->write(); | ||
| 106 | |||
| 107 | |||
| 108 | =head1 DESCRIPTION | ||
| 109 | |||
| 110 | This module is the implementation of the L<diary> command, that can help to keep | ||
| 111 | a directory of organized daily notes aimed at standup preparation and | ||
| 112 | presentation. | ||
| 113 | |||
| 114 | It provides a couple of ways to customize the notes template. | ||
| 115 | |||
| 116 | It use internal tools built with CPAN modules: | ||
| 117 | |||
| 118 | =over 2 | ||
| 119 | |||
| 120 | =item L<App::Standup::Diary::Template> | ||
| 121 | |||
| 122 | The Markdown template where your data are interpolated. | ||
| 123 | |||
| 124 | =item L<Standup::Role::Date> | ||
| 125 | |||
| 126 | Provide date features for all the C<diary> uses. | ||
| 127 | |||
| 128 | =item L<Standup::Role::Project> | ||
| 129 | |||
| 130 | Provide a project name, so far. | ||
| 131 | |||
| 132 | =back | ||
| 133 | |||
| 134 | =head1 MOTIVATIONS | ||
| 135 | |||
| 136 | Daily standups are a common, tried and tested modern work methodology. They are | ||
| 137 | I<"brief, daily collaboration meeting in which the team review progress from the | ||
| 138 | previous day, declares intentions for the current day, and highlights any | ||
| 139 | obstacles encountered or anticipated"> (L<source|brief, daily collaboration | ||
| 140 | meeting in which the team review progress from the previous day, declares | ||
| 141 | intentions for the current day, and highlights any obstacles encountered or | ||
| 142 | anticipated.>). | ||
| 143 | |||
| 144 | This tool is supposed to provide self-support for persons: | ||
| 145 | |||
| 146 | =over 2 | ||
| 147 | |||
| 148 | =item Who struggle with daily standups presentations oral expression | ||
| 149 | |||
| 150 | =item Surely familiar with the Perl ecosystem | ||
| 151 | |||
| 152 | =back | ||
| 153 | |||
| 154 | =head2 How did it start? | ||
| 155 | |||
| 156 | Social anxiety can make my standup presentation very confusing. I also tend to | ||
| 157 | forget key points if improvising, due to the stress of having no talk notes | ||
| 158 | support. Keeping a diary of my thoughts drastically helped me to stay calm and | ||
| 159 | collaborate better with the various teams I worked with. And if they are well | ||
| 160 | sorted by year, month and day, it makes very easy to find old notes for eventual | ||
| 161 | later usage. | ||
| 162 | |||
| 163 | =head2 Ready for production | ||
| 164 | |||
| 165 | I have been using it at work since 2021 and it helped me to reduce the stress of | ||
| 166 | standups and meeting. | ||
| 167 | |||
| 168 | =head2 Methodology | ||
| 169 | |||
| 170 | Every morning, create the daily file by running C<diary>. It's template is a | ||
| 171 | simple 3 items list. Open the day file in C<$data_dir/$year/$month/> and stash | ||
| 172 | your thoughts by using the following methodology: | ||
| 173 | |||
| 174 | =over 2 | ||
| 175 | |||
| 176 | =item C<done> | ||
| 177 | |||
| 178 | List of tasks you accomplished in the previous day | ||
| 179 | |||
| 180 | =item C<todo> | ||
| 181 | |||
| 182 | List of tasks you plan to accomplish today | ||
| 183 | |||
| 184 | =item C<blockers> | ||
| 185 | |||
| 186 | List of eventual blockers, so that your colleagues can support you | ||
| 187 | |||
| 188 | =back | ||
| 189 | |||
| 190 | Then just read the notes during the daily standup. | ||
| 191 | |||
| 192 | =head2 Experiment with Object::Pad | ||
| 193 | |||
| 194 | L<App::Standup::Diary> is my pet project for Perl's Corinna implementation of the | ||
| 195 | core OOP features. C<diary> use L<Object::Pad>, not the C<class> feature | ||
| 196 | introduced in Perl C<5.40>. L<Object::Pad> is the test bed for the new core OO | ||
| 197 | system. | ||
| 198 | |||
| 199 | =head1 INSTALLATION | ||
| 200 | |||
| 201 | =head2 For common usage | ||
| 202 | |||
| 203 | cpanm App::Standup::Diary | ||
| 204 | |||
| 205 | It will make the C<diary> command available in the C<~/perl5/bin/> directory. | ||
| 206 | Should be available in your C<PATH>. | ||
| 207 | |||
| 208 | See L<diary> for command line usage. | ||
| 209 | |||
| 210 | =head2 For development | ||
| 211 | |||
| 212 | # Install a Perl module manager | ||
| 213 | apt install carton | ||
| 214 | |||
| 215 | git clone git@codeberg.org:smonff/Diary.git | ||
| 216 | |||
| 217 | cd Diary | ||
| 218 | |||
| 219 | # Install CPAN dependencies | ||
| 220 | carton install | ||
| 221 | |||
| 222 | =head1 How to use it? | ||
| 223 | |||
| 224 | I set an alias in my C<.bashrc>. Should also work in your own-favorite-shell: | ||
| 225 | |||
| 226 | alias diary="diary --data-dir /home/smonff/diary --project-name SeriousWork"; | ||
| 227 | |||
| 228 | Each morning, before my work standup, I run C<diary>. It create a Markdown file | ||
| 229 | in the specified C<--project-name> directory. I then edit my thoughts with an | ||
| 230 | editor. | ||
| 231 | |||
| 232 | See L<diary> for command line usage. | ||
| 233 | |||
| 234 | =head1 FIELDS | ||
| 235 | |||
| 236 | =head2 config | ||
| 237 | |||
| 238 | =head2 daily_data_path | ||
| 239 | |||
| 240 | =head2 data_dir | ||
| 241 | |||
| 242 | =head2 template | ||
| 243 | |||
| 244 | A L<App::Standup::Diary::Template> object. | ||
| 245 | |||
| 246 | =head1 METHODS | ||
| 247 | |||
| 248 | =head2 build_full_file_path() | ||
| 249 | |||
| 250 | =head2 build_path($self->date->ymd('/')) | ||
| 251 | |||
| 252 | Use the date from C<Standup::Role::Date> to build the final path file name. | ||
| 253 | |||
| 254 | =head2 create_directories_tree() | ||
| 255 | |||
| 256 | If C<$self->should_create_dir()> returns a true value, it would take care of the | ||
| 257 | directory creation using L<Path::Tiny> C<mkpath>. | ||
| 258 | |||
| 259 | =head2 init_daily_data_path($file_path) | ||
| 260 | |||
| 261 | Helper that initialize C<$daily_data_path> with a C<Path::Tiny> instance | ||
| 262 | for the current day diary entry. | ||
| 263 | |||
| 264 | # foo/2022/03 (Path::Tiny) | ||
| 265 | $self->init_daily_data_path($self->build_path) | ||
| 266 | |||
| 267 | =head2 should_create_dir() | ||
| 268 | |||
| 269 | Check if a new I<year> or I<month> directory should be created so that we can | ||
| 270 | store the standup file. In simpler words: are we the first day of the year, or | ||
| 271 | of the month? | ||
| 272 | |||
| 273 | =head2 write() | ||
| 274 | |||
| 275 | This is C<App::Standup::Diary> entry point, AKA C<main()>. | ||
| 276 | |||
| 277 | =head1 TODOs | ||
| 278 | |||
| 279 | =over 2 | ||
| 280 | |||
| 281 | =item Make the template configurable by setting it in a separate file | ||
| 282 | |||
| 283 | =item Retrieve TODOS from previous days | ||
| 284 | |||
| 285 | =back | ||
| 286 | |||
| 287 | See the L<issues tracker|https://codeberg.org/smonff/Standup-Diary/issues>. | ||
| 288 | |||
| 289 | =head1 SEE ALSO | ||
| 290 | |||
| 291 | A couple of similar tools: | ||
| 292 | |||
| 293 | =over 2 | ||
| 294 | |||
| 295 | =item L<StandupGenerator|https://metacpan.org/release/JTREEVES/StandupGenerator-0.5/source/README.md> | ||
| 296 | |||
| 297 | On the CPAN, this is pretty much all what I found. I like the spirit of this | ||
| 298 | one. | ||
| 299 | |||
| 300 | =item L<Almanac|https://codeberg.org/jameschip/almanac> | ||
| 301 | |||
| 302 | A similar effort written in Bash. | ||
| 303 | |||
| 304 | =back | ||
| 305 | |||
| 306 | =head1 ACKNOWLEDGEMENTS | ||
| 307 | |||
| 308 | Thanks to the maintainers of L<Config::Tiny>, L<Mojo::Template>, L<Object::Pad>, | ||
| 309 | L<Path::Tiny>, L<Time::Piece>. | ||
| 310 | |||
| 311 | =head1 LICENSE | ||
| 312 | |||
| 313 | Copyright 2022-2024 Sebastien Feugère | ||
| 314 | |||
| 315 | This library is free software; you can redistribute it and/or modify it under | ||
| 316 | the Artistic License 2.0. | ||
| 317 | |||
| 318 | See L<perlartistic>. | ||
| 319 | |||
| 320 | =head1 AUTHOR | ||
| 321 | |||
| 322 | Sébastien Feugère - seb@feugere.net | ||
| 323 | |||
| 324 | =cut | ||