verkilo 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ # require 'fileutils'
2
+ require 'yaml'
3
+ module Verkilo
4
+ class Log
5
+ def initialize(type, root_dir)
6
+ @type = type
7
+ @root_dir = root_dir
8
+ @data = YAML.load(read_file)
9
+ @today = Time.now.strftime("%F")
10
+ end
11
+ def data=(h)
12
+ @data = @data.merge({@today => h})
13
+ end
14
+ def data
15
+ @data
16
+ end
17
+ def write
18
+ fname = self.filename
19
+ FileUtils.mkdir_p(File.dirname(fname))
20
+ f = File.open(fname,'w')
21
+ f.write(@data.to_yaml)
22
+ f.close
23
+ end
24
+ def filename
25
+ File.join([@root_dir, '.verkilo', "#{@type}.yml"])
26
+ end
27
+ private
28
+ def read_file
29
+ contents = "---"
30
+ if File.exist?(self.filename)
31
+ f = File.open(self.filename,'r')
32
+ contents = f.read()
33
+ f.close
34
+ end
35
+ return contents
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,32 @@
1
+ module Verkilo
2
+ class Shelf
3
+ def initialize(root_dir)
4
+ cmd = "basename -s .git `git config --get remote.origin.url`"
5
+ @repo = `#{cmd}`.strip || root_dir
6
+ @root_dir = root_dir
7
+ @books = []
8
+ @wordcount = Hash.new
9
+ end
10
+ def to_s
11
+ File.basename(@root_dir)
12
+ end
13
+ alias title to_s
14
+
15
+ def to_i
16
+ self.books.each do |b|
17
+ @wordcount[b.title] = b.to_i
18
+ end
19
+ return @wordcount
20
+ end
21
+ alias wordcount to_i
22
+
23
+ def books
24
+ return @books unless @books.empty?
25
+ @books = Dir["#{@root_dir}/**/.book"].map do |book_flag|
26
+ dir = File.dirname(book_flag)
27
+ title = File.basename(dir)
28
+ Book.new(title, dir, @repo)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Verkilo
2
+ VERSION = "0.1.2"
3
+ end
File without changes
@@ -0,0 +1,497 @@
1
+ % Options for packages loaded elsewhere
2
+ \PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
3
+ \PassOptionsToPackage{hyphens}{url}
4
+ $if(colorlinks)$
5
+ \PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}
6
+ $endif$
7
+ $if(dir)$
8
+ $if(latex-dir-rtl)$
9
+ \PassOptionsToPackage{RTLdocument}{bidi}
10
+ $endif$
11
+ $endif$
12
+ $if(CJKmainfont)$
13
+ \PassOptionsToPackage{space}{xeCJK}
14
+ $endif$
15
+ %
16
+ \documentclass[
17
+ $if(fontsize)$
18
+ $fontsize$,
19
+ $endif$
20
+ $if(lang)$
21
+ $babel-lang$,
22
+ $endif$
23
+ $if(papersize)$
24
+ $papersize$paper,
25
+ $endif$
26
+ $if(beamer)$
27
+ ignorenonframetext,
28
+ $if(handout)$
29
+ handout,
30
+ $endif$
31
+ $if(aspectratio)$
32
+ aspectratio=$aspectratio$,
33
+ $endif$
34
+ $endif$
35
+ $for(classoption)$
36
+ $classoption$$sep$,
37
+ $endfor$
38
+ ]{$documentclass$}
39
+ $if(beamer)$
40
+ $if(background-image)$
41
+ \usebackgroundtemplate{%
42
+ \includegraphics[width=\paperwidth]{$background-image$}%
43
+ }
44
+ $endif$
45
+ \usepackage{pgfpages}
46
+ \setbeamertemplate{caption}[numbered]
47
+ \setbeamertemplate{caption label separator}{: }
48
+ \setbeamercolor{caption name}{fg=normal text.fg}
49
+ \beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$
50
+ $for(beameroption)$
51
+ \setbeameroption{$beameroption$}
52
+ $endfor$
53
+ % Prevent slide breaks in the middle of a paragraph
54
+ \widowpenalties 1 10000
55
+ \raggedbottom
56
+ $if(section-titles)$
57
+ \setbeamertemplate{part page}{
58
+ \centering
59
+ \begin{beamercolorbox}[sep=16pt,center]{part title}
60
+ \usebeamerfont{part title}\insertpart\par
61
+ \end{beamercolorbox}
62
+ }
63
+ \setbeamertemplate{section page}{
64
+ \centering
65
+ \begin{beamercolorbox}[sep=12pt,center]{part title}
66
+ \usebeamerfont{section title}\insertsection\par
67
+ \end{beamercolorbox}
68
+ }
69
+ \setbeamertemplate{subsection page}{
70
+ \centering
71
+ \begin{beamercolorbox}[sep=8pt,center]{part title}
72
+ \usebeamerfont{subsection title}\insertsubsection\par
73
+ \end{beamercolorbox}
74
+ }
75
+ \AtBeginPart{
76
+ \frame{\partpage}
77
+ }
78
+ \AtBeginSection{
79
+ \ifbibliography
80
+ \else
81
+ \frame{\sectionpage}
82
+ \fi
83
+ }
84
+ \AtBeginSubsection{
85
+ \frame{\subsectionpage}
86
+ }
87
+ $endif$
88
+ $endif$
89
+ $if(beamerarticle)$
90
+ \usepackage{beamerarticle} % needs to be loaded first
91
+ $endif$
92
+ $if(fontfamily)$
93
+ \usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
94
+ $else$
95
+ \usepackage{lmodern}
96
+ $endif$
97
+ $if(linestretch)$
98
+ \usepackage{setspace}
99
+ $endif$
100
+ \usepackage{amssymb,amsmath}
101
+ \usepackage{ifxetex,ifluatex}
102
+ \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
103
+ \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}
104
+ \usepackage[utf8]{inputenc}
105
+ \usepackage{textcomp} % provide euro and other symbols
106
+ \else % if luatex or xetex
107
+ $if(mathspec)$
108
+ \ifxetex
109
+ \usepackage{mathspec}
110
+ \else
111
+ \usepackage{unicode-math}
112
+ \fi
113
+ $else$
114
+ \usepackage{unicode-math}
115
+ $endif$
116
+ \defaultfontfeatures{Scale=MatchLowercase}
117
+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
118
+ $if(mainfont)$
119
+ \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}
120
+ $endif$
121
+ $if(sansfont)$
122
+ \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}
123
+ $endif$
124
+ $if(monofont)$
125
+ \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$}
126
+ $endif$
127
+ $for(fontfamilies)$
128
+ \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}
129
+ $endfor$
130
+ $if(mathfont)$
131
+ $if(mathspec)$
132
+ \ifxetex
133
+ \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
134
+ \else
135
+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
136
+ \fi
137
+ $else$
138
+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}
139
+ $endif$
140
+ $endif$
141
+ $if(CJKmainfont)$
142
+ \ifxetex
143
+ \usepackage{xeCJK}
144
+ \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
145
+ \fi
146
+ $endif$
147
+ $if(luatexjapresetoptions)$
148
+ \ifluatex
149
+ \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}
150
+ \fi
151
+ $endif$
152
+ $if(CJKmainfont)$
153
+ \ifluatex
154
+ \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}
155
+ \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}
156
+ \fi
157
+ $endif$
158
+ \fi
159
+ $if(beamer)$
160
+ $if(theme)$
161
+ \usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}
162
+ $endif$
163
+ $if(colortheme)$
164
+ \usecolortheme{$colortheme$}
165
+ $endif$
166
+ $if(fonttheme)$
167
+ \usefonttheme{$fonttheme$}
168
+ $endif$
169
+ $if(mainfont)$
170
+ \usefonttheme{serif} % use mainfont rather than sansfont for slide text
171
+ $endif$
172
+ $if(innertheme)$
173
+ \useinnertheme{$innertheme$}
174
+ $endif$
175
+ $if(outertheme)$
176
+ \useoutertheme{$outertheme$}
177
+ $endif$
178
+ $endif$
179
+ % Use upquote if available, for straight quotes in verbatim environments
180
+ \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
181
+ \IfFileExists{microtype.sty}{% use microtype if available
182
+ \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}
183
+ \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
184
+ }{}
185
+ $if(indent)$
186
+ $else$
187
+ \makeatletter
188
+ \@ifundefined{KOMAClassName}{% if non-KOMA class
189
+ \IfFileExists{parskip.sty}{%
190
+ \usepackage{parskip}
191
+ }{% else
192
+ \setlength{\parindent}{0pt}
193
+ \setlength{\parskip}{6pt plus 2pt minus 1pt}}
194
+ }{% if KOMA class
195
+ \KOMAoptions{parskip=half}}
196
+ \makeatother
197
+ $endif$
198
+ $if(verbatim-in-note)$
199
+ \usepackage{fancyvrb}
200
+ $endif$
201
+ \usepackage{xcolor}
202
+ \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
203
+ \IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
204
+ \hypersetup{
205
+ $if(title-meta)$
206
+ pdftitle={$title-meta$},
207
+ $endif$
208
+ $if(author-meta)$
209
+ pdfauthor={$author-meta$},
210
+ $endif$
211
+ $if(lang)$
212
+ pdflang={$lang$},
213
+ $endif$
214
+ $if(subject)$
215
+ pdfsubject={$subject$},
216
+ $endif$
217
+ $if(keywords)$
218
+ pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},
219
+ $endif$
220
+ $if(colorlinks)$
221
+ colorlinks=true,
222
+ linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,
223
+ filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$,
224
+ citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
225
+ urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
226
+ $else$
227
+ hidelinks,
228
+ $endif$
229
+ pdfcreator={LaTeX via pandoc}}
230
+ \urlstyle{same} % disable monospaced font for URLs
231
+ $if(verbatim-in-note)$
232
+ \VerbatimFootnotes % allow verbatim text in footnotes
233
+ $endif$
234
+ $if(geometry)$
235
+ $if(beamer)$
236
+ \geometry{$for(geometry)$$geometry$$sep$,$endfor$}
237
+ $else$
238
+ \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
239
+ $endif$
240
+ $endif$
241
+ $if(beamer)$
242
+ \newif\ifbibliography
243
+ $endif$
244
+ $if(listings)$
245
+ \usepackage{listings}
246
+ \newcommand{\passthrough}[1]{#1}
247
+ \lstset{defaultdialect=[5.3]Lua}
248
+ \lstset{defaultdialect=[x86masm]Assembler}
249
+ $endif$
250
+ $if(lhs)$
251
+ \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
252
+ $endif$
253
+ $if(highlighting-macros)$
254
+ $highlighting-macros$
255
+ $endif$
256
+ $if(tables)$
257
+ \usepackage{longtable,booktabs}
258
+ $if(beamer)$
259
+ \usepackage{caption}
260
+ % Make caption package work with longtable
261
+ \makeatletter
262
+ \def\fnum@table{\tablename~\thetable}
263
+ \makeatother
264
+ $else$
265
+ % Correct order of tables after \paragraph or \subparagraph
266
+ \usepackage{etoolbox}
267
+ \makeatletter
268
+ \patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
269
+ \makeatother
270
+ % Allow footnotes in longtable head/foot
271
+ \IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
272
+ \makesavenoteenv{longtable}
273
+ $endif$
274
+ $endif$
275
+ $if(graphics)$
276
+ \usepackage{graphicx}
277
+ \makeatletter
278
+ \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
279
+ \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
280
+ \makeatother
281
+ % Scale images if necessary, so that they will not overflow the page
282
+ % margins by default, and it is still possible to overwrite the defaults
283
+ % using explicit options in \includegraphics[width, height, ...]{}
284
+ \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
285
+ % Set default figure placement to htbp
286
+ \makeatletter
287
+ \def\fps@figure{htbp}
288
+ \makeatother
289
+ $endif$
290
+ $if(links-as-notes)$
291
+ % Make links footnotes instead of hotlinks:
292
+ \DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}
293
+ $endif$
294
+ $if(strikeout)$
295
+ \usepackage[normalem]{ulem}
296
+ % Avoid problems with \sout in headers with hyperref
297
+ \pdfstringdefDisableCommands{\renewcommand{\sout}{}}
298
+ $endif$
299
+ \setlength{\emergencystretch}{3em} % prevent overfull lines
300
+ \providecommand{\tightlist}{%
301
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
302
+ $if(numbersections)$
303
+ \setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}
304
+ $else$
305
+ \setcounter{secnumdepth}{-\maxdimen} % remove section numbering
306
+ $endif$
307
+ $if(beamer)$
308
+ $else$
309
+ $if(block-headings)$
310
+ % Make \paragraph and \subparagraph free-standing
311
+ \ifx\paragraph\undefined\else
312
+ \let\oldparagraph\paragraph
313
+ \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
314
+ \fi
315
+ \ifx\subparagraph\undefined\else
316
+ \let\oldsubparagraph\subparagraph
317
+ \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
318
+ \fi
319
+ $endif$
320
+ $endif$
321
+ $if(pagestyle)$
322
+ \pagestyle{$pagestyle$}
323
+ $endif$
324
+ $for(header-includes)$
325
+ $header-includes$
326
+ $endfor$
327
+ $if(lang)$
328
+ \ifxetex
329
+ % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
330
+ \usepackage{polyglossia}
331
+ \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
332
+ $for(polyglossia-otherlangs)$
333
+ \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
334
+ $endfor$
335
+ \else
336
+ \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
337
+ $if(babel-newcommands)$
338
+ $babel-newcommands$
339
+ $endif$
340
+ \fi
341
+ $endif$
342
+ $if(dir)$
343
+ \ifxetex
344
+ % Load bidi as late as possible as it modifies e.g. graphicx
345
+ \usepackage{bidi}
346
+ \fi
347
+ \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
348
+ \TeXXeTstate=1
349
+ \newcommand{\RL}[1]{\beginR #1\endR}
350
+ \newcommand{\LR}[1]{\beginL #1\endL}
351
+ \newenvironment{RTL}{\beginR}{\endR}
352
+ \newenvironment{LTR}{\beginL}{\endL}
353
+ \fi
354
+ $endif$
355
+ $if(natbib)$
356
+ \usepackage[$natbiboptions$]{natbib}
357
+ \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
358
+ $endif$
359
+ $if(biblatex)$
360
+ \usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}
361
+ $for(bibliography)$
362
+ \addbibresource{$bibliography$}
363
+ $endfor$
364
+ $endif$
365
+ $if(csl-refs)$
366
+ \newlength{\cslhangindent}
367
+ \setlength{\cslhangindent}{1.5em}
368
+ \newenvironment{cslreferences}%
369
+ {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}%
370
+ \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}%
371
+ {\par}
372
+ $endif$
373
+
374
+ $if(title)$
375
+ \title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
376
+ $endif$
377
+ $if(subtitle)$
378
+ $if(beamer)$
379
+ $else$
380
+ \usepackage{etoolbox}
381
+ \makeatletter
382
+ \providecommand{\subtitle}[1]{% add subtitle to \maketitle
383
+ \apptocmd{\@title}{\par {\large #1 \par}}{}{}
384
+ }
385
+ \makeatother
386
+ $endif$
387
+ \subtitle{$subtitle$}
388
+ $endif$
389
+ \author{$for(author)$$author$$sep$ \and $endfor$}
390
+ \date{$date$}
391
+ $if(beamer)$
392
+ $if(institute)$
393
+ \institute{$for(institute)$$institute$$sep$ \and $endfor$}
394
+ $endif$
395
+ $if(titlegraphic)$
396
+ \titlegraphic{\includegraphics{$titlegraphic$}}
397
+ $endif$
398
+ $if(logo)$
399
+ \logo{\includegraphics{$logo$}}
400
+ $endif$
401
+ $endif$
402
+
403
+ \begin{document}
404
+ $if(has-frontmatter)$
405
+ \frontmatter
406
+ $endif$
407
+ $if(title)$
408
+ $if(beamer)$
409
+ \frame{\titlepage}
410
+ $else$
411
+ \maketitle
412
+ $endif$
413
+ $if(abstract)$
414
+ \begin{abstract}
415
+ $abstract$
416
+ \end{abstract}
417
+ $endif$
418
+ $endif$
419
+
420
+ $for(include-before)$
421
+ $include-before$
422
+
423
+ $endfor$
424
+ $if(toc)$
425
+ $if(toc-title)$
426
+ \renewcommand*\contentsname{$toc-title$}
427
+ $endif$
428
+ $if(beamer)$
429
+ \begin{frame}[allowframebreaks]
430
+ $if(toc-title)$
431
+ \frametitle{$toc-title$}
432
+ $endif$
433
+ \tableofcontents[hideallsubsections]
434
+ \end{frame}
435
+ $else$
436
+ {
437
+ $if(colorlinks)$
438
+ \hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}
439
+ $endif$
440
+ \setcounter{tocdepth}{$toc-depth$}
441
+ \tableofcontents
442
+ }
443
+ $endif$
444
+ $endif$
445
+ $if(lot)$
446
+ \listoftables
447
+ $endif$
448
+ $if(lof)$
449
+ \listoffigures
450
+ $endif$
451
+ $if(linestretch)$
452
+ \setstretch{$linestretch$}
453
+ $endif$
454
+ $if(has-frontmatter)$
455
+ \mainmatter
456
+ $endif$
457
+ $body$
458
+
459
+ $if(has-frontmatter)$
460
+ \backmatter
461
+ $endif$
462
+ $if(natbib)$
463
+ $if(bibliography)$
464
+ $if(biblio-title)$
465
+ $if(has-chapters)$
466
+ \renewcommand\bibname{$biblio-title$}
467
+ $else$
468
+ \renewcommand\refname{$biblio-title$}
469
+ $endif$
470
+ $endif$
471
+ $if(beamer)$
472
+ \begin{frame}[allowframebreaks]{$biblio-title$}
473
+ \bibliographytrue
474
+ $endif$
475
+ \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}
476
+ $if(beamer)$
477
+ \end{frame}
478
+ $endif$
479
+
480
+ $endif$
481
+ $endif$
482
+ $if(biblatex)$
483
+ $if(beamer)$
484
+ \begin{frame}[allowframebreaks]{$biblio-title$}
485
+ \bibliographytrue
486
+ \printbibliography[heading=none]
487
+ \end{frame}
488
+ $else$
489
+ \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
490
+ $endif$
491
+
492
+ $endif$
493
+ $for(include-after)$
494
+ $include-after$
495
+
496
+ $endfor$
497
+ \end{document}