commentbox 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cbwiz +22 -7
- data/lib/commentbox.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6e6ad58ee774761f75736dfa59521066e1891734a2cbec74735934787bd217b
|
4
|
+
data.tar.gz: ed56c9fc4b444ad98d8efb8ff466b4febae04120f6fdec4de3f44a886e61b455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a696f49cdbc12e075d0a02743bd7c7ac5ead6ee337f9849b9e9ae3070393f8b6f2609943c137ab8216d7a1a19555d34fc441ad8d60572ac5d12e1bb26a090a9b
|
7
|
+
data.tar.gz: 8b2a64f47c07f8784afb7fbb5b3ab7cde81083e158559dc3b41eabd37f1777dc58a445818e0a482b123626beac7679dc113c5f728b8ca383cf0133049cc7c6ad
|
data/bin/cbwiz
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# cbwiz - an executable tool for the commentbox ruby gem by Lenny
|
4
|
+
# it's read: Comment Box WhIZzer
|
5
|
+
# github.com/lennyitb/commentbox
|
6
|
+
|
3
7
|
require 'commentbox'
|
4
8
|
|
5
|
-
$HELP_MSG = %q(Usage: cbwiz [
|
9
|
+
$HELP_MSG = %q(Usage: cbwiz [-t] text [options]
|
6
10
|
Options:
|
7
11
|
-t, --text [text] Text to be commented. Optional flag for first argument
|
8
|
-
-a, --align [l1
|
12
|
+
-a, --align [l1 l2...] Alignment of text: left, center, right
|
9
13
|
-s, --style [style] Style of comment box: stub, window, parallax, zigzag, or money
|
10
14
|
-p, --padding [padding] Padding of comment box
|
11
15
|
-o, --offset [offset] Offset of comment box
|
@@ -19,16 +23,22 @@ def help_and_exit
|
|
19
23
|
puts $HELP_MSG
|
20
24
|
exit
|
21
25
|
end
|
22
|
-
|
23
26
|
if ARGV.empty?
|
24
|
-
|
27
|
+
puts "/* cbwiz - no arguments given. for help, use: cbwiz -h */"
|
28
|
+
exit
|
25
29
|
end
|
30
|
+
|
26
31
|
# if the :text parameter is first, the -t flag is optional
|
27
32
|
mode = :text
|
28
33
|
options = {}
|
29
34
|
# for each argument:
|
30
|
-
#
|
31
|
-
#
|
35
|
+
# - if it's a switch, set the `mode` symbol
|
36
|
+
# - if it's a value, set/append to the coresponding `mode` key in `options`
|
37
|
+
|
38
|
+
# usually this type of code wouldn't be the best practice, but not only does it work well here--
|
39
|
+
# it's also a situation where the order of the arguments is an important piece, that we can't
|
40
|
+
# really get away from by writitng unnecicarily declarative code. With each iterative pass,
|
41
|
+
# we're either updating the mode, or using the value of mode we set before.
|
32
42
|
ARGV.each do |arg|
|
33
43
|
case arg
|
34
44
|
when '-h', '--help', 'help', '-?', '--?'
|
@@ -53,14 +63,19 @@ ARGV.each do |arg|
|
|
53
63
|
# although it remains possible to explicitly specify true
|
54
64
|
options[:spacelines] = false
|
55
65
|
else
|
66
|
+
# every argv that gets here is not a switch
|
56
67
|
if options[mode].nil?
|
57
68
|
options[mode] = arg
|
58
69
|
else
|
59
|
-
# hacky line to make sure
|
70
|
+
# hacky line to make sure any switch with multiple arguments comes out as a flat array like so:
|
71
|
+
# -a left center right
|
72
|
+
# >> { alignment: ['left', 'center', 'right'] }
|
60
73
|
options[mode] = ([ options[mode] ] << arg).flatten
|
61
74
|
end
|
62
75
|
end
|
63
76
|
end
|
77
|
+
# make sure the :text key is a string
|
78
|
+
if options[:text].is_a? Array then options[:text] = options[:text].join(' ') end
|
64
79
|
# finally, unescape newlines in text
|
65
80
|
options[:text] = options[:text].gsub('\n', "\n")
|
66
81
|
|
data/lib/commentbox.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
|
2
|
+
# commentbox: a ruby gem for generating C/C++ formatted comment boxes
|
3
|
+
# github.com/lennyitb/commentbox
|
4
|
+
|
2
5
|
module CommentBoxStyles
|
3
6
|
DefaultParams = {
|
4
7
|
style: :stub,
|
@@ -7,7 +10,7 @@ module CommentBoxStyles
|
|
7
10
|
offset: 2,
|
8
11
|
min_width: 0,
|
9
12
|
spacelines: true,
|
10
|
-
alignment:
|
13
|
+
alignment: :left
|
11
14
|
}
|
12
15
|
Styles = {
|
13
16
|
stub: {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commentbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonard H. Phelan IV
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A little gem for generating pretty multiline comment boxes in C/C++ templates
|
14
14
|
email: lenny@lenny.beer
|