squib 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +29 -29
  3. data/.travis.yml +6 -6
  4. data/.yardopts +7 -5
  5. data/Gemfile +2 -2
  6. data/LICENSE.txt +22 -22
  7. data/README.md +245 -92
  8. data/Rakefile +11 -11
  9. data/bin/squib +18 -18
  10. data/lib/squib.rb +31 -18
  11. data/lib/squib/api/background.rb +18 -16
  12. data/lib/squib/api/data.rb +52 -52
  13. data/lib/squib/api/image.rb +66 -48
  14. data/lib/squib/api/save.rb +43 -37
  15. data/lib/squib/api/settings.rb +38 -35
  16. data/lib/squib/api/shapes.rb +116 -106
  17. data/lib/squib/api/text.rb +50 -45
  18. data/lib/squib/api/units.rb +16 -16
  19. data/lib/squib/card.rb +42 -36
  20. data/lib/squib/commands/new.rb +43 -39
  21. data/lib/squib/constants.rb +104 -39
  22. data/lib/squib/deck.rb +116 -113
  23. data/lib/squib/graphics/background.rb +13 -12
  24. data/lib/squib/graphics/image.rb +47 -28
  25. data/lib/squib/graphics/save_doc.rb +54 -50
  26. data/lib/squib/graphics/save_images.rb +32 -10
  27. data/lib/squib/graphics/shapes.rb +59 -55
  28. data/lib/squib/graphics/text.rb +113 -107
  29. data/lib/squib/input_helpers.rb +193 -139
  30. data/lib/squib/progress.rb +38 -0
  31. data/lib/squib/project_template/.gitignore +4 -3
  32. data/lib/squib/project_template/ABOUT.md +19 -19
  33. data/lib/squib/project_template/Gemfile +2 -2
  34. data/lib/squib/project_template/PNP NOTES.md +3 -3
  35. data/lib/squib/project_template/config.yml +20 -2
  36. data/lib/squib/project_template/deck.rb +5 -5
  37. data/lib/squib/version.rb +6 -6
  38. data/samples/ball.png +0 -0
  39. data/samples/basic.rb +19 -19
  40. data/samples/colors.rb +15 -16
  41. data/samples/custom-config.yml +6 -1
  42. data/samples/custom-layout.yml +39 -34
  43. data/samples/custom_config.rb +18 -5
  44. data/samples/customconfig-imgdir/shiny-purse2.png +0 -0
  45. data/samples/customconfig-imgdir/spanner2.svg +91 -0
  46. data/samples/draw_shapes.rb +18 -18
  47. data/samples/excel.rb +19 -19
  48. data/samples/grit.png +0 -0
  49. data/samples/hello_world.rb +6 -6
  50. data/samples/load_images.rb +29 -19
  51. data/samples/offset.svg +71 -0
  52. data/samples/portrait-landscape.rb +23 -0
  53. data/samples/ranges.rb +55 -47
  54. data/samples/save_pdf.rb +14 -14
  55. data/samples/shiny-purse.png +0 -0
  56. data/samples/spanner.svg +91 -91
  57. data/samples/text_options.rb +60 -58
  58. data/samples/tgc_proofs.rb +19 -19
  59. data/samples/units.rb +12 -12
  60. data/samples/use_layout.rb +28 -28
  61. data/spec/api/api_text_spec.rb +42 -36
  62. data/spec/commands/new_spec.rb +47 -47
  63. data/spec/data/multi-extends-single-entry.yml +13 -0
  64. data/spec/data/multi-level-extends.yml +10 -0
  65. data/spec/data/no-extends.yml +5 -0
  66. data/spec/data/single-extends.yml +7 -0
  67. data/spec/data/single-level-multi-extends.yml +12 -0
  68. data/spec/deck_spec.rb +147 -49
  69. data/spec/input_helpers_spec.rb +117 -0
  70. data/spec/samples_run_spec.rb +19 -14
  71. data/spec/spec_helper.rb +3 -0
  72. data/squib.gemspec +46 -42
  73. metadata +78 -4
  74. data/API.md +0 -59
@@ -1,6 +1,6 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(cards: 3) do
4
- text str: "Hello, World!"
5
- save format: :png
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(cards: 3, layout: 'layout.yml') do
4
+ text str: "Hello, World!"
5
+ save format: :png
6
6
  end
@@ -1,6 +1,6 @@
1
- module Squib
2
-
3
- # The next version to be released.
4
- # Uses semantic versioning
5
- VERSION = "0.0.2"
6
- end
1
+ module Squib
2
+
3
+ # The next version to be released.
4
+ # Uses semantic versioning
5
+ VERSION = "0.0.3"
6
+ end
Binary file
@@ -1,20 +1,20 @@
1
- #!/usr/bin/env ruby
2
- require 'squib'
3
-
4
- data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
5
- 'level' => [1,2,3]}
6
-
7
- Squib::Deck.new(width: 825, height: 1125, cards: 3) do
8
- background color: :white
9
- rect x: 38, y: 38, width: 750, height: 1050, radius: 38
10
- rect x: 75, y: 75, width: 128, height: 128, radius: 25
11
-
12
- text str: data['name'], x: 220, y: 78, font: 'Arial 54'
13
- text str: data['level'], x: 75, y: 85, width: 128,
14
- font: 'Arial 72', align: :center
15
-
16
- png range: [0,2], file: 'shiny-purse.png', x: 620, y: 75
17
- svg range: 1..2, file: 'spanner.svg', x: 620, y: 218
18
-
19
- save prefix: 'basic_', format: :png
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
5
+ 'level' => [1,2,3]}
6
+
7
+ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
8
+ background color: :white
9
+ rect x: 38, y: 38, width: 750, height: 1050, radius: 38
10
+ rect x: 75, y: 75, width: 128, height: 128, radius: 25
11
+
12
+ text str: data['name'], x: 220, y: 78, font: 'Arial 54'
13
+ text str: data['level'], x: 75, y: 85, width: 128,
14
+ font: 'Arial 72', align: :center
15
+
16
+ png range: [0,2], file: 'shiny-purse.png', x: 620, y: 75
17
+ svg range: 1..2, file: 'spanner.svg', x: 620, y: 218
18
+
19
+ save prefix: 'basic_', format: :png#, progress_bar: true
20
20
  end
@@ -1,17 +1,16 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(width: 825, height: 1125, cards: 1) do
4
- background color: :white
5
-
6
- y = 0
7
- text color: '#f00', str: '3-hex', x: 50, y: y+=50
8
- text color: '#f00', str: '3-hex (alpha)', x: 50, y: y+=50
9
- text color: '#ff0000', str: '6-hex', x: 50, y: y+=50
10
- text color: '#ff000099', str: '8-hex(alpha) *', x: 50, y: y+=50
11
- text color: '#ffff00000000', str: '12-hex', x: 50, y: y+=50
12
- text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y+=50
13
- text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y+=50
14
- text color: [1.0, 0.0, 0.0], str: 'Array of percentages', x: 50, y: y+=50
15
-
16
- save_png prefix: "colors_"
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: 825, height: 1125, cards: 1) do
4
+ background color: :white
5
+
6
+ y = 0
7
+ text color: '#f00', str: '3-hex', x: 50, y: y+=50
8
+ text color: '#f00', str: '3-hex (alpha)', x: 50, y: y+=50
9
+ text color: '#ff0000', str: '6-hex', x: 50, y: y+=50
10
+ text color: '#ff000099', str: '8-hex(alpha) *', x: 50, y: y+=50
11
+ text color: '#ffff00000000', str: '12-hex', x: 50, y: y+=50
12
+ text color: '#ffff000000009999', str: '12-hex (alpha)', x: 50, y: y+=50
13
+ text color: :burnt_orange, str: 'Symbols of constants too', x: 50, y: y+=50
14
+
15
+ save_png prefix: "colors_"
17
16
  end
@@ -1 +1,6 @@
1
- dpi: 300
1
+ dpi: 300
2
+ progress_bars: true
3
+ text_hint: '#FF0000'
4
+ custom_colors:
5
+ foo: '#ccc'
6
+ img_dir: customconfig-imgdir
@@ -1,34 +1,39 @@
1
- frame:
2
- x: 38
3
- y: 38
4
- width: 750
5
- height: 1050
6
- radius: 25
7
- title:
8
- x: 125
9
- y: 50
10
- width: 625
11
- height: 100
12
- align: !ruby/symbol center #see http://www.yaml.org/YAML_for_ruby.html#symbols
13
- valign: !ruby/symbol middle
14
- subtitle:
15
- x: 150
16
- y: 150
17
- width: 575
18
- height: 60
19
- align: !ruby/symbol center
20
- valign: !ruby/symbol middle
21
- icon:
22
- width: 125
23
- height: 125
24
- y: 250
25
- icon_left:
26
- extends: icon
27
- x: 150
28
- icon_middle:
29
- extends: icon
30
- x: 350
31
- y: 400 #overrides the y inherited from icon
32
- icon_right:
33
- extends: icon
34
- x: 550
1
+ frame:
2
+ x: 38
3
+ y: 38
4
+ width: 750
5
+ height: 1050
6
+ radius: 25
7
+ title:
8
+ x: 125
9
+ y: 50
10
+ width: 625
11
+ height: 100
12
+ align: !ruby/symbol center #see http://www.yaml.org/YAML_for_ruby.html#symbols
13
+ valign: !ruby/symbol middle
14
+ subtitle:
15
+ x: 150
16
+ y: 150
17
+ width: 575
18
+ height: 60
19
+ align: !ruby/symbol center
20
+ valign: !ruby/symbol middle
21
+
22
+ # Yaml has this beautfiul feature for us: merge keys
23
+ # http://www.yaml.org/YAML_for_ruby.html#merge_key
24
+ # Define an alias with &foo, then use <<: *foo to include it
25
+ # Everything gets merged, with later merges overriding
26
+ icon: &icon
27
+ width: 125
28
+ height: 125
29
+ y: 250
30
+ icon_left:
31
+ <<: *icon
32
+ x: 150
33
+ icon_middle:
34
+ <<: *icon
35
+ x: 350
36
+ y: 400 #overrides the y inherited from icon
37
+ icon_right:
38
+ <<: *icon
39
+ x: 550
@@ -1,6 +1,19 @@
1
- #!/usr/bin/env ruby
2
- require 'squib'
3
-
4
- Squib::Deck.new(config: 'custom-config.yml') do
5
-
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ Squib::Deck.new(config: 'custom-config.yml') do
5
+ # Custom color defined in our config
6
+ background color: :foo
7
+
8
+ # Hints are turned on in the config file
9
+ text str: "The Title", x: 0, y: 78, width: 825,
10
+ font: 'Arial 72', align: :center
11
+
12
+ # Progress bars are shown for these commands
13
+ # And images are taken from config-imgdir
14
+ png file: 'shiny-purse2.png', x: 620, y: 75
15
+ svg file: 'spanner2.svg', x: 620, y: 218
16
+ save_png prefix: 'custom-config_'
17
+ save_pdf file: "custom-config-out.pdf"
18
+
6
19
  end
@@ -0,0 +1,91 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://creativecommons.org/ns#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10
+ viewBox="0 0 128 128"
11
+ id="svg2"
12
+ version="1.1"
13
+ inkscape:version="0.48.3.1 r9886"
14
+ width="100%"
15
+ height="100%"
16
+ sodipodi:docname="spanner.svg">
17
+ <metadata
18
+ id="metadata18">
19
+ <rdf:RDF>
20
+ <cc:Work
21
+ rdf:about="">
22
+ <dc:format>image/svg+xml</dc:format>
23
+ <dc:type
24
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
25
+ </cc:Work>
26
+ </rdf:RDF>
27
+ </metadata>
28
+ <defs
29
+ id="defs16" />
30
+ <sodipodi:namedview
31
+ pagecolor="#ffffff"
32
+ bordercolor="#666666"
33
+ borderopacity="1"
34
+ objecttolerance="10"
35
+ gridtolerance="10"
36
+ guidetolerance="10"
37
+ inkscape:pageopacity="0"
38
+ inkscape:pageshadow="2"
39
+ inkscape:window-width="1280"
40
+ inkscape:window-height="1002"
41
+ id="namedview14"
42
+ showgrid="false"
43
+ inkscape:zoom="2.8284271"
44
+ inkscape:cx="98.928938"
45
+ inkscape:cy="62.194589"
46
+ inkscape:window-x="1912"
47
+ inkscape:window-y="-8"
48
+ inkscape:window-maximized="1"
49
+ inkscape:current-layer="g3767"
50
+ inkscape:document-units="in"
51
+ units="px"
52
+ showguides="true"
53
+ inkscape:guide-bbox="true" />
54
+ <g
55
+ id="g3767"
56
+ transform="matrix(0.24961486,0,0,0.24961486,0.197194,96.049335)">
57
+ <rect
58
+ ry="67.108368"
59
+ y="-378.68747"
60
+ x="5.3126979"
61
+ height="501.3746"
62
+ width="501.3746"
63
+ id="backdrop"
64
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:10.62539577;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0"
65
+ inkscape:label="#rect3765" />
66
+ <path
67
+ style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
68
+ d="M 36.267098,-7.709219 C 16.393265,5.1318032 3.2161811,27.462365 3.2161811,52.884128 c 0,39.825874 32.2852369,72.111092 72.1110909,72.111092 23.870397,0 44.964938,-11.67699 58.089488,-29.545518 -11.26063,7.275808 -24.65607,11.517748 -39.060173,11.517748 -39.825853,0 -72.11109,-32.285221 -72.11109,-72.111095 0,-15.95546 5.248882,-30.6218942 14.021601,-42.565574 z"
69
+ id="path3790"
70
+ inkscape:connector-curvature="0" />
71
+ <g
72
+ id="g6"
73
+ transform="matrix(18.68858,0,0,18.68858,-3385.6437,-2608.3849)">
74
+ <path
75
+ style="fill:#ffffff"
76
+ inkscape:connector-curvature="0"
77
+ id="path8"
78
+ d="m 192.2325,129.3203 -10,10 v 5.5625 h 5.375 l 10.0938,-10.0938 -5.4688,-5.4688 z" />
79
+ <path
80
+ style="fill:#ffffff;stroke:#000000"
81
+ inkscape:connector-curvature="0"
82
+ id="path10"
83
+ d="m 181.7796,141.8591 15.6196,-15.6178 m 3.349,3.3486 -15.8051,15.8032" />
84
+ <path
85
+ style="fill:#ffffff"
86
+ inkscape:connector-curvature="0"
87
+ id="path12"
88
+ d="m 201.2023,119.7104 c -2.8283,-0.73 -5.9623,-0.004 -8.1759,2.2097 -3.3293,3.3292 -3.3293,8.7358 -2e-5,12.065 3.32928,3.3292 8.7358,3.3292 12.065,0 2.216,-2.216 2.9436,-5.3452 2.2097,-8.1759 l -5.6348,5.6348 -4.8172,-1.2816 -1.2816,-4.8171 5.6348,-5.6348 z" />
89
+ </g>
90
+ </g>
91
+ </svg>
@@ -1,19 +1,19 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new do
4
- rect x: 300, y: 300, width: 400, height: 400,
5
- fill_color: :blue, stroke_color: :red, stroke_width: 50.0
6
-
7
- circle x: 600, y: 600, radius: 75,
8
- fill_color: :gray, stroke_color: :green, stroke_width: 8.0
9
-
10
- triangle x1: 50, y1: 50,
11
- x2: 150, y2: 150,
12
- x3: 75, y3: 250
13
-
14
- line x1: 50, y1: 550,
15
- x2: 150, y2: 650,
16
- stroke_width: 25.0
17
-
18
- save_png prefix: 'shape_'
1
+ require 'squib'
2
+
3
+ Squib::Deck.new do
4
+ rect x: 300, y: 300, width: 400, height: 400,
5
+ fill_color: :blue, stroke_color: :red, stroke_width: 50.0
6
+
7
+ circle x: 600, y: 600, radius: 75,
8
+ fill_color: :gray, stroke_color: :green, stroke_width: 8.0
9
+
10
+ triangle x1: 50, y1: 50,
11
+ x2: 150, y2: 150,
12
+ x3: 75, y3: 250
13
+
14
+ line x1: 50, y1: 550,
15
+ x2: 150, y2: 650,
16
+ stroke_width: 25.0
17
+
18
+ save_png prefix: 'shape_'
19
19
  end
@@ -1,19 +1,19 @@
1
- #!/usr/bin/env ruby
2
- require 'squib'
3
-
4
- Squib::Deck.new(width: 825, height: 1125, cards: 3) do
5
- background color: :white
6
-
7
- # Takes the first sheet by default
8
- # Outputs a hash of arrays with the header names as keys
9
- data = xlsx file: 'sample.xlsx'
10
-
11
- text str: data['Name'], x: 250, y: 55, font: 'Arial 54'
12
- text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
13
- text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
14
-
15
- # You can also specify the sheet, starting at 0
16
- data = xlsx file: 'sample.xlsx', sheet: 2
17
-
18
- save format: :png, prefix: 'sample_excel_'
19
- end
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
5
+ background color: :white
6
+
7
+ # Takes the first sheet by default
8
+ # Outputs a hash of arrays with the header names as keys
9
+ data = xlsx file: 'sample.xlsx'
10
+
11
+ text str: data['Name'], x: 250, y: 55, font: 'Arial 54'
12
+ text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
13
+ text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
14
+
15
+ # You can also specify the sheet, starting at 0
16
+ data = xlsx file: 'sample.xlsx', sheet: 2
17
+
18
+ save format: :png, prefix: 'sample_excel_'
19
+ end
Binary file
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env ruby
2
- require 'squib'
3
-
4
- Squib::Deck.new do
5
- text str: 'Hello, World!'
6
- save_png
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ Squib::Deck.new do
5
+ text str: 'Hello, World!'
6
+ save_png
7
7
  end
@@ -1,19 +1,29 @@
1
- require 'squib'
2
-
3
- Squib::Deck.new(width: 825, height: 1125, cards: 1) do
4
- background color: :white
5
- rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
6
-
7
- png file: 'shiny-purse.png', x: 620, y: 75
8
- svg file: 'spanner.svg', x: 620, y: 218
9
-
10
- # SVGs can be scaled too
11
- svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
12
-
13
- # We can also limit our rendering to a single object, if the SVG ID is set
14
- # Squib prepends a #-sign if one is not specified
15
- svg file: 'spanner.svg', id: '#backdrop', x: 50, y: 350, width: 75, height: 75
16
- svg file: 'spanner.svg', id: 'backdrop', x: 50, y: 450, width: 125, height: 125
17
-
18
- save prefix: 'load_images_', format: :png
19
- end
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: 825, height: 1125, cards: 1) do
4
+ background color: '#0b7c8e'
5
+ rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
6
+
7
+ png file: 'shiny-purse.png', x: 620, y: 75
8
+ svg file: 'spanner.svg', x: 620, y: 218
9
+
10
+ # SVGs can be scaled too
11
+ svg file: 'spanner.svg', x: 50, y: 50, width: 250, height: 250
12
+
13
+ # We can also limit our rendering to a single object, if the SVG ID is set
14
+ # Squib prepends a #-sign if one is not specified
15
+ svg file: 'spanner.svg', id: '#backdrop', x: 50, y: 350, width: 75, height: 75
16
+ svg file: 'spanner.svg', id: 'backdrop', x: 50, y: 450, width: 125, height: 125
17
+
18
+ # WARNING! If you choose to use the SVG ID, the x-y coordinates are still
19
+ # relative to the SVG page. See this example in an SVG editor
20
+ svg file: 'offset.svg', id: 'thing', x: 0, y: 0, width: 600, height: 600
21
+
22
+ # Over 15 different blending operators are supported.
23
+ # See http://cairographics.org/operators
24
+ # Alpha transparency too
25
+ png file: 'ball.png', x: 50, y: 700
26
+ png file: 'grit.png', x: 70, y: 750, blend: :color_burn, alpha: 0.75
27
+
28
+ save prefix: 'load_images_', format: :png
29
+ end