Browse Source

Fix the csv_import.rb sample to function properly

dev
Andy Meneely 11 years ago
parent
commit
ac7769237c
  1. 8
      samples/csv_import.rb
  2. 6
      samples/sample.csv
  3. 42
      spec/data/samples/csv_import.rb.txt
  4. BIN
      spec/samples/expected/sample_csv_00.png
  5. BIN
      spec/samples/expected/sample_csv_01.png
  6. 4
      squib.sublime-project

8
samples/csv_import.rb

@ -5,15 +5,13 @@ Squib::Deck.new(cards: 2) do
# Outputs a hash of arrays with the header names as keys
data = csv file: 'sample.csv'
text str: data['Name'], x: 250, y: 55, font: 'Arial 54'
text str: data['Type'], x: 250, y: 55, font: 'Arial 54'
text str: data['Level'], x: 65, y: 65, font: 'Arial 72'
text str: data['Description'], x: 65, y: 600, font: 'Arial 36'
save format: :png, prefix: 'sample_csv_'
# You can also specify the sheet, starting at 0
data = xlsx file: 'sample.xlsx', sheet: 2
save format: :png, prefix: 'sample_csv_'
end
# CSV is also a Squib-module-level function, so this also works:

6
samples/sample.csv

@ -1,3 +1,3 @@
Type,"Quantity"
Thief,2
Mastermind,1
Type,"Level"
Thief,1
Mastermind,2
1 Type Quantity Level
2 Thief 2 1
3 Mastermind 1 2

42
spec/data/samples/csv_import.rb.txt

@ -14,7 +14,7 @@ cairo: translate([250, 55])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=([""])
pango: text=(["Thief"])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@ -31,7 +31,7 @@ cairo: translate([250, 55])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=([""])
pango: text=(["Mastermind"])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@ -48,7 +48,7 @@ cairo: translate([65, 65])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=([""])
pango: text=(["1"])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@ -65,41 +65,7 @@ cairo: translate([65, 65])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=([""])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
pango: justify=([false])
pango: spacing=([0])
cairo: update_pango_layout([MockDouble])
cairo: move_to([0, 0])
cairo: update_pango_layout([MockDouble])
cairo: show_pango_layout([MockDouble])
cairo: restore([])
cairo: save([])
cairo: set_source_color([:black])
cairo: translate([65, 600])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=([""])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
pango: justify=([false])
pango: spacing=([0])
cairo: update_pango_layout([MockDouble])
cairo: move_to([0, 0])
cairo: update_pango_layout([MockDouble])
cairo: show_pango_layout([MockDouble])
cairo: restore([])
cairo: save([])
cairo: set_source_color([:black])
cairo: translate([65, 600])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=([""])
pango: text=(["2"])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])

BIN
spec/samples/expected/sample_csv_00.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
spec/samples/expected/sample_csv_01.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

4
squib.sublime-project vendored

@ -32,6 +32,10 @@
"name": "rake run[draw_shapes]",
"shell_cmd": "rake run[draw_shapes]",
},
{
"name": "rake run[csv_import]",
"shell_cmd": "rake run[csv_import]",
},
{
"name": "rake run[config_text_markup]",
"shell_cmd": "rake run[config_text_markup]",

Loading…
Cancel
Save