labrat 0.1.14 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6d7ea2a07a4077450d70eea18beb9472f830866841e7c62f85cf917a61a6d82
4
- data.tar.gz: 666cf99f5016218342cc7a9e8eed616f8b2cec00ced9b4b76753d3fff05602f8
3
+ metadata.gz: 33cfd23bc08f69e0f9147329ae77a91de45458ec613431c258608fc00a175e26
4
+ data.tar.gz: 92a47e9f6eb8e4f807591664ac1188a59856e000c5c0018bca901fb72ac08253
5
5
  SHA512:
6
- metadata.gz: 37705fd50acbadd2c6b68b6a91b6004b11b74763fc9f26cdd9baef29112e62d2075dd80ade5eb72ff7e36b32f96d415b610ef55f3faeb6084a299cb114cf566f
7
- data.tar.gz: dde4ca8c27e70cffc3988fc09ecded937fc8f9c6ebdb9a783b663ae68b0ab110d0c28e017737051f2c32d1a2c01526063265661bf0df67f144a22dee2edb2bf4
6
+ metadata.gz: e4e6e36bbc4d26531f5358f71f2e2ad43b10b67e692c9be1f7d5cd0a07f5a8ca9f02a714cd594e91bfe8703f84f68c37aa32f15765a861452a03ab6820675a1f
7
+ data.tar.gz: d43a0befaf67f7365d9aa7b049a555c4dacf75d2c7d5f0755047fd4adb828cb7c2781a0822d86b439ab35c34c1a9f4d7cf163545b9a1c028687dfb3c65bec360
data/.gitignore CHANGED
@@ -15,3 +15,6 @@
15
15
  label.pdf
16
16
  labrat.pdf
17
17
  /vendor-templates/
18
+ /README.pdf
19
+ /README.pyg
20
+ /README.tex
data/.rubocop.yml CHANGED
@@ -1,18 +1,2 @@
1
- inherit_gem:
2
- rubocop-shopify: rubocop.yml
3
-
4
- # require:
5
- # - rubocop-rspec
6
- # - rubocop-performance
7
-
8
- AllCops:
9
- TargetRubyVersion: 2.7
10
-
11
- Style/StringLiteralsInInterpolation:
12
- Enabled: true
13
-
14
- Layout/LineLength:
15
- Max: 120
16
-
17
- Style/MethodCallWithArgsParentheses:
18
- Enabled: false
1
+ inherit_from:
2
+ - ~/.rubocop.yml
data/.simplecov ADDED
@@ -0,0 +1,18 @@
1
+ # -*- mode: ruby -*-
2
+
3
+ SimpleCov.start do
4
+ # any custom configs like groups and filters can be here at a central place
5
+ add_filter '/spec/'
6
+ add_filter '/tmp/'
7
+ add_group "Models", "lib/labrat"
8
+ # add_group "Core Extension", "lib/ext"
9
+ # After this many seconds between runs, old coverage stats are thrown out,
10
+ # so 3600 => 1 hour
11
+ merge_timeout 3600
12
+ # Make this true to merge rspec and cucumber coverage together
13
+ use_merging false
14
+ command_name 'Rspec'
15
+ nocov_token 'no_cover'
16
+ # Branch coverage
17
+ enable_coverage :branch
18
+ end
data/Gemfile.lock CHANGED
@@ -1,17 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- labrat (0.1.13)
4
+ labrat (1.2.0)
5
5
  activesupport
6
6
  fat_core
7
7
  matrix
8
- methodize
9
8
  prawn (~> 2.0)
10
9
 
11
10
  GEM
12
11
  remote: https://rubygems.org/
13
12
  specs:
14
- activesupport (6.1.4.1)
13
+ activesupport (6.1.7)
15
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
16
15
  i18n (>= 1.6, < 2)
17
16
  minitest (>= 5.1)
@@ -19,78 +18,85 @@ GEM
19
18
  zeitwerk (~> 2.3)
20
19
  ast (2.4.2)
21
20
  coderay (1.1.3)
22
- concurrent-ruby (1.1.9)
21
+ concurrent-ruby (1.1.10)
23
22
  damerau-levenshtein (1.3.3)
24
- debug (1.4.0)
25
- irb (>= 1.3.6)
26
- reline (>= 0.2.7)
27
- diff-lcs (1.4.4)
28
- fat_core (4.9.2)
29
- activesupport
23
+ debug (1.7.1)
24
+ irb (>= 1.5.0)
25
+ reline (>= 0.3.1)
26
+ diff-lcs (1.5.0)
27
+ docile (1.4.0)
28
+ fat_core (4.13.0)
29
+ activesupport (~> 6.0)
30
30
  damerau-levenshtein
31
- i18n (1.8.11)
31
+ i18n (1.12.0)
32
32
  concurrent-ruby (~> 1.0)
33
- io-console (0.5.11)
34
- irb (1.4.1)
33
+ io-console (0.6.0)
34
+ irb (1.6.2)
35
35
  reline (>= 0.3.0)
36
+ json (2.6.3)
36
37
  matrix (0.4.2)
37
38
  method_source (1.0.0)
38
- methodize (0.3.1)
39
- minitest (5.14.4)
40
- parallel (1.20.1)
41
- parser (3.0.2.0)
39
+ minitest (5.17.0)
40
+ parallel (1.22.1)
41
+ parser (3.2.0.0)
42
42
  ast (~> 2.4.1)
43
43
  pdf-core (0.9.0)
44
44
  prawn (2.4.0)
45
45
  pdf-core (~> 0.9.0)
46
46
  ttfunk (~> 1.7)
47
- pry (0.13.1)
47
+ pry (0.14.1)
48
48
  coderay (~> 1.1)
49
49
  method_source (~> 1.0)
50
- rainbow (3.0.0)
50
+ rainbow (3.1.1)
51
51
  rake (13.0.6)
52
- regexp_parser (2.1.1)
53
- reline (0.3.1)
52
+ regexp_parser (2.6.1)
53
+ reline (0.3.2)
54
54
  io-console (~> 0.5)
55
55
  rexml (3.2.5)
56
- rspec (3.10.0)
57
- rspec-core (~> 3.10.0)
58
- rspec-expectations (~> 3.10.0)
59
- rspec-mocks (~> 3.10.0)
60
- rspec-core (3.10.1)
61
- rspec-support (~> 3.10.0)
62
- rspec-expectations (3.10.1)
56
+ rspec (3.12.0)
57
+ rspec-core (~> 3.12.0)
58
+ rspec-expectations (~> 3.12.0)
59
+ rspec-mocks (~> 3.12.0)
60
+ rspec-core (3.12.0)
61
+ rspec-support (~> 3.12.0)
62
+ rspec-expectations (3.12.1)
63
63
  diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.10.0)
65
- rspec-mocks (3.10.2)
64
+ rspec-support (~> 3.12.0)
65
+ rspec-mocks (3.12.1)
66
66
  diff-lcs (>= 1.2.0, < 2.0)
67
- rspec-support (~> 3.10.0)
68
- rspec-support (3.10.2)
69
- rubocop (1.18.4)
67
+ rspec-support (~> 3.12.0)
68
+ rspec-support (3.12.0)
69
+ rubocop (1.42.0)
70
+ json (~> 2.3)
70
71
  parallel (~> 1.10)
71
- parser (>= 3.0.0.0)
72
+ parser (>= 3.1.2.1)
72
73
  rainbow (>= 2.2.2, < 4.0)
73
74
  regexp_parser (>= 1.8, < 3.0)
74
- rexml
75
- rubocop-ast (>= 1.8.0, < 2.0)
75
+ rexml (>= 3.2.5, < 4.0)
76
+ rubocop-ast (>= 1.24.1, < 2.0)
76
77
  ruby-progressbar (~> 1.7)
77
78
  unicode-display_width (>= 1.4.0, < 3.0)
78
- rubocop-ast (1.8.0)
79
- parser (>= 3.0.1.1)
80
- rubocop-performance (1.11.5)
79
+ rubocop-ast (1.24.1)
80
+ parser (>= 3.1.1.0)
81
+ rubocop-performance (1.15.2)
81
82
  rubocop (>= 1.7.0, < 2.0)
82
83
  rubocop-ast (>= 0.4.0)
83
- rubocop-rspec (2.4.0)
84
- rubocop (~> 1.0)
85
- rubocop-ast (>= 1.1.0)
86
- rubocop-shopify (2.2.0)
87
- rubocop (~> 1.18)
84
+ rubocop-rspec (2.16.0)
85
+ rubocop (~> 1.33)
86
+ rubocop-shopify (2.11.1)
87
+ rubocop (~> 1.42)
88
88
  ruby-progressbar (1.11.0)
89
+ simplecov (0.22.0)
90
+ docile (~> 1.1)
91
+ simplecov-html (~> 0.11)
92
+ simplecov_json_formatter (~> 0.1)
93
+ simplecov-html (0.12.3)
94
+ simplecov_json_formatter (0.1.4)
89
95
  ttfunk (1.7.0)
90
- tzinfo (2.0.4)
96
+ tzinfo (2.0.5)
91
97
  concurrent-ruby (~> 1.0)
92
- unicode-display_width (2.0.0)
93
- zeitwerk (2.5.1)
98
+ unicode-display_width (2.4.2)
99
+ zeitwerk (2.6.6)
94
100
 
95
101
  PLATFORMS
96
102
  x86_64-linux
@@ -98,13 +104,14 @@ PLATFORMS
98
104
  DEPENDENCIES
99
105
  debug (>= 1.0.0)
100
106
  labrat!
101
- pry (~> 0.13.0)
107
+ pry
102
108
  rake (~> 13.0)
103
109
  rspec (~> 3.0)
104
110
  rubocop (~> 1.7)
105
111
  rubocop-performance
106
112
  rubocop-rspec
107
113
  rubocop-shopify
114
+ simplecov
108
115
 
109
116
  BUNDLED WITH
110
117
  2.3.4
data/Notes.org ADDED
@@ -0,0 +1,17 @@
1
+ * Lprint
2
+
3
+ See [[https://www.msweet.org/lprint/lprint.html][the documentation here]].
4
+
5
+ #+begin_src shell
6
+ sudo snap install lprint
7
+ sudo apt install gtk3-nocsd
8
+ set -gx LD_PRELOAD '/usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0'
9
+ sudo lprint devices
10
+ snap list
11
+ snap get lprint
12
+ snap info --verbose lprint
13
+ lsusb
14
+ snap connections lprint
15
+ sudo snap connect lprint:raw-usb
16
+ lprint devices
17
+ #+end_src
data/README.org CHANGED
@@ -10,7 +10,7 @@ The following is for org.
10
10
  [[https://travis-ci.org/ddoherty03/labrat.svg?branch=master]]
11
11
 
12
12
 
13
- * Table of Contents :toc_3:
13
+ * Table of Contents :toc_4:
14
14
  - [[#labrat][Labrat]]
15
15
  - [[#motivation][Motivation]]
16
16
  - [[#a-tip-on-buying-file-folder-labels][A Tip on Buying File Folder Labels]]
@@ -32,9 +32,17 @@ The following is for org.
32
32
  - [[#label-separator][Label separator]]
33
33
  - [[#number-of-copies][Number of copies]]
34
34
  - [[#input-and-output-files][Input and output files]]
35
+ - [[#output-file][Output file]]
36
+ - [[#command-line-arguments][Command-line arguments]]
37
+ - [[#specified-input-file][Specified input file]]
38
+ - [[#standard-input][Standard input]]
39
+ - [[#template-exception][Template exception]]
35
40
  - [[#printing-or-viewing][Printing or viewing]]
36
41
  - [[#shell-commands][Shell commands]]
37
42
  - [[#aids-to-testing-label-layouts][Aids to testing label layouts]]
43
+ - [[#page-grid-1][Page Grid]]
44
+ - [[#page-template][Page Template]]
45
+ - [[#verbose-reporting][Verbose Reporting]]
38
46
  - [[#the-label-database-and-the-label-option][The Label Database and the label option]]
39
47
  - [[#listing-labels][Listing labels]]
40
48
  - [[#system-label-database][System label database]]
@@ -51,7 +59,7 @@ wonderful [[https://github.com/prawnpdf/prawn][Prawn gem]] to generate PDF files
51
59
  =labrat= properly configured, printing a label is as simple as:
52
60
 
53
61
  #+begin_example
54
- $ labrat 'Income Taxes 2021++Example Maker, Inc.'
62
+ $ labrat 'Income Taxes 2021 ~~ Example Maker, Inc.'
55
63
  #+end_example
56
64
 
57
65
  And you will get a two-line file-folder label printed that looks like this:
@@ -77,14 +85,14 @@ without success, I decided to write my own. Hence labrat. With it---after
77
85
  due configuration---printing a file folder label is as simple as:
78
86
 
79
87
  #+begin_src sh
80
- $ labrat 'First Line of Label++And the Second Line'
88
+ $ labrat 'First Line of Label ~~ And the Second Line'
81
89
  #+end_src
82
90
 
83
91
  Or, you can preview the label in your previewer of choice (mine is qpdfview)
84
92
  by adding the -V flag:
85
93
 
86
94
  #+begin_src sh
87
- $ labrat -V 'First Line of Label++And the Second Line'
95
+ $ labrat -V 'First Line of Label ~~ And the Second Line'
88
96
  #+end_src
89
97
 
90
98
  Even better, I have included with =labrat= an elisp file (=labrat.el=) that
@@ -150,9 +158,9 @@ For the benefit of Emacs users, it also installs the =labrat.el= elisp library
150
158
  in =~/.config/labrat= as well, though you may want to move it to a different
151
159
  location.
152
160
 
153
- If invoke =labrat-install= multiple times, it will refuse to overwrite any
154
- existing config or database files that you may have edited. If you want to
155
- re-install them you have to move them out of the way.
161
+ If you invoke =labrat-install= multiple times, it will refuse to overwrite any
162
+ existing config or database files that you may have already installed. If you
163
+ want to re-install them you have to move the existing files out of the way.
156
164
 
157
165
  ** Setting options
158
166
  You can control how =labrat= composes a label completely from the
@@ -166,11 +174,11 @@ Labrat reads options from the following locations, with the locations listed
166
174
  from lowest to highest priority. In other words, options set in the
167
175
  first-listed location can be overriden by settings in later-listed locations.
168
176
 
169
- 1. It reads system-wide options from =/etc/xdg/labrat/config.yml=. This is a
170
- YAML formatted file in which the long form of the option, without the
171
- leading '--', is used as a key with the setting as the value.
172
- 2. It reads a user configuration from =~/.config/labrat/config.yml=. It also
173
- uses the YAML format based on the long form of option names.
177
+ 1. From =/etc/xdg/labrat/config.yml=. This is a YAML formatted file in which
178
+ the long form of the option, without the leading '--', is used as a key
179
+ with the setting as the value.
180
+ 2. From =~/.config/labrat/config.yml=. It also uses the YAML format based on
181
+ the long form of option names.
174
182
  3. Finally, it reads options from the command-line, where, of course, the
175
183
  leading hyphens are mandatory.
176
184
 
@@ -265,7 +273,7 @@ taking the page orientation into account
265
273
 
266
274
  ** Label Setup Options
267
275
  These options determine the layout of individual labels within the page rather
268
- than the page as a whole. Note that the dimensions of individual labels is
276
+ than the page as a whole. Note that the dimensions of a single whole label is
269
277
  not specified, but is implicitly determined by (1) the page width and height,
270
278
  (2) the page margins, (3) the number of rows and columns per page, and (4) the
271
279
  row and column gaps. The remaining space on the page is divided into a grid
@@ -279,10 +287,10 @@ side of the label:
279
287
  - ~--bottom-pad=DIM~ :: Distance from bottom side of label to the printed text
280
288
  - ~--left-pad=DIM~ :: Distance from left side of label to the printed text
281
289
  - ~--right-pad=DIM~ :: Distance from right side of label to the printed text
282
- - ~--v-pad=DIM~ :: Short for ~--top-pad=DIM~ and ~--bottom-pad~
283
- - ~--h-pad=DIM~ :: Short for ~--left-pad=DIM~ and ~--right-pad~
284
- - ~--pad=DIM~ :: Short for ~--top-pad=DIM~, ~--bottom-pad~, ~--left-pad=DIM~
285
- and ~--right-pad~
290
+ - ~--v-pad=DIM~ :: Short for ~--top-pad=DIM~ and ~--bottom-pad=DIM~
291
+ - ~--h-pad=DIM~ :: Short for ~--left-pad=DIM~ and ~--right-pad=DIM~
292
+ - ~--pad=DIM~ :: Short for ~--top-pad=DIM~, ~--bottom-pad=DIM~, ~--left-pad=DIM~
293
+ and ~--right-pad=DIM~
286
294
 
287
295
  *** Alignment
288
296
  By default the label text is centered horizontally and vertically within the
@@ -298,8 +306,9 @@ label, but the following options allow you to alter that.
298
306
  of these apply to the whole label text: there is no provision yet for doing
299
307
  in-line changes of font styles.
300
308
 
301
- - ~--font-name=NAME~ :: Name of font to use, Times, Courier, or Helvetica
302
- (default Helvetica);
309
+ - ~--font-name=[Times|Courier|Helvetica]~ :: Name of font to use. Currently,
310
+ these are the only three fonts are available: Times, Courier, or Helvetica.
311
+ Without this option, Helvetica is used;
303
312
  - ~--font-size=NUM~ :: Size of font to use in points (default 12)
304
313
  - ~--font-style=[normal|bold|italic|bold-italic]~ :: Style of font to use for
305
314
  text (default normal)
@@ -337,27 +346,27 @@ later pages always start on the first label position.
337
346
 
338
347
  *** New line marker
339
348
  You can embed a special text-sequence in the label text to indicate where a
340
- line-break should occur. By default it is the sequence =++=. This means that
341
- =labrat= will translate all occurrences of =++= in the text into a line-break,
342
- even consecutive occurrences. There is no way to escape this in the text, so
343
- if you want labels for various programming languages, you are going to have
344
- difficulty printing a label with 'C++' in it. But you can change the marker
349
+ line-break should occur. By default it is the sequence = ~~ =. This means
350
+ that =labrat= will translate all occurrences of = ~~ = in the text into a
351
+ line-break, even consecutive occurrences. There is no way to escape this in
352
+ the text, so if you want labels for that use ' ~~ ' as part of the text, you
353
+ are going to have difficulty printing a labels. But you can change the marker
345
354
  to something else with ~--nlsep~. This is especially helpful when you are
346
355
  using the command-line to supply the label text since specifying line-breaks
347
356
  on a shell command can be difficult. However note that this substitution
348
357
  takes place even when reading label texts from a file or standard input.
349
358
 
350
359
  - ~-n~, ~--nlsep=SEPARATOR~ :: Specify text to be translated into a line-break
351
- (default '++')
360
+ (default ' ~~ ')
352
361
 
353
362
  *** Label separator
354
363
  The only way to print more than one label from the command-line is to indicate
355
364
  where one label ends and the next begins with a special marker in the
356
- command-line arguments, by default the string ']*['. The text used for this
365
+ command-line arguments, by default the string '@@'. The text used for this
357
366
  can be customized with this option.
358
367
 
359
368
  - ~--label-sep=SEPARATOR~ :: Specify text that indicates the start of a new
360
- label (default ']*[')
369
+ label (default '@@')
361
370
 
362
371
  *** Number of copies
363
372
  This option causes =labrat= to generate multiple copies of each label with all
@@ -379,11 +388,11 @@ on the command-line. It combines all the non-option arguments and joins them
379
388
  with a space between each argument. For example,
380
389
 
381
390
  #+begin_example
382
- $ labrat -c3 This is a 'single label' '++composed of all this' text --font-style=italic
391
+ $ labrat -c3 This is a 'single label' ' ~~ composed of all this' text --font-style=italic
383
392
  #+end_example
384
393
 
385
394
  prints three copies of a single label in italics with two lines, breaking at
386
- the '++' marker, resulting in something like this:
395
+ the ' ~~ ' marker, resulting in something like this:
387
396
 
388
397
  #+begin_example
389
398
  This is a single label
@@ -392,12 +401,12 @@ composed of all this text
392
401
 
393
402
  Note that when the label text is specified on the command-line, ~labrat~ just
394
403
  prints a single label. The only ways to get multiple labels is by (1) marking
395
- a separation between labels with the ~--label-sep~ marker (']*[' by default)
404
+ a separation between labels with the ~--label-sep~ marker ('@@' by default)
396
405
  or (2) using the ~-c~ (~--copies~) argument to get multiple copies of the
397
406
  label text. These options can be combined as well. For example,
398
407
 
399
408
  #+begin_example
400
- $ labrat -c3 This is the 'first label' ']*[' 'And the rest ++ is the second' text --font-style=italic
409
+ $ labrat -c3 This is the 'first label' @@ 'And the rest ~~ is the second' text --font-style=italic
401
410
  #+end_example
402
411
 
403
412
  will produce three copies of two separate labels:
@@ -439,9 +448,10 @@ as for a specified ~in-file~, treating each paragraph as a label text and
439
448
  disregarding comments.
440
449
 
441
450
  **** Template exception
442
- Notwithstanding all of the above, if the ~-T~ (~--template~) option is given,
443
- all label texts from the command-line, an ~in-file~, or standard input are
444
- ignored and a template is generated.
451
+ Notwithstanding all of the above, if the ~-T~ (~--template~) option is given
452
+ (see below at [[*Aids to testing label layouts][Aids to testing label layouts]]), all label texts from the
453
+ command-line, an ~in-file~, or standard input are ignored and a template is
454
+ generated.
445
455
 
446
456
  *** Printing or viewing
447
457
  By default, =labrat= prints the generated output file to the printer named
@@ -467,7 +477,8 @@ any event.
467
477
 
468
478
  - ~-p~, ~--printer=NAME~ :: Name of the label printer to print on
469
479
  - ~-%~, ~--print-command=PRINTCMD~ :: Command to use for printing with %p for
470
- printer name; %o for label file name
480
+ printer name; %o for label file name (the `%` is meant to remind you of a
481
+ piece of a paper beingg fed between two rollers)
471
482
 
472
483
  Likewise, =labrat= uses the shell command
473
484
  #+begin_example
@@ -479,11 +490,16 @@ very likely that you will want to configure this with the ~--view-command~
479
490
  option to your liking.
480
491
 
481
492
  - ~-:~, ~--view-command=VIEWCMD~ :: Command to use for viewing with %o for
482
- label file name
493
+ label file name (the `:` is meant to remind you of a pair of eyes looking at
494
+ the purdy label)
483
495
 
484
496
  *** Aids to testing label layouts
497
+
498
+ **** Page Grid
485
499
  The following options are very useful if your are trying to configure the set
486
- up for a new label type or otherwise trying to figure out a problem.
500
+ up for a new label type or otherwise trying to figure out a problem, such as
501
+ setting the ~--delta-x~ or ~--delta-y~ values for your setup.
502
+
487
503
  Normally, =labrat= does not print an outline for the labels, but if you are
488
504
  testing things out on plain paper, it helps to know where =labrat= thinks the
489
505
  boundaries of the labels are. That is what the ~--grid~ or ~-g~ options
@@ -491,14 +507,16 @@ provide.
491
507
 
492
508
  - ~-g~, ~--[no-]grid~ :: Add grid lines to output
493
509
 
510
+ **** Page Template
494
511
  When trying to define a new label layout, it also helps to just see what a
495
- single sheet of labels would look like. That is what the ~--template~ or ~-T~
496
- option give you: it just prints an outline of where labels would be printed
497
- but ignores any label text.
512
+ single sheet of labels would look like. That is what the ~--template~ (or
513
+ ~-T~) option gives you: it just prints an outline of where labels would be
514
+ printed but ignores any label text.
498
515
 
499
516
  - ~-T~, ~--[no-]template~ :: Print a template of a page of labels and ignore
500
517
  any content
501
518
 
519
+ **** Verbose Reporting
502
520
  Finally, =labrat= will print a lot of information about what it's doing with
503
521
  the ~--verbose~ or ~-v~ option. The information is printed to the standard
504
522
  error output stream.
@@ -554,7 +572,7 @@ $ labrat -T -V --label=avery8987
554
572
 
555
573
  And if you want to see it with sample label text filled in, try the following:
556
574
  #+begin_example
557
- $ labrat -V -c30 --label=avery8987 'Four score and seven years ago++Our fathers brought forth'
575
+ $ labrat -V -c30 --label=avery8987 'Four score and seven years ago ~~ Our fathers brought forth'
558
576
  #+end_example
559
577
 
560
578
  *** Nesting label definitions
@@ -590,7 +608,7 @@ badge:
590
608
 
591
609
  With this, you can print a file folder label with:
592
610
  #+begin_example
593
- $ labrat --label=ff 'Four score and seven years ago++Our fathers brought forth'
611
+ $ labrat --label=ff 'Four score and seven years ago ~~ Our fathers brought forth'
594
612
  #+end_example
595
613
 
596
614
  And, if you want this to be your default label type, you can add to your user-level
@@ -602,13 +620,13 @@ label:
602
620
 
603
621
  Now you can print the label without the ~--label~ option on the command-line:
604
622
  #+begin_example
605
- $ labrat 'Four score and seven years ago++Our fathers brought forth'
623
+ $ labrat 'Four score and seven years ago ~~ Our fathers brought forth'
606
624
  #+end_example
607
625
 
608
626
  If you want to print badges, you have to specify the ~--label~ option explicitly on
609
627
  the command-line:
610
628
  #+begin_example
611
- $ labrat -V -c14 --label=badge 'Daniel E. Doherty++(Amateur Programmer)'
629
+ $ labrat -V -c14 --label=badge 'Daniel E. Doherty ~~ (Amateur Programmer)'
612
630
  #+end_example
613
631
 
614
632
  *** A Caution about option order
@@ -618,7 +636,7 @@ override earlier settings. For example, given the configuration above, where
618
636
  ~ff~ is your default label type, the following will not do what you expect:
619
637
 
620
638
  #+begin_example
621
- $ labrat --font-style=italic --label=ff 'Four score and seven years ago++Our fathers brought forth'
639
+ $ labrat --font-style=italic --label=ff 'Four score and seven years ago ~~ Our fathers brought forth'
622
640
  #+end_example
623
641
 
624
642
  You expect the label to be printed in italic, but the ~--label=ff~ option in
@@ -629,7 +647,7 @@ namely ~--font-style=bold~ from the user-level label database.
629
647
  To get this to work, you have to put the command-line setting after the
630
648
  ~--label=ff~ option in order for it to take effect:
631
649
  #+begin_example
632
- $ labrat --label=ff --font-style=italic 'Four score and seven years ago++Our fathers brought forth'
650
+ $ labrat --label=ff --font-style=italic 'Four score and seven years ago ~~ Our fathers brought forth'
633
651
  #+end_example
634
652
 
635
653
  * Development
data/bin/labrat CHANGED
@@ -27,9 +27,9 @@ begin
27
27
  if ops.template
28
28
  []
29
29
  elsif !ops.in_file.blank?
30
- Labrat.read_label_texts(ops.in_file, ops.nlsep)
30
+ Labrat.read_label_texts(ops.in_file, ops.nl_sep)
31
31
  elsif non_ops.empty?
32
- Labrat.read_label_texts(nil, ops.nlsep)
32
+ Labrat.read_label_texts(nil, ops.nl_sep)
33
33
  else
34
34
  []
35
35
  end
data/labrat.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  the wonderful Prawn gem to generate PDF files with label formatting in mind. With
16
16
  labrat properly configured, printing a label is as simple as:
17
17
 
18
- $ labrat 'Income Taxes 2021++Example Maker, Inc.'
18
+ $ labrat 'Income Taxes 2021 ~~ Example Maker, Inc.'
19
19
 
20
20
  And you will get a two-line file-folder label with the text centered. It can
21
21
  print on dymo label printer rolls or Avery sheet labels. It knows the layout of
@@ -45,13 +45,12 @@ DESC
45
45
  spec.add_dependency "matrix"
46
46
  spec.add_dependency "prawn", "~> 2.0"
47
47
  spec.add_dependency "activesupport"
48
- spec.add_dependency "methodize"
49
48
  spec.add_dependency "fat_core"
50
49
 
51
- # Note: pry-byebug requires that pry be within the '0.13.0' version box.
52
50
  spec.add_development_dependency 'rake'
53
51
  spec.add_development_dependency 'rspec'
54
- spec.add_development_dependency 'pry', '~> 0.13.0'
52
+ spec.add_development_dependency 'pry'
53
+ spec.add_development_dependency 'simplecov'
55
54
  spec.add_development_dependency 'debug', '>= 1.0.0'
56
55
  spec.add_development_dependency 'rubocop-performance'
57
56
  spec.add_development_dependency 'rubocop-shopify'
@@ -93,7 +93,12 @@
93
93
  # A string sequence that is interpreted as a line-break can be defined. Such
94
94
  # a sequence is particularly helpful when you provide the label text on the
95
95
  # command-line, though it will be applied to file-read label texts as well.
96
- # nlsep: '++'
96
+ # nlsep: '~~'
97
+
98
+ # A string sequence that indicates the start of a new label. Such a sequence
99
+ # is particularly helpful when you provide the label text on the command-line,
100
+ # though it will be applied to file-read label texts as well.
101
+ # label-sep: '==>'
97
102
 
98
103
  # The name of the printer to use in substituting for the %p placeholder in the
99
104
  # print-command setting below.
@@ -3,8 +3,9 @@
3
3
  # out-file, etc., only things such as page and label dimensions that would
4
4
  # apply to all users of a particular label type.
5
5
 
6
+ # 19.9x87.29mm
6
7
  dymo30327:
7
- page-width: 24mm
8
+ page-width: 25mm
8
9
  page-height: 87mm
9
10
  rows: 1
10
11
  columns: 1
@@ -12,10 +13,10 @@ dymo30327:
12
13
  bottom-page-margin: 0mm
13
14
  left-page-margin: 5mm
14
15
  right-page-margin: 5mm
15
- top-pad: 0mm
16
- bottom-pad: 0mm
17
- left-pad: 2mm
18
- right-pad: 2mm
16
+ top-pad: 1mm
17
+ bottom-pad: 1mm
18
+ left-pad: 1mm
19
+ right-pad: 1mm
19
20
  landscape: true
20
21
 
21
22
  duraready1034D:
@@ -208,7 +209,7 @@ avery5163:
208
209
  column-gap: 5mm
209
210
  landscape: false
210
211
 
211
- avery15513::
212
+ avery15513:
212
213
  label: avery5163
213
214
 
214
215
  label: avery5163
@@ -20,7 +20,7 @@ module Labrat
20
20
  # Parse and set the options object to reflect the values of the given
21
21
  # args, after merging in any prior settings into options. Return the
22
22
  # resulting options instance. The args argument can be either a Hash or,
23
- # as usual, an Array of Strings from the command-line.x Throw an exception
23
+ # as usual, an Array of Strings from the command-line. Throw an exception
24
24
  # for errors encountered parsing the args.
25
25
  def parse(args, prior: {}, verbose: false)
26
26
  options.msg = nil
@@ -48,7 +48,7 @@ module Labrat
48
48
  parser.separator ""
49
49
  parser.separator "Print or view (with -V) a label with the given <label-text>."
50
50
  parser.separator "All non-option arguments are used for the label text with a special"
51
- parser.separator "marker ('++' by default, see --nlsep) indicating a line-break."
51
+ parser.separator "marker ('~~' by default, see --nlsep) indicating a line-break."
52
52
  parser.separator ""
53
53
  parser.separator "Below, NUM indicates an integer, DIM, indicates a linear dimension,"
54
54
  parser.separator "valid DIM units are: pt, mm, cm, dm, m, in, ft, yd."
@@ -198,8 +198,10 @@ module Labrat
198
198
  # of common labels with their dimensions, so that --width and --height
199
199
  # need not be specified.
200
200
  def label_name_option
201
+ # options.raw_label = nil
201
202
  parser.on("-lNAME", "--label=NAME",
202
203
  "Use options for label type NAME from label database") do |name|
204
+ options.raw_label ||= name
203
205
  if labels_seen.include?(name)
204
206
  msg = "label option '#{name}' has circular reference"
205
207
  labels_seen.each do |nm|
@@ -236,8 +238,17 @@ module Labrat
236
238
  warn "#{p}\n"
237
239
  end
238
240
  warn "\nKnown labels:\n"
239
- lab_names.groups_of(6).each do |_n, grp|
240
- warn " #{grp.join(', ')}"
241
+ max_width = lab_names.max_by(&:length).length
242
+ ngrps = (78 / (max_width + 1)).floor
243
+
244
+ lab_names.sort_by do |nm|
245
+ nm.match(/\A([a-zA-z]+)([0-9]+)?/)
246
+ [$1, $2.to_i || 0]
247
+ end
248
+ .groups_of(ngrps).each do |_n, grp|
249
+ fmt = "%-#{max_width+1}s"
250
+ grp = grp.map{|nm| sprintf(fmt, nm) }
251
+ warn " #{grp.join(' ')}"
241
252
  end
242
253
  end
243
254
  exit(0)
@@ -350,11 +361,11 @@ module Labrat
350
361
 
351
362
  # On a command-line, specifying where a line-break should occur is not
352
363
  # convenient when shell interpretation and quoting rules are taken into
353
- # account. This allows the user to use some distinctive marker ('++' by
364
+ # account. This allows the user to use some distinctive marker ('~~' by
354
365
  # default) to designate where a line break should occur.
355
366
  def nl_sep_option
356
367
  parser.on("-nSEP", "--nl-sep=SEPARATOR",
357
- "Specify text to be translated into a line-break (default '++')") do |nl|
368
+ "Specify text to be translated into a line-break (default '~~')") do |nl|
358
369
  options.nl_sep = nl
359
370
  warn " ::nl-sep <- '#{nl}'::" if options.verbose
360
371
  end
@@ -365,7 +376,7 @@ module Labrat
365
376
  # designate where a new label shoul be started.
366
377
  def label_sep_option
367
378
  parser.on("--label-sep=SEPARATOR",
368
- "Specify text that indicates the start of a new label (default ']*[')") do |ls|
379
+ "Specify text that indicates the start of a new label (default '==>')") do |ls|
369
380
  options.label-sep = ls
370
381
  warn " ::label-sep <- '#{ls}'::" if options.verbose
371
382
  end
data/lib/labrat/config.rb CHANGED
@@ -71,8 +71,15 @@ module Labrat
71
71
  files.each do |f|
72
72
  next unless File.readable?(f)
73
73
 
74
- yml_hash = YAML.load(File.read(f))&.methodize || {}
75
- yml_hash.report("Merging from file '#{f}") if verbose
74
+ yml_hash = YAML.load(File.read(f))
75
+ next unless yml_hash
76
+
77
+ if yml_hash.is_a?(Hash)
78
+ yml_hash = yml_hash.methodize
79
+ else
80
+ raise "Error loading file #{f}:\n#{File.read(f)[0..500]}"
81
+ end
82
+ yml_hash.report("Merging config from file '#{f}") if verbose
76
83
  hash.deep_merge!(yml_hash)
77
84
  end
78
85
  hash
data/lib/labrat/label.rb CHANGED
@@ -57,11 +57,15 @@ module Labrat
57
57
  warn ""
58
58
  end
59
59
  if ops.template
60
- # Replace any texts with the numbers and show the grid.
61
- self.texts = (1..(ops.rows * ops.columns)).map(&:to_s)
60
+ # Replace any texts with the numbers, the name of the label (and alias) and show the grid.
61
+ lab_text = ops.raw_label || ops.label
62
+ if ops.label != ops.raw_label
63
+ lab_text += "\n(#{ops.label})"
64
+ end
65
+ self.texts = (1..(ops.rows * ops.columns)).map {|n| "#{n}\n#{lab_text}"}
62
66
  ops.font_name = 'Helvetica'
63
67
  ops.font_style = 'bold'
64
- ops.font_size = 16
68
+ ops.font_size = 11
65
69
  pdf.grid.show_all
66
70
  end
67
71
  raise EmptyLabelError, "Empty label" if waste_of_labels?
@@ -6,7 +6,7 @@ module Labrat
6
6
  # and perhaps environment. An Options instance can be handed off to the
7
7
  # label-printing objects to inform its formatting, printing, etc.
8
8
  class Options
9
- attr_accessor :label, :page_width, :page_height,
9
+ attr_accessor :label, :raw_label, :page_width, :page_height,
10
10
  :left_page_margin, :right_page_margin,
11
11
  :top_page_margin, :bottom_page_margin,
12
12
  :rows, :columns, :row_gap, :column_gap, :landscape,
@@ -22,6 +22,7 @@ module Labrat
22
22
  # Initialize with an optional hash of default values for the attributes.
23
23
  def initialize(**init)
24
24
  self.label = init[:label] || nil
25
+ self.raw_label = nil
25
26
  # Per-page attributes
26
27
  self.page_width = init[:page_width] || 24.mm
27
28
  self.page_height = init[:page_height] || 87.mm
@@ -49,8 +50,8 @@ module Labrat
49
50
  self.font_size = init[:font_size] || 12
50
51
  # Input attributes
51
52
  self.in_file = init[:in_file] || nil
52
- self.nl_sep = init[:nl_sep] || '++'
53
- self.label_sep = init[:label_sep] || ']*['
53
+ self.nl_sep = init[:nl_sep] || '~~'
54
+ self.label_sep = init[:label_sep] || '@@'
54
55
  self.copies = init[:copies] || 1
55
56
  # Output attributes
56
57
  self.printer = init[:printer] || ENV['LABRAT_PRINTER'] || ENV['PRINTER'] || 'dymo'
@@ -84,6 +85,8 @@ module Labrat
84
85
  end
85
86
  warn ""
86
87
  end
88
+ # We want raw_label to reflect what the user typed on the command-line
89
+ file_options.raw_label = nil
87
90
  Labrat::ArgParser.new.parse(args, prior: file_options, verbose: verbose)
88
91
  end
89
92
 
@@ -124,6 +127,7 @@ module Labrat
124
127
  def to_hash
125
128
  {
126
129
  label: label,
130
+ raw_label: raw_label,
127
131
  page_width: page_width,
128
132
  page_height: page_height,
129
133
  left_page_margin: left_page_margin,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Labrat
4
- VERSION = "0.1.14"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/labrat.rb CHANGED
@@ -7,8 +7,8 @@ require 'prawn'
7
7
  require 'prawn/measurement_extensions'
8
8
  require 'optparse'
9
9
  require 'yaml'
10
- require 'methodize'
11
10
  require 'pp'
11
+ require 'debug'
12
12
 
13
13
  require_relative "labrat/version"
14
14
  require_relative "labrat/errors"
data/lib/lisp/labrat.el CHANGED
@@ -22,7 +22,7 @@ e.g. ~/.rbenv/shims/labrat, for an rbenv ruby installation."
22
22
  :type 'string
23
23
  :group 'labrat)
24
24
 
25
- (defcustom labrat-nl-sep "++"
25
+ (defcustom labrat-nl-sep "~~"
26
26
  "String to mark newlines in label text.
27
27
 
28
28
  If you change this, you need to make a corresponding change in your
@@ -30,7 +30,7 @@ labrat configuration at ~/.config/labrat/config.yml."
30
30
  :type 'string
31
31
  :group 'labrat)
32
32
 
33
- (defcustom labrat-label-sep "]*["
33
+ (defcustom labrat-label-sep "@@"
34
34
  "String to mark the separation between labels on the labrat command-line.
35
35
 
36
36
  If you change this, you need to make a corresponding change in your
@@ -88,10 +88,10 @@ returned"
88
88
  This invokes the \"labrat -V\ <label>\" command with the
89
89
  paragraph at or before point inserted in the <label> position,
90
90
  but with each new-line replaced with the value of the variable
91
- labrat-nl-sep, '++' by default."
91
+ labrat-nl-sep, '~~' by default."
92
92
  (interactive)
93
- (call-process labrat-executable nil nil nil
94
- "-V" (labrat/pars-in-region)))
93
+ (call-process labrat-executable nil (get-buffer-create "*labrat*") nil
94
+ "-V" "-o ~/labrat.pdf""-V --out-file=~/labrat.pdf" (labrat/pars-in-region)))
95
95
 
96
96
  (defun labrat-print ()
97
97
  "Print the paragraph at or before point as a label with labrat.
@@ -99,10 +99,10 @@ labrat-nl-sep, '++' by default."
99
99
  This invokes the \"labrat -P <label>\" command with the paragraph
100
100
  at or before point inserted in the <label> position, but with
101
101
  each new-line replaced with the value of the variable
102
- labrat-nl-sep, '++' by default."
102
+ labrat-nl-sep, '~~' by default."
103
103
  (interactive)
104
- (call-process labrat-executable nil nil nil
105
- (labrat/pars-in-region)))
104
+ (call-process labrat-executable nil (buffer-name (get-buffer-create "*labrat*")) nil
105
+ "-o ~/labrat.pdf" (labrat/pars-in-region)))
106
106
 
107
107
  (provide 'labrat)
108
108
  ;;; labrat.el ends here
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: labrat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
11
+ date: 2023-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: matrix
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: methodize
56
+ name: fat_core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,13 +67,13 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: fat_core
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
- type: :runtime
76
+ type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rake
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rspec
98
+ name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,19 +109,19 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: pry
112
+ name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 0.13.0
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 0.13.0
124
+ version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: debug
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -184,7 +184,7 @@ description: |2+
184
184
  the wonderful Prawn gem to generate PDF files with label formatting in mind. With
185
185
  labrat properly configured, printing a label is as simple as:
186
186
 
187
- $ labrat 'Income Taxes 2021++Example Maker, Inc.'
187
+ $ labrat 'Income Taxes 2021 ~~ Example Maker, Inc.'
188
188
 
189
189
  And you will get a two-line file-folder label with the text centered. It can
190
190
  print on dymo label printer rolls or Avery sheet labels. It knows the layout of
@@ -204,10 +204,12 @@ files:
204
204
  - ".gitignore"
205
205
  - ".rspec"
206
206
  - ".rubocop.yml"
207
+ - ".simplecov"
207
208
  - ".travis.yml"
208
209
  - CHANGELOG.md
209
210
  - Gemfile
210
211
  - Gemfile.lock
212
+ - Notes.org
211
213
  - README.org
212
214
  - Rakefile
213
215
  - TODO.org
@@ -254,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
256
  - !ruby/object:Gem::Version
255
257
  version: '0'
256
258
  requirements: []
257
- rubygems_version: 3.3.3
259
+ rubygems_version: 3.4.2
258
260
  signing_key:
259
261
  specification_version: 4
260
262
  summary: Command-line and Emacs label print software.