squib 0.0.1 → 0.0.2

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +29 -26
  3. data/.travis.yml +6 -4
  4. data/.yardopts +6 -0
  5. data/API.md +59 -0
  6. data/Gemfile +2 -2
  7. data/LICENSE.txt +22 -22
  8. data/README.md +92 -55
  9. data/Rakefile +11 -6
  10. data/bin/squib +19 -2
  11. data/lib/squib/api/background.rb +16 -11
  12. data/lib/squib/api/data.rb +52 -29
  13. data/lib/squib/api/image.rb +48 -10
  14. data/lib/squib/api/save.rb +36 -15
  15. data/lib/squib/api/settings.rb +35 -0
  16. data/lib/squib/api/shapes.rb +106 -12
  17. data/lib/squib/api/text.rb +45 -25
  18. data/lib/squib/api/units.rb +17 -0
  19. data/lib/squib/card.rb +36 -27
  20. data/lib/squib/commands/new.rb +40 -0
  21. data/lib/squib/constants.rb +40 -0
  22. data/lib/squib/deck.rb +113 -48
  23. data/lib/squib/graphics/background.rb +12 -10
  24. data/lib/squib/graphics/image.rb +28 -12
  25. data/lib/squib/graphics/save_doc.rb +50 -21
  26. data/lib/squib/graphics/save_images.rb +10 -8
  27. data/lib/squib/graphics/shapes.rb +55 -11
  28. data/lib/squib/graphics/text.rb +107 -27
  29. data/lib/squib/input_helpers.rb +140 -0
  30. data/lib/squib/project_template/.gitignore +3 -0
  31. data/lib/squib/project_template/ABOUT.md +19 -0
  32. data/lib/squib/project_template/Gemfile +3 -0
  33. data/lib/squib/project_template/PNP NOTES.md +4 -0
  34. data/lib/squib/project_template/_output/gitkeep.txt +1 -0
  35. data/lib/squib/project_template/config.yml +2 -0
  36. data/lib/squib/project_template/deck.rb +6 -0
  37. data/lib/squib/project_template/layout.yml +0 -0
  38. data/lib/squib/version.rb +6 -3
  39. data/lib/squib.rb +19 -2
  40. data/samples/_output/gitkeep.txt +0 -0
  41. data/samples/basic.rb +20 -22
  42. data/samples/colors.rb +17 -0
  43. data/samples/custom-config.yml +1 -0
  44. data/samples/custom-layout.yml +34 -0
  45. data/samples/custom_config.rb +6 -0
  46. data/samples/draw_shapes.rb +19 -0
  47. data/samples/excel.rb +19 -16
  48. data/samples/hello_world.rb +7 -0
  49. data/samples/load_images.rb +19 -0
  50. data/samples/pokercard.png +0 -0
  51. data/samples/ranges.rb +47 -0
  52. data/samples/sample.xlsx +0 -0
  53. data/samples/save_pdf.rb +14 -0
  54. data/samples/spanner.svg +91 -0
  55. data/samples/text_options.rb +58 -0
  56. data/samples/tgc_proofs.rb +20 -0
  57. data/samples/units.rb +12 -0
  58. data/samples/use_layout.rb +29 -0
  59. data/spec/api/api_text_spec.rb +37 -0
  60. data/spec/commands/new_spec.rb +48 -0
  61. data/spec/deck_spec.rb +49 -48
  62. data/spec/samples_run_spec.rb +15 -0
  63. data/spec/spec_helper.rb +9 -0
  64. data/squib.gemspec +42 -27
  65. metadata +109 -11
  66. data/samples/_output/watch.html +0 -25
data/samples/excel.rb CHANGED
@@ -1,16 +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: [1.0,1.0,1.0]
6
-
7
- data = xlsx file: 'sample.xlsx', sheet: 0
8
-
9
- text str: data['Name'], x: 250, y: 55, font: 'Arial 54'
10
- text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
11
- text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
12
-
13
- save format: :png, prefix: 'sample_excel_'
14
- end
15
-
16
- puts "Done!"
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
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ Squib::Deck.new do
5
+ text str: 'Hello, World!'
6
+ save_png
7
+ end
@@ -0,0 +1,19 @@
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
Binary file
data/samples/ranges.rb ADDED
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
5
+ 'type' => ['Thug', 'Thinker', 'Thinker'],
6
+ 'level' => [1,2,3]}
7
+
8
+ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
9
+ # Default range is :all
10
+ background color: :white
11
+ text str: data['name'], x: 250, y: 55, font: 'Arial 54'
12
+ text str: data['level'], x: 65, y: 40, font: 'Arial 72'
13
+
14
+ # Could be explicit about using :all, too
15
+ text range: :all,
16
+ str: data['type'], x: 40, y: 128, font: 'Arial 18',
17
+ width: 100, align: :center
18
+
19
+ # Ranges are inclusive, zero-based
20
+ text range: 0..1, str: "Thief and Grifter only!!", x: 25, y:200
21
+
22
+ # Integers are also allowed
23
+ text range: 0, str: "Thief only!", x: 25, y: 250
24
+
25
+ # Negatives go from the back of the deck
26
+ text range: -1, str: "Mastermind only!", x: 25, y: 250
27
+ text range: -2..-1, str: "Grifter and Mastermind only!", x: 25, y: 650
28
+
29
+ # We can use Arrays too!
30
+ text range: [0,2], str: "Thief and Mastermind only!!", x: 25, y:300
31
+
32
+ # Useful idiom: construct a hash from card names back to its index (ID),
33
+ # then use a range. No need to memorize IDs, and you can add cards easily
34
+ id = {} ; data['name'].each_with_index{ |name,i| id[name] = i}
35
+ text range: id['Thief']..id['Grifter'],
36
+ str: "Thief through Grifter with id lookup!!",
37
+ x:25, y: 400
38
+
39
+ # Useful idiom: generate arrays from a column called 'type'
40
+ type = {}; data['type'].each_with_index{ |t,i| (type[t] ||= []) << i}
41
+ text range: type['Thinker'],
42
+ str: "Only for Thinkers!",
43
+ x:25, y: 500
44
+
45
+ save prefix: 'ranges_', format: :png
46
+ end
47
+
data/samples/sample.xlsx CHANGED
Binary file
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ Squib::Deck.new(width: 825, height: 1125, cards: 16) do
5
+ background color: :gray
6
+ rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
7
+
8
+ text str: (1..16).to_a, x: 220, y: 78, font: 'Arial 54'
9
+
10
+ save_pdf file: "sample-save-pdf.pdf", margin: 75, gap: 5, trim: 37
11
+
12
+ #Note that our PNGs still are not trimmed even though the pdf ones are
13
+ save_png range: 1, prefix: "save_pdf_"
14
+ 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>
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ data = {'name' => ['Thief', 'Grifter', 'Mastermind'],
5
+ 'level' => [1,2,3]}
6
+ longtext = "This is left-justified text.\nWhat do you know about tweetle beetles? well... \nWhen tweetle beetles fight, it's called a tweetle beetle battle. And when they battle in a puddle, it's a tweetle beetle puddle battle. AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle. AND... When beetles battle beetles in a puddle paddle battle and the beetle battle puddle is a puddle in a bottle... ..they call this a tweetle beetle bottle puddle paddle battle muddle. AND... When beetles fight these battles in a bottle with their paddles and the bottle's on a poodle and the poodle's eating noodles... ...they call this a muddle puddle tweetle poodle beetle noodle bottle paddle battle."
7
+
8
+ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
9
+ background color: :white
10
+ rect x: 15, y: 15, width: 795, height: 1095, x_radius: 50, y_radius: 50
11
+ rect x: 30, y: 30, width: 128, height: 128, x_radius: 25, y_radius: 25
12
+
13
+ # Arrays are rendered over each card
14
+ text str: data['name'], x: 250, y: 55, font: 'Arial weight=900 54'
15
+ text str: data['level'], x: 65, y: 40, font: 'Arial 72', color: :burnt_orange
16
+
17
+ text str: "UTF-8 \u2663", x: 565, y: 150, font: 'Arial weight=900 36'
18
+
19
+ text str: "Font strings are expressive!", x:65, y: 200,
20
+ font: 'Impact bold italic 36'
21
+
22
+ text str: "Font strings are expressive!", x:65, y: 300,
23
+ font: 'Arial,Verdana weight=900 style=oblique 36'
24
+
25
+ text str: "This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint",
26
+ hint: :red,
27
+ x: 65, y: 400,
28
+ width: 300, height: 200,
29
+ align: :center, valign: :middle,
30
+ font: 'Arial 18'
31
+
32
+ text str: "Ellipsization!\nThe ultimate question of life, the universe, and everything to life and everything is 42",
33
+ hint: :green, font: 'Arial 22',
34
+ x: 450, y: 400,
35
+ width: 280, height: 180,
36
+ ellipsize: true
37
+
38
+ hint text: :cyan
39
+ text str: "Text hints are also globally togglable!",
40
+ x: 65, y: 625,
41
+ font: 'Arial 22'
42
+ hint text: nil
43
+ text str: "See? No hint here.",
44
+ x: 565, y: 625,
45
+ font: 'Arial 22'
46
+
47
+ text str: longtext, font: 'Arial 16',
48
+ x: 65, y: 700,
49
+ width: inches(2.25), height: inches(1),
50
+ justify: true
51
+
52
+ text str: "<b>Markup</b> is also <i>quite</i> <s>easy</s> awesome",
53
+ markup: true,
54
+ x: 50, y: 1000,
55
+ font: 'Arial 32'
56
+
57
+ save prefix: 'text_', format: :png
58
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ require 'squib'
3
+
4
+ # This sample uses a proof overlay from TheGameCrafter.com to check bleed
5
+ Squib::Deck.new(width: 825, height: 1125, cards: 1) do
6
+ background color: :white
7
+ rect x: 38, y: 38, width: 750, height: 1050, x_radius: 38, y_radius: 38
8
+ rect x: 75, y: 75, width: 128, height: 128, x_radius: 25, y_radius: 25
9
+
10
+ text str: 'Mastermind', x: 220, y: 78, font: 'Arial 54'
11
+ text str: 3, x: 75, y: 85, width: 128, font: 'Arial 72', align: :center
12
+
13
+ png file: 'shiny-purse.png', x: 620, y: 75
14
+ svg file: 'spanner.svg', x: 620, y: 218
15
+
16
+ # TGC proof overlay
17
+ png file: 'pokercard.png', x:0, y:0, alpha: 0.5
18
+
19
+ save_png prefix: 'tgc_sample_'
20
+ end
data/samples/units.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
4
+ background color: :white
5
+
6
+ bleed = inches(0.125)
7
+ cut_width = inches(2.5)
8
+ cut_height = inches(3.5)
9
+ rect x: bleed, y: bleed, width: cut_width, height: cut_height, radius: 25
10
+
11
+ save prefix: 'units_', format: :png
12
+ end
@@ -0,0 +1,29 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(layout: 'custom-layout.yml') do
4
+ background color: :white
5
+ hint text: :cyan
6
+
7
+ # Layouts are YAML files that specify any option as a default
8
+ rect layout: :frame
9
+
10
+ # You can also override a given layout entry in the command
11
+ circle layout: :frame, x: 50, y: 50, radius: 25
12
+
13
+ # Lots of commands have the :layout option
14
+ text str: 'The Title', layout: :title
15
+
16
+ # Layouts also support an "extends" attribute to reuse settings
17
+ svg file: 'spanner.svg', layout: :icon_left
18
+ png file: 'shiny-purse.png', layout: :icon_middle
19
+ svg file: 'spanner.svg', layout: :icon_right
20
+
21
+ # Strings can also be used to specify a layout (e.g. from a data file)
22
+ text str: 'subtitle', layout: 'subtitle'
23
+
24
+ # For debugging purposes, you can always print out the loaded layout
25
+ #require 'pp'
26
+ #pp @layout
27
+
28
+ save_png prefix: 'layout_'
29
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+ require 'squib'
3
+
4
+ describe Squib::Deck, '#text' do
5
+
6
+ context "when working with fonts" do
7
+ it"should use the default font when #text and #set_font don't specify" do
8
+ card = instance_double(Squib::Card)
9
+ expect(card).to receive(:text).with('a', 'Arial 36', anything, anything, anything, anything).once
10
+ Squib::Deck.new do
11
+ @cards = [card]
12
+ text str: 'a'
13
+ end
14
+ end
15
+
16
+ it "should use the #set_font when #text doesn't specify" do
17
+ card = instance_double(Squib::Card)
18
+ expect(card).to receive(:text).with('a', 'Times New Roman 16', anything, anything, anything, anything).once
19
+ Squib::Deck.new do
20
+ @cards = [card]
21
+ set font: 'Times New Roman 16'
22
+ text str: 'a'
23
+ end
24
+ end
25
+
26
+ it "should use the specified font no matter what" do
27
+ card = instance_double(Squib::Card)
28
+ expect(card).to receive(:text).with('a', 'Arial 18', anything, anything, anything, anything).once
29
+ Squib::Deck.new do
30
+ @cards = [card]
31
+ set font: 'Times New Roman 16'
32
+ text str: 'a', font: 'Arial 18'
33
+ end
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+ require 'squib'
3
+
4
+ describe Squib::Commands::New do
5
+
6
+ describe "#process" do
7
+ before(:all) do
8
+ @old_stderr = $stderr
9
+ $stderr = StringIO.new
10
+ @oldpwd = Dir.pwd
11
+ Dir.chdir(File.expand_path('../../samples/_output', File.dirname(__FILE__)))
12
+ end
13
+
14
+ before(:each) do
15
+ FileUtils.rm_rf('foo', secure: true)
16
+ @cmd = Squib::Commands::New.new
17
+ end
18
+
19
+ it "raises an error if no directory was specified" do
20
+ expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.')
21
+ end
22
+
23
+ it "creates a new template on an fresh directory" do
24
+ @cmd.process(['foo'])
25
+ expect(File.exists?('foo/deck.rb')).to be true
26
+ end
27
+
28
+ it "creates a new template on an empty directory" do
29
+ Dir.mkdir('foo')
30
+ @cmd.process(['foo'])
31
+ expect(File.exists?('foo/deck.rb')).to be true
32
+ end
33
+
34
+ it "does not create a new template on an empty " do
35
+ Dir.mkdir('foo')
36
+ File.new('foo/somefile.txt', 'w+')
37
+ @cmd.process(['foo'])
38
+ $stderr.rewind
39
+ expect($stderr.string.chomp).to end_with " exists and is not empty. Doing nothing and quitting."
40
+ end
41
+
42
+ after(:all) do
43
+ $stderr = @old_stderr
44
+ Dir.chdir(@oldpwd)
45
+ end
46
+ end
47
+
48
+ end
data/spec/deck_spec.rb CHANGED
@@ -1,48 +1,49 @@
1
- require 'squib/deck'
2
-
3
- describe Squib::Deck do
4
-
5
- it "initializes with default parameters" do
6
- d = Squib::Deck.new
7
- expect(d.width).to eq(825)
8
- expect(d.height).to eq(1125)
9
- expect(d.cards.size).to eq(1)
10
- end
11
-
12
- context "in dealing with ranges" do
13
- it "calls text on all cards by default" do
14
- card1 = instance_double(Squib::Card)
15
- card2 = instance_double(Squib::Card)
16
- expect(card1).to receive(:text).with('blah','Arial 36',0,0,{}).once
17
- expect(card2).to receive(:text).with('blah','Arial 36',0,0,{}).once
18
- Squib::Deck.new do
19
- @cards = [card1, card2]
20
- text str: 'blah'
21
- end
22
- end
23
-
24
- it "calls text on some cards with an integer" do
25
- card1 = instance_double(Squib::Card)
26
- card2 = instance_double(Squib::Card)
27
- expect(card2).to receive(:text).with('blah','Arial 36',0,0,{}).once
28
- Squib::Deck.new do
29
- @cards = [card1, card2]
30
- text range: 1, str: 'blah'
31
- end
32
- end
33
-
34
- it "calls text with ranges" do
35
- card1 = instance_double(Squib::Card)
36
- card2 = instance_double(Squib::Card)
37
- card3 = instance_double(Squib::Card)
38
- expect(card1).to receive(:text).with('blah','Arial 36',0,0,{}).once
39
- expect(card2).to receive(:text).with('blah','Arial 36',0,0,{}).once
40
- Squib::Deck.new do
41
- @cards = [card1, card2, card3]
42
- text range: 0..1, str: 'blah'
43
- end
44
- end
45
- end
46
-
47
- end#describe
48
-
1
+ require 'spec_helper'
2
+ require 'squib/deck'
3
+
4
+ describe Squib::Deck do
5
+
6
+ it "initializes with default parameters" do
7
+ d = Squib::Deck.new
8
+ expect(d.width).to eq(825)
9
+ expect(d.height).to eq(1125)
10
+ expect(d.cards.size).to eq(1)
11
+ end
12
+
13
+ context "in dealing with ranges" do
14
+ it "calls text on all cards by default" do
15
+ card1 = instance_double(Squib::Card)
16
+ card2 = instance_double(Squib::Card)
17
+ expect(card1).to receive(:text).once
18
+ expect(card2).to receive(:text).once
19
+ Squib::Deck.new do
20
+ @cards = [card1, card2]
21
+ text str: 'blah'
22
+ end
23
+ end
24
+
25
+ it "calls text on some cards with an integer" do
26
+ card1 = instance_double(Squib::Card)
27
+ card2 = instance_double(Squib::Card)
28
+ expect(card2).to receive(:text).once
29
+ Squib::Deck.new do
30
+ @cards = [card1, card2]
31
+ text range: 1, str: 'blah'
32
+ end
33
+ end
34
+
35
+ it "calls text with ranges" do
36
+ card1 = instance_double(Squib::Card)
37
+ card2 = instance_double(Squib::Card)
38
+ card3 = instance_double(Squib::Card)
39
+ expect(card1).to receive(:text).once
40
+ expect(card2).to receive(:text).once
41
+ Squib::Deck.new do
42
+ @cards = [card1, card2, card3]
43
+ text range: 0..1, str: 'blah'
44
+ end
45
+ end
46
+ end
47
+
48
+ end#describe
49
+
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+ require 'squib'
3
+
4
+ describe Squib do
5
+
6
+ it "should execute all examples with no errors" do
7
+ samples = File.expand_path('../samples', File.dirname(__FILE__))
8
+ Dir["#{samples}/**/*.rb"].each do |sample|
9
+ Dir.chdir(samples) do #to save to _output
10
+ require_relative "../samples/#{File.basename(sample)}"
11
+ end
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,9 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start
9
+
data/squib.gemspec CHANGED
@@ -1,27 +1,42 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'squib/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "squib"
8
- spec.version = Squib::VERSION
9
- spec.authors = ["Andy Meneely"]
10
- spec.email = ["playconfidencegames@gmail.com"]
11
- spec.summary = %q{A Ruby API for prototyping card and other tabletop games}
12
- spec.homepage = ""
13
- spec.license = "MIT"
14
-
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_runtime_dependency 'cairo', '~> 1.12.9'
21
- spec.add_runtime_dependency 'pango', '~> 2.2.0'
22
- spec.add_runtime_dependency 'roo', '~> 1.13.2'
23
-
24
- spec.add_development_dependency "bundler", "~> 1.6"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rspec", "~> 3.0"
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'squib/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.specification_version = 2 if spec.respond_to? :specification_version=
8
+ spec.required_rubygems_version = Gem::Requirement.new(">= 0") if spec.respond_to? :required_rubygems_version=
9
+ spec.rubygems_version = '2.2.2'
10
+ spec.required_ruby_version = '>= 2.0.0'
11
+
12
+ spec.name = "squib"
13
+ spec.version = Squib::VERSION
14
+ spec.license = "MIT"
15
+
16
+ spec.summary = %q{A Ruby DSL for prototyping card games}
17
+ spec.description = %q{Squib is a Ruby DSL for prototyping card games}
18
+ spec.authors = ["Andy Meneely"]
19
+ spec.email = ["playconfidencegames@gmail.com"]
20
+ spec.homepage = "https://github.com/andymeneely/squib"
21
+
22
+ spec.rdoc_options = ["--charset=UTF-8"]
23
+ spec.extra_rdoc_files = %w[README.md LICENSE.txt]
24
+
25
+ spec.files = `git ls-files -z`.split("\x0")
26
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_runtime_dependency 'cairo', '~> 1.12.9'
31
+ spec.add_runtime_dependency 'pango', '~> 2.2.0'
32
+ spec.add_runtime_dependency 'roo', '~> 1.13.2'
33
+ spec.add_runtime_dependency 'rsvg2', '~> 2.2.0'
34
+ spec.add_runtime_dependency 'mercenary', '~> 0.3.4'
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.6"
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "rspec", "~> 3.0"
39
+ spec.add_development_dependency "yard"
40
+ spec.add_development_dependency "coveralls"
41
+
42
+ end