squib 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +162 -133
  3. data/Gemfile +4 -4
  4. data/README.md +630 -550
  5. data/RELEASE TODO.md +18 -18
  6. data/Rakefile +99 -99
  7. data/lib/squib.rb +32 -32
  8. data/lib/squib/api/background.rb +20 -19
  9. data/lib/squib/api/data.rb +100 -99
  10. data/lib/squib/api/image.rb +90 -76
  11. data/lib/squib/api/save.rb +149 -103
  12. data/lib/squib/api/settings.rb +35 -37
  13. data/lib/squib/api/shapes.rb +230 -228
  14. data/lib/squib/api/text.rb +65 -66
  15. data/lib/squib/api/text_embed.rb +96 -66
  16. data/lib/squib/args/arg_loader.rb +138 -0
  17. data/lib/squib/args/box.rb +55 -0
  18. data/lib/squib/args/card_range.rb +32 -0
  19. data/lib/squib/args/color_validator.rb +12 -0
  20. data/lib/squib/args/coords.rb +33 -0
  21. data/lib/squib/args/dir_validator.rb +16 -0
  22. data/lib/squib/args/draw.rb +92 -0
  23. data/lib/squib/args/embed_adjust.rb +25 -0
  24. data/lib/squib/args/embed_key.rb +17 -0
  25. data/lib/squib/args/hand_special.rb +37 -0
  26. data/lib/squib/args/input_file.rb +37 -0
  27. data/lib/squib/args/paint.rb +44 -0
  28. data/lib/squib/args/paragraph.rb +115 -0
  29. data/lib/squib/args/save_batch.rb +60 -0
  30. data/lib/squib/args/scale_box.rb +53 -0
  31. data/lib/squib/args/sheet.rb +72 -0
  32. data/lib/squib/args/showcase_special.rb +38 -0
  33. data/lib/squib/args/svg_special.rb +37 -0
  34. data/lib/squib/args/transform.rb +25 -0
  35. data/lib/squib/args/typographer.rb +117 -117
  36. data/lib/squib/card.rb +67 -67
  37. data/lib/squib/conf.rb +117 -111
  38. data/lib/squib/constants.rb +178 -178
  39. data/lib/squib/deck.rb +113 -111
  40. data/lib/squib/graphics/cairo_context_wrapper.rb +99 -53
  41. data/lib/squib/graphics/gradient_regex.rb +46 -46
  42. data/lib/squib/graphics/hand.rb +42 -43
  43. data/lib/squib/graphics/image.rb +76 -73
  44. data/lib/squib/graphics/save_doc.rb +103 -137
  45. data/lib/squib/graphics/save_images.rb +33 -33
  46. data/lib/squib/graphics/shapes.rb +119 -152
  47. data/lib/squib/graphics/showcase.rb +85 -88
  48. data/lib/squib/graphics/text.rb +176 -216
  49. data/lib/squib/layout_parser.rb +91 -89
  50. data/lib/squib/layouts/economy.yml +85 -0
  51. data/lib/squib/layouts/fantasy.yml +101 -0
  52. data/lib/squib/layouts/hand.yml +62 -46
  53. data/lib/squib/layouts/playing-card.yml +35 -18
  54. data/lib/squib/project_template/config.yml +45 -40
  55. data/lib/squib/version.rb +10 -10
  56. data/samples/color_shortcuts.rb +6 -0
  57. data/samples/csv_import.rb +18 -18
  58. data/samples/custom-config.yml +5 -5
  59. data/samples/custom_config.rb +18 -18
  60. data/samples/draw_shapes.rb +45 -35
  61. data/samples/embed_text.rb +88 -90
  62. data/samples/hand.rb +24 -24
  63. data/samples/layouts.rb +62 -61
  64. data/samples/layouts_builtin.rb +51 -0
  65. data/samples/load_images.rb +78 -64
  66. data/samples/ranges.rb +64 -53
  67. data/samples/sample.csv +2 -2
  68. data/samples/text_options.rb +102 -94
  69. data/spec/api/api_data_spec.rb +57 -50
  70. data/spec/api/api_settings_spec.rb +37 -17
  71. data/spec/args/box_spec.rb +127 -0
  72. data/spec/args/draw_spec.rb +95 -0
  73. data/spec/args/embed_key_spec.rb +13 -0
  74. data/spec/args/input_file_spec.rb +21 -0
  75. data/spec/args/paint_spec.rb +22 -0
  76. data/spec/args/paragraph_spec.rb +153 -0
  77. data/spec/args/range_spec.rb +36 -0
  78. data/spec/args/save_batch_spec.rb +51 -0
  79. data/spec/args/scale_box_spec.rb +71 -0
  80. data/spec/args/sheet_spec.rb +58 -0
  81. data/spec/args/showcase_special_spec.rb +15 -0
  82. data/spec/data/samples/autoscale_font.rb.txt +84 -87
  83. data/spec/data/samples/basic.rb.txt +209 -203
  84. data/spec/data/samples/cairo_access.rb.txt +2 -2
  85. data/spec/data/samples/config_text_markup.rb.txt +72 -75
  86. data/spec/data/samples/csv_import.rb.txt +76 -80
  87. data/spec/data/samples/custom_config.rb.txt +48 -49
  88. data/spec/data/samples/draw_shapes.rb.txt +100 -42
  89. data/spec/data/samples/embed_text.rb.txt +283 -295
  90. data/spec/data/samples/excel.rb.txt +162 -171
  91. data/spec/data/samples/gradients.rb.txt +79 -67
  92. data/spec/data/samples/hand.rb.txt +538 -514
  93. data/spec/data/samples/hello_world.rb.txt +36 -38
  94. data/spec/data/samples/load_images.rb.txt +41 -5
  95. data/spec/data/samples/portrait-landscape.rb.txt +49 -51
  96. data/spec/data/samples/ranges.rb.txt +460 -429
  97. data/spec/data/samples/saves.rb.txt +801 -785
  98. data/spec/data/samples/showcase.rb.txt +5910 -5906
  99. data/spec/data/samples/text_options.rb.txt +1125 -981
  100. data/spec/data/samples/tgc_proofs.rb.txt +81 -79
  101. data/spec/data/samples/units.rb.txt +18 -12
  102. data/spec/data/xlsx/with_macros.xlsm +0 -0
  103. data/spec/graphics/cairo_context_wrapper_spec.rb +84 -75
  104. data/spec/graphics/graphics_images_spec.rb +94 -85
  105. data/spec/graphics/graphics_save_doc_spec.rb +67 -65
  106. data/spec/samples/expected/hand.png +0 -0
  107. data/spec/samples/expected/hand_pretty.png +0 -0
  108. data/spec/samples/expected/layout_00.png +0 -0
  109. data/spec/samples/expected/load_images_00.png +0 -0
  110. data/spec/samples/expected/ranges_00.png +0 -0
  111. data/spec/samples/expected/shape_00.png +0 -0
  112. data/spec/samples/expected/showcase.png +0 -0
  113. data/spec/samples/expected/showcase2.png +0 -0
  114. data/spec/samples/expected/showcase_individual_00.png +0 -0
  115. data/spec/samples/expected/showcase_individual_01.png +0 -0
  116. data/spec/samples/expected/showcase_individual_02.png +0 -0
  117. data/spec/samples/expected/showcase_individual_03.png +0 -0
  118. data/spec/samples/expected/text_00.png +0 -0
  119. data/spec/samples/expected/text_01.png +0 -0
  120. data/spec/samples/expected/text_02.png +0 -0
  121. data/spec/samples/samples_regression_spec.rb +82 -82
  122. data/spec/spec_helper.rb +3 -2
  123. data/squib.gemspec +48 -48
  124. data/squib.sublime-project +42 -36
  125. metadata +61 -33
  126. data/lib/squib/input_helpers.rb +0 -238
  127. data/spec/api/api_image_spec.rb +0 -38
  128. data/spec/api/api_text_spec.rb +0 -37
  129. data/spec/graphics/graphics_shapes_spec.rb +0 -85
  130. data/spec/graphics/graphics_text_spec.rb +0 -164
  131. data/spec/input_helpers_spec.rb +0 -238
  132. data/spec/samples/expected/embed_multi_00.png +0 -0
  133. data/spec/samples/expected/embed_multi_01.png +0 -0
  134. data/spec/samples/expected/embed_multi_02.png +0 -0
  135. data/spec/samples/expected/ranges_01.png +0 -0
  136. data/spec/samples/expected/ranges_02.png +0 -0
@@ -0,0 +1,85 @@
1
+ #This layout inspired by popular fantasy games
2
+ title:
3
+ x: 90
4
+ y: 90
5
+ width: 635
6
+ height: 50
7
+ align: center
8
+
9
+ art:
10
+ x: 75
11
+ y: 150
12
+ width: 675
13
+ height: 520
14
+
15
+ description:
16
+ x: 100
17
+ y: 675
18
+ width: 625
19
+ height: 275
20
+ valign: middle
21
+ align: center
22
+ font_size: 18
23
+ desc: # alias
24
+ extends: description
25
+
26
+ type:
27
+ x: 90
28
+ y: 955
29
+ width: 645
30
+ height: 50
31
+ align: center
32
+
33
+ lower_right:
34
+ x: 675
35
+ y: 975
36
+ width: 75
37
+ height: 75
38
+ font_size: 18
39
+ valign: bottom
40
+ align: right
41
+ lr: #alias
42
+ extends: lower_right
43
+
44
+ lower_left:
45
+ x: 75
46
+ y: 975
47
+ width: 75
48
+ height: 75
49
+ font_size: 18
50
+ valign: bottom
51
+ align: left
52
+ ll: # alias
53
+ extends: lower_left
54
+
55
+ copyright:
56
+ x: 75
57
+ y: 1025
58
+ width: 675
59
+ height: 25
60
+ font_size: 16
61
+ align: center
62
+ valign: bottom
63
+ #aliases for copyright
64
+ copy:
65
+ extends: copyright
66
+ credit:
67
+ extends: copyright
68
+ credits:
69
+ extends: copyright
70
+
71
+ # The "cut line", without rounded corners
72
+ cut:
73
+ x: 37.5
74
+ y: 37.5
75
+ width: 750
76
+ height: 1050
77
+
78
+ # The "safe zone" as defined by TheGameCrafter poker cards
79
+ safe:
80
+ x: 75
81
+ y: 75
82
+ width: 675
83
+ height: 975
84
+ radius: 16
85
+ dash: 3 3
@@ -0,0 +1,101 @@
1
+ #This layout inspired by popular fantasy games
2
+ title:
3
+ x: 90
4
+ y: 90
5
+ width: 500
6
+ height: 50
7
+
8
+ upper_right:
9
+ x: 595
10
+ y: 90
11
+ width: 135
12
+ height: 50
13
+ align: right
14
+ ur: # alias
15
+ extends: upper_right
16
+
17
+ art:
18
+ x: 75
19
+ y: 150
20
+ width: 675
21
+ height: 520
22
+
23
+ type:
24
+ x: 90
25
+ y: 675
26
+ width: 500
27
+ height: 50
28
+
29
+ type_right:
30
+ x: 595
31
+ y: 675
32
+ width: 135
33
+ height: 50
34
+ align: right
35
+ tr: #alias
36
+ extends: type_right
37
+
38
+ description:
39
+ x: 100
40
+ y: 730
41
+ width: 625
42
+ height: 275
43
+ valign: middle
44
+ align: center
45
+ font_size: 18
46
+ desc: # alias
47
+ extends: description
48
+
49
+ lower_right:
50
+ x: 675
51
+ y: 975
52
+ width: 75
53
+ height: 75
54
+ font_size: 18
55
+ valign: bottom
56
+ align: right
57
+ lr: #alias
58
+ extends: lower_right
59
+
60
+ lower_left:
61
+ x: 75
62
+ y: 975
63
+ width: 75
64
+ height: 75
65
+ font_size: 18
66
+ valign: bottom
67
+ align: left
68
+ ll: # alias
69
+ extends: lower_left
70
+
71
+ copyright:
72
+ x: 75
73
+ y: 1025
74
+ width: 675
75
+ height: 25
76
+ font_size: 16
77
+ align: center
78
+ valign: bottom
79
+ #aliases for copyright
80
+ copy:
81
+ extends: copyright
82
+ credit:
83
+ extends: copyright
84
+ credits:
85
+ extends: copyright
86
+
87
+ # The "cut line", without rounded corners
88
+ cut:
89
+ x: 37.5
90
+ y: 37.5
91
+ width: 750
92
+ height: 1050
93
+
94
+ # The "safe zone" as defined by TheGameCrafter poker cards
95
+ safe:
96
+ x: 75
97
+ y: 75
98
+ width: 675
99
+ height: 975
100
+ radius: 16
101
+ dash: 3 3
@@ -1,46 +1,62 @@
1
- # A layout designed for a card to be held in your hand.
2
- # * Bonuses align along the left-hand side.
3
- # * Title along the top.
4
- # * Middle area for artwork,
5
- # * Room for a text description
6
- # * And some theme-based text (which I like call the "snark")
7
- # Along the lines of Race for the Galaxy or 7 Wonders
8
- # Based on TheGameCrafter.com's Poker Card, which is 825x1125
9
- # Sample usage is found in samples/layouts.rb
10
- title:
11
- x: 275
12
- y: 75
13
- width: 475
14
- height: 125
15
- art:
16
- x: 275
17
- y: 225
18
- width: 475
19
- height: 475
20
- description:
21
- x: 275
22
- y: 725
23
- width: 475
24
- height: 200
25
- snark:
26
- x: 275
27
- y: 950
28
- width: 475
29
- height: 100
30
- bonus1:
31
- x: 75
32
- y: 75
33
- width: 175
34
- height: 175
35
- bonus2:
36
- extends: bonus1
37
- y: += 198
38
- bonus3:
39
- extends: bonus2
40
- y: += 198
41
- bonus4:
42
- extends: bonus3
43
- y: += 198
44
- bonus5:
45
- extends: bonus4
46
- y: += 198
1
+ # A layout designed for a card to be held in your hand.
2
+ # * Bonuses align along the left-hand side.
3
+ # * Title along the top.
4
+ # * Middle area for artwork,
5
+ # * Room for a text description
6
+ # * And some theme-based text (which I like call the "snark")
7
+ # Along the lines of Race for the Galaxy or 7 Wonders
8
+ # Based on TheGameCrafter.com's Poker Card, which is 825x1125
9
+ # Sample usage is found in samples/layouts.rb
10
+ title:
11
+ x: 275
12
+ y: 75
13
+ width: 475
14
+ height: 125
15
+ art:
16
+ x: 275
17
+ y: 225
18
+ width: 475
19
+ height: 475
20
+ description:
21
+ x: 275
22
+ y: 725
23
+ width: 475
24
+ height: 200
25
+ snark:
26
+ x: 275
27
+ y: 950
28
+ width: 475
29
+ height: 100
30
+ bonus1:
31
+ x: 75
32
+ y: 75
33
+ width: 175
34
+ height: 175
35
+ bonus2:
36
+ extends: bonus1
37
+ y: += 198
38
+ bonus3:
39
+ extends: bonus2
40
+ y: += 198
41
+ bonus4:
42
+ extends: bonus3
43
+ y: += 198
44
+ bonus5:
45
+ extends: bonus4
46
+ y: += 198
47
+
48
+ # The "cut line", without rounded corners
49
+ cut:
50
+ x: 37.5
51
+ y: 37.5
52
+ width: 750
53
+ height: 1050
54
+
55
+ # The "safe zone" as defined by TheGameCrafter poker cards
56
+ safe:
57
+ x: 75
58
+ y: 75
59
+ width: 675
60
+ height: 975
61
+ radius: 16
62
+ dash: 3 3
@@ -1,18 +1,35 @@
1
- # A basic playing card layout with bonuses in the upper-left and lower-right. The lower-right angle is rotated for text.
2
- bonus_ul:
3
- x: 75
4
- y: 75
5
- width: 200
6
- height: 200
7
- bonus_lr:
8
- extends: bonus_ul
9
- x: 750
10
- y: 1050
11
- angle: 3.14159
12
- art:
13
- x: 150
14
- y: 275
15
- width: 525
16
- height: 575
17
- valign: middle
18
- align: center
1
+ # A basic playing card layout with bonuses in the upper-left and lower-right.
2
+ # The lower-right angle is rotated for text.
3
+ bonus_ul:
4
+ x: 75
5
+ y: 75
6
+ width: 200
7
+ height: 200
8
+ bonus_lr:
9
+ extends: bonus_ul
10
+ x: 750
11
+ y: 1050
12
+ angle: 3.14159
13
+ art:
14
+ x: 150
15
+ y: 275
16
+ width: 525
17
+ height: 575
18
+ valign: middle
19
+ align: center
20
+
21
+ # The "cut line", without rounded corners
22
+ cut:
23
+ x: 37.5
24
+ y: 37.5
25
+ width: 750
26
+ height: 1050
27
+
28
+ # The "safe zone" as defined by TheGameCrafter poker cards
29
+ safe:
30
+ x: 75
31
+ y: 75
32
+ width: 675
33
+ height: 975
34
+ radius: 16
35
+ dash: 3 3
@@ -1,40 +1,45 @@
1
- # Settings in the config.yml are overriding Squib's defaults. Anything in the main script will override this.
2
-
3
- # DPI is used in making PDFs and in unit conversions
4
- # Default: 300
5
- #dpi: 72
6
-
7
- #antialias: best #recommended. Only about 10% slower than fast
8
- #antialias: default # set the anti-aliasing algorithm. default defers to the underlying graphics device. See http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t
9
-
10
- # Text hints are used to show the boundaries of text boxes.
11
- # Can be enabled/disabled at the command-level, or set globally with `set`
12
- #text_hint: '#F00'
13
-
14
- # Show progress bars on the command line for potentially long-running operations
15
- #progress_bars: true
16
-
17
- #Enable some custom colors that can be used in any color
18
- #custom_colors:
19
- # foo: '#abc'
20
-
21
- #For reading image file command (e.g. png and svg), read from this directory instead
22
- #img_dir: img-color
23
- #img_dir: img-bw
24
-
25
- # Use a SVG cairo back end, instead of an in-memory buffer
26
- # backend: :memory # default
27
- # backend: :svg # can create scalable pdfs, but rendering done at the printer level is not as good as Cairo.
28
-
29
- # Configure what text markup uses replace characters
30
- # Below are the defaults
31
- # lsquote: "\u2018" #note that Yaml wants double quotes here to use escape chars
32
- # rsquote: "\u2019"
33
- # ldquote: "\u201C"
34
- # rdquote: "\u201D"
35
- # em_dash: "\u2014"
36
- # en_dash: "\u2013"
37
- # ellipsis: "\u2026"
38
-
39
- # We can also disallow smart quotes and only allow explicit replacements with ``LaTeX-style'' quotes.
40
- # smart_quotes: false
1
+ # Settings in the config.yml are overriding Squib's defaults. Anything in the main script will override this.
2
+
3
+ # DPI is used in making PDFs and in unit conversions
4
+ # Default: 300
5
+ #dpi: 72
6
+
7
+ #antialias: best #recommended. Only about 10% slower than fast
8
+ #antialias: default # set the anti-aliasing algorithm. default defers to the underlying graphics device. See http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t
9
+
10
+ # Text hints are used to show the boundaries of text boxes.
11
+ # Can be enabled/disabled at the command-level, or set globally with `set`
12
+ #text_hint: '#F00'
13
+
14
+ # Show progress bars on the command line for potentially long-running operations
15
+ #progress_bars: true
16
+
17
+ #Enable some custom colors that can be used in any color
18
+ #custom_colors:
19
+ # foo: '#abc'
20
+
21
+ #For reading image file command (e.g. png and svg), read from this directory instead
22
+ #img_dir: img-color
23
+ #img_dir: img-bw
24
+
25
+ # Use a SVG cairo back end, instead of an in-memory buffer
26
+ # backend: :memory # default
27
+ # backend: :svg # can create scalable pdfs, but rendering done at the printer level is not as good as Cairo.
28
+
29
+ # Configure what text markup uses replace characters
30
+ # Below are the defaults
31
+ # lsquote: "\u2018" #note that Yaml wants double quotes here to use escape chars
32
+ # rsquote: "\u2019"
33
+ # ldquote: "\u201C"
34
+ # rdquote: "\u201D"
35
+ # em_dash: "\u2014"
36
+ # en_dash: "\u2013"
37
+ # ellipsis: "\u2026"
38
+
39
+ # We can also disallow smart quotes and only allow explicit replacements with ``LaTeX-style'' quotes.
40
+ # smart_quotes: false
41
+
42
+ # By default, Squib warns when a text box is ellipsized. This can get verbose
43
+ # and can be turned off here
44
+ # warn_ellipsize: true # default
45
+ # warn_ellipsize: false # default
@@ -1,10 +1,10 @@
1
- module Squib
2
-
3
- # The next version to be released.
4
- # Uses semantic versioning: http://semver.org/
5
- #
6
- # Most of the time this is in the alpha of the next release.
7
- # e.g. v0.0.5a is on its way to becoming v0.0.5
8
- #
9
- VERSION = '0.6.0'
10
- end
1
+ module Squib
2
+
3
+ # The next version to be released.
4
+ # Uses semantic versioning: http://semver.org/
5
+ #
6
+ # Most of the time this is in the alpha of the next release.
7
+ # e.g. v0.0.5a is on its way to becoming v0.0.5
8
+ #
9
+ VERSION = '0.7.0'
10
+ end