squib 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -1
  3. data/CHANGELOG.md +10 -0
  4. data/README.md +65 -4
  5. data/lib/squib/api/data.rb +48 -1
  6. data/lib/squib/api/text.rb +4 -2
  7. data/lib/squib/deck.rb +22 -5
  8. data/lib/squib/graphics/text.rb +4 -0
  9. data/lib/squib/layouts/hand.yml +46 -0
  10. data/lib/squib/layouts/playing-card.yml +18 -0
  11. data/lib/squib/version.rb +1 -1
  12. data/samples/cairo_access.rb +4 -3
  13. data/samples/csv_import.rb +20 -0
  14. data/samples/custom-layout.yml +5 -4
  15. data/samples/custom-layout2.yml +15 -0
  16. data/samples/custom_config.rb +0 -1
  17. data/samples/excel.rb +1 -2
  18. data/samples/layouts.rb +61 -0
  19. data/samples/ranges.rb +0 -1
  20. data/samples/sample.csv +3 -0
  21. data/samples/text_options.rb +14 -3
  22. data/samples/tgc_proofs.rb +0 -1
  23. data/samples/units.rb +1 -1
  24. data/spec/api/api_data_spec.rb +31 -0
  25. data/spec/api/api_image_spec.rb +38 -0
  26. data/spec/data/csv/basic.csv +3 -0
  27. data/spec/data/csv/dup_cols.csv +3 -0
  28. data/spec/data/csv/with_spaces.csv +3 -0
  29. data/spec/data/{easy-circular-extends.yml → layouts/easy-circular-extends.yml} +0 -0
  30. data/spec/data/{hard-circular-extends.yml → layouts/hard-circular-extends.yml} +0 -0
  31. data/spec/data/{multi-extends-single-entry.yml → layouts/multi-extends-single-entry.yml} +0 -0
  32. data/spec/data/{multi-level-extends.yml → layouts/multi-level-extends.yml} +0 -0
  33. data/spec/data/layouts/multifile-a.yml +4 -0
  34. data/spec/data/layouts/multifile-b.yml +4 -0
  35. data/spec/data/layouts/multifile-extends-a.yml +8 -0
  36. data/spec/data/layouts/multifile-extends-b.yml +9 -0
  37. data/spec/data/{no-extends.yml → layouts/no-extends.yml} +0 -0
  38. data/spec/data/{pre-extends.yml → layouts/pre-extends.yml} +0 -0
  39. data/spec/data/{self-circular-extends.yml → layouts/self-circular-extends.yml} +0 -0
  40. data/spec/data/{single-extends.yml → layouts/single-extends.yml} +0 -0
  41. data/spec/data/{single-level-multi-extends.yml → layouts/single-level-multi-extends.yml} +0 -0
  42. data/spec/data/samples/autoscale_font.rb.txt +81 -0
  43. data/spec/data/samples/basic.rb.txt +206 -0
  44. data/spec/data/samples/cairo_access.rb.txt +25 -0
  45. data/spec/data/samples/colors.rb.txt +124 -0
  46. data/spec/data/samples/csv_import.rb.txt +112 -0
  47. data/spec/data/samples/custom_config.rb.txt +45 -0
  48. data/spec/data/samples/draw_shapes.rb.txt +35 -0
  49. data/spec/data/samples/excel.rb.txt +168 -0
  50. data/spec/data/samples/hello_world.rb.txt +36 -0
  51. data/spec/data/samples/layouts.rb.txt +489 -0
  52. data/spec/data/samples/load_images.rb.txt +104 -0
  53. data/spec/data/samples/portrait-landscape.rb.txt +49 -0
  54. data/spec/data/samples/ranges.rb.txt +426 -0
  55. data/spec/data/samples/save_pdf.rb.txt +545 -0
  56. data/spec/data/samples/text_options.rb.txt +819 -0
  57. data/spec/data/samples/tgc_proofs.rb.txt +81 -0
  58. data/spec/data/samples/units.rb.txt +14 -0
  59. data/spec/deck_spec.rb +33 -9
  60. data/spec/graphics/graphics_text_spec.rb +7 -5
  61. data/spec/samples/samples_regression_spec.rb +73 -0
  62. data/spec/spec_helper.rb +64 -2
  63. data/squib.gemspec +2 -2
  64. metadata +100 -27
  65. data/samples/use_layout.rb +0 -34
  66. data/spec/samples_run_spec.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88dc6fa44ed331fbc2a3985342f8643411150ccf
4
- data.tar.gz: 53688a6d02c0f26ab0f80a0e6cad0c801e101305
3
+ metadata.gz: 1f92ed35ef9dd4ecc229f5608a621af891c3e31f
4
+ data.tar.gz: d45847e33458b00f6642558892abeb4f7682e0f0
5
5
  SHA512:
6
- metadata.gz: 45d3440c0f8e28a459d12a89a650ec30e0c6d3d8b1c22b1ca558927af336d4f9f0be562ce7b50c3e52a1bfd3c08cfd0973b7e8e15b405fee66727fd3c1f6002b
7
- data.tar.gz: d2d258e94fdaf3be396de46dc3ffccd8ce55c87735b714657a2d60c42f063ca1a6ac0c7ad4cc8bb8fce1ac10c76865d266d656f91f0707c13d1aece99ad3a869
6
+ metadata.gz: d0fe30d4bfcf1f528140cbda4cd3662b88a06b605093390d2bf0ad28243b83b54ca97a294a3882f161db92d51ee13654519285df0c555c1e7aa5848a14de3520
7
+ data.tar.gz: 0acfc9a5e09394528b0eb3a6ed5df1ae528b18324ffe336e1f01d981ef839808283ab1b66468d66568869a376e99fde087bd2dfb9381069d353be29d15ba8a75
data/.yardopts CHANGED
@@ -1,8 +1,10 @@
1
1
  --readme README.md
2
- --markup-provider=redcarpet
2
+ --title 'Squib API Documentation'
3
3
  --markup markdown
4
+ --markup-provider=redcarpet
4
5
  --api public
5
6
  --asset samples:samples
7
+ --charset utf-8
6
8
  -
7
9
  samples/**/*.rb
8
10
  LICENSE.txt
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Squib CHANGELOG
2
2
 
3
+ ## v0.0.6
4
+ # Added a `csv` command that works just like `xslx`. Uses Ruby's CSV inside, with some extra checking and warnings.
5
+ # Custom layouts now support loading & merging multiple Yaml files! Updated README, docs, and sample to document it.
6
+ # Built-in layouts! Currently we support `hand.yml` and `playing-card.yml`. Documented in the `layouts.rb` sample.
7
+ # `text` now returns the ink extent rectangle of the rendered text. Updated docs and sample to document it.
8
+ # Samples now show that you can use text instead of symbols for things like `center`
9
+ # Improved logging, and documentation on increasing logger verboseness
10
+ # Better regression testing technique that tracks when a sample has changed.
11
+ # Bumped version of Cairo to ~> 1.14
12
+
3
13
  ## v0.0.5
4
14
  * Image rotation for png and svg via `angle`
5
15
  * New sample for demonstrating direct cairo access
data/README.md CHANGED
@@ -4,7 +4,7 @@ Squib is a Ruby [DSL](http://en.wikipedia.org/wiki/Domain-specific_language) for
4
4
  * A concise set of rules for laying out your cards
5
5
  * Loading PNGs and SVGs using [Cairo](http://cairographics.org/)
6
6
  * Complex text rendering using [Pango](http://www.pango.org/)
7
- * Reading `.xlsx` files
7
+ * Reading `xlsx` and `csv` files
8
8
  * Basic shape drawing
9
9
  * Rendering decks to PNGs and PDFs
10
10
  * Data-driven layouts
@@ -38,7 +38,7 @@ And then execute:
38
38
 
39
39
  $ bundle
40
40
 
41
- Note: Squib has some native dependencies, such as [Cairo](https://github.com/rcairo/rcairo), [Pango](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3ALayout), and [Nokogiri](http://nokogiri.org/), which all require DevKit to compile C code. This is usually not painful, but can cause headaches on some setups. For Windows users, I *strongly* recommend using the *non-64 bit* RubyInstaller at http://rubyinstaller.org. For Mac, I recommend using [rvm](https://rvm.io).
41
+ Note: Squib has some native dependencies, such as [Cairo](https://github.com/rcairo/rcairo), [Pango](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Pango%3A%3ALayout), and [Nokogiri](http://nokogiri.org/), which all require DevKit to compile C code. This is usually not painful, but can cause headaches on some setups. For Windows users, I *strongly* recommend using the *non-64 bit* RubyInstaller at http://rubyinstaller.org along with installing DevKit. For Mac, I recommend using [rvm](https://rvm.io).
42
42
 
43
43
  Note: Squib requires Ruby 2.0 or later.
44
44
 
@@ -169,6 +169,12 @@ Layouts will override Squib's defaults, but are overriden by anything specified
169
169
  * If anything was not yet specified, use what was given in a layout (if a layout was specified in the command and the file was given to the Deck)
170
170
  * If still anything was not yet specified, use what was given in Squib's defaults.
171
171
 
172
+ Layouts also allow merging, extending, and combining layouts. The sample demonstrates this, but they are also explained below. See the `layouts.rb` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
173
+
174
+ {include:file:samples/layouts.rb}
175
+
176
+ ### Merge Keys and `extends`
177
+
172
178
  Since Layouts are in Yaml, we have the full power of that data format. One particular feature you should look into are ["merge keys"](http://www.yaml.org/YAML_for_ruby.html#merge_key). With merge keys, you can define base styles in one entry, then include those keys elsewhere. For example:
173
179
 
174
180
  ```yaml
@@ -193,9 +199,46 @@ yang:
193
199
  x: += 50
194
200
  ```
195
201
 
196
- See the `use_layout` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/)
202
+ ### Multiple layout files
203
+
204
+ Squib also supports the combination of multiple layout files. As shown in the above example, if you provide an `Array` of files then Squib will merge them sequentially. Colliding keys will be completely re-defined by the later file. Extends is processed after _each file_. YAML merge keys are NOT supported across multiple files - use extends instead. Here's a demonstrative example:
205
+
206
+ ```yaml
207
+ # load order: a.yml, b.yml
208
+
209
+ ##############
210
+ # file a.yml #
211
+ ##############
212
+ grandparent:
213
+ x: 100
214
+ parent_a:
215
+ extends: grandparent
216
+ x: += 10 # evaluates to 110
217
+ parent_b:
218
+ extends: grandparent
219
+ x: += 20 # evaluates to 120
220
+
221
+ ##############
222
+ # file b.yml #
223
+ ##############
224
+ child_a:
225
+ extends: parent_a
226
+ x: += 3 # evaluates to 113
227
+ parent_b: # redefined
228
+ extends: grandparent
229
+ x: += 30 # evaluates to 130
230
+ child_b:
231
+ extends: parent_b
232
+ x: += 3 # evaluates to 133
233
+ ```
234
+
235
+ This can hopefully be helpful for:
236
+ * Creating a base layout for structure, and one for color (for easier color/black-and-white switching)
237
+ * Sharing base layouts with other designers
238
+
239
+ ### Built-in Layout Files
197
240
 
198
- {include:file:samples/use_layout.rb}
241
+ If your layout file is not found in the current directory, Squib will search for its own set of layout files (here's the latest the development version [on GitHub](https://github.com/andymeneely/squib/tree/master/lib/squib/layouts). See the `layouts.rb` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/) for some demonstrative examples.
199
242
 
200
243
  ## Configuration File
201
244
 
@@ -212,6 +255,24 @@ See the `custom_config` sample found [here](https://github.com/andymeneely/squib
212
255
 
213
256
  {include:file:samples/custom_config.rb}
214
257
 
258
+ ## Importing from Excel and CSV
259
+
260
+ Squib supports importing data from `xlsx` files and `csv` files. These methods are column-based, which means that they assume you have a header row in your table, and that header row will define the column. Squib will return a `Hash` of `Arrays` correspoding to each row. Warnings are thrown on things like duplicate columns. See the `excel.rb` and the `csv_import.rb` sample found [here](https://github.com/andymeneely/squib/tree/master/samples/).
261
+
262
+ {include:file:samples/excel.rb}
263
+
264
+ Of course, you can always import your game data other ways using just Ruby. There's nothing special about Squib's methods other than their convenience.
265
+
266
+ ## Making Squib Verbose
267
+
268
+ By default, Squib's logger is set to WARN, but more fine-grained logging is embedded in the code. To set the logger, just put this at the top of your script:
269
+
270
+ ```ruby
271
+ Squib::logger.level = Logger::INFO
272
+ ```
273
+
274
+ If you REALLY want to see tons of output, you can also set DEBUG, but that's not intended for general consumption.
275
+
215
276
  ## Staying DRY
216
277
 
217
278
  Squib tries to keep you DRY (Don't Repeat Yourself) with the following features:
@@ -1,4 +1,5 @@
1
1
  require 'roo'
2
+ require 'csv'
2
3
 
3
4
  module Squib
4
5
 
@@ -40,12 +41,58 @@ module Squib
40
41
  end#xlsx
41
42
  module_function :xlsx
42
43
 
44
+ # Pulls CSV data from `.csv` files into a column-based hash
45
+ #
46
+ # Pulls the data into a Hash of arrays based on the columns. First row is assumed to be the header row.
47
+ # See the example `samples/csv.rb` in the [source repository](https://github.com/andymeneely/squib/tree/master/samples)
48
+ #
49
+ # @example
50
+ # # File data.csv looks like this (without the comment symbols)
51
+ # # h1,h2
52
+ # # 1,2
53
+ # # 3,4
54
+ # data = csv file: 'data.csv'
55
+ # => {'h1' => [1,3], 'h2' => [2,4]}
56
+ #
57
+ # Parsing uses Ruby's CSV, options: {headers: true, converters: :numeric}
58
+ # http://www.ruby-doc.org/stdlib-2.0/libdoc/csv/rdoc/CSV.html
59
+ #
60
+ # @option opts file [String] the CSV-formatted file to open. Opens relative to the current directory.
61
+ # @return [Hash] a hash of arrays based on columns in the spreadsheet
62
+ # @api public
63
+ def csv(opts = {})
64
+ opts = Squib::SYSTEM_DEFAULTS.merge(opts)
65
+ opts = Squib::InputHelpers.fileify(opts)
66
+ table = CSV.read(opts[:file], headers: true, converters: :numeric)
67
+ check_duplicate_csv_headers(table)
68
+ hash = Hash.new
69
+ table.headers.each do |header|
70
+ hash[header.to_s] ||= table[header]
71
+ end
72
+ return hash
73
+ end
74
+ module_function :csv
75
+
76
+ # Check if the given CSV table has duplicate columns, and throw a warning
77
+ # @api private
78
+ def check_duplicate_csv_headers(table)
79
+ if table.headers.size != table.headers.uniq.size
80
+ dups = table.headers.select{|e| table.headers.count(e) > 1 }
81
+ Squib.logger.warn "CSV duplicated the following column keys: #{dups.join(',')}"
82
+ end
83
+ end
84
+ module_function :check_duplicate_csv_headers
85
+
43
86
  class Deck
44
87
 
45
- # Convenience call for Squib.xlsx
88
+ # Convenience call on deck goes to the module function
46
89
  def xlsx(opts = {})
47
90
  Squib.xlsx(opts)
48
91
  end
49
92
 
93
+ def csv(opts = {})
94
+ Squib.csv(opts)
95
+ end
96
+
50
97
  end
51
98
  end
@@ -36,18 +36,20 @@ module Squib
36
36
  # @option opts ellipsize [:none, :start, :middle, :end, true, false] (:end) When width and height are set, determines the behavior of overflowing text. Also: `true` maps to `:end` and `false` maps to `:none`. Default `:end`
37
37
  # @option opts angle [FixNum] (0) Rotation of the text in radians. Note that this rotates around the upper-left corner of the text box, making the placement of x-y coordinates slightly tricky.
38
38
  # @option opts hint [String] (:nil) draw a rectangle around the text with the given color. Overrides global hints (see {Deck#hint}).
39
- # @return [nil] Returns nothing
39
+ # @return [Array] Returns an Array of hashes keyed by :width and :height that mark the ink extents of the text rendered.
40
40
  # @api public
41
41
  def text(opts = {})
42
42
  opts = needs(opts, [:range, :str, :font, :font_size, :x, :y, :width, :height, :color, :wrap,
43
43
  :align, :justify, :spacing, :valign, :markup, :ellipsize, :hint, :layout, :angle])
44
+ extents = Array.new(@cards.size)
44
45
  opts[:range].each do |i|
45
- @cards[i].text(opts[:str][i], opts[:font][i], opts[:font_size][i], opts[:color][i],
46
+ extents[i] = @cards[i].text(opts[:str][i], opts[:font][i], opts[:font_size][i], opts[:color][i],
46
47
  opts[:x][i], opts[:y][i], opts[:width][i], opts[:height][i],
47
48
  opts[:markup][i], opts[:justify][i], opts[:wrap][i],
48
49
  opts[:ellipsize][i], opts[:spacing][i], opts[:align][i],
49
50
  opts[:valign][i], opts[:hint][i], opts[:angle][i])
50
51
  end
52
+ return extents
51
53
  end
52
54
 
53
55
  end
data/lib/squib/deck.rb CHANGED
@@ -50,6 +50,7 @@ module Squib
50
50
  # @param cards [Integer] the number of cards in the deck
51
51
  # @param dpi [Integer] the pixels per inch when rendering out to PDF or calculating using inches.
52
52
  # @param config [String] the file used for global settings of this deck
53
+ # @param layout [String, Array] load a YML file of custom layouts. Multiple files are merged sequentially, redefining collisons. See README and sample for details.
53
54
  # @param block [Block] the main body of the script.
54
55
  # @api public
55
56
  def initialize(width: 825, height: 1125, cards: 1, dpi: 300, config: 'config.yml', layout: nil, &block)
@@ -62,6 +63,7 @@ module Squib
62
63
  @progress_bar = Squib::Progress.new(false)
63
64
  @text_hint = :off
64
65
  cards.times{ @cards << Squib::Card.new(self, width, height) }
66
+ show_info(config, layout)
65
67
  load_config(config)
66
68
  load_layout(layout)
67
69
  if block_given?
@@ -94,6 +96,7 @@ module Squib
94
96
  # @api private
95
97
  def load_config(file)
96
98
  if File.exists?(file) && config = YAML.load_file(file)
99
+ Squib::logger.info { " using config: #{file}" }
97
100
  config = Squib::CONFIG_DEFAULTS.merge(config)
98
101
  @dpi = config['dpi'].to_i
99
102
  @text_hint = config['text_hint']
@@ -105,12 +108,21 @@ module Squib
105
108
 
106
109
  # Load the layout configuration file, if exists
107
110
  # @api private
108
- def load_layout(file)
109
- return if file.nil?
111
+ def load_layout(files)
110
112
  @layout = {}
111
- yml = YAML.load_file(file)
112
- yml.each do |key, value|
113
- @layout[key] = recurse_extends(yml, key, {})
113
+ Squib::logger.info { " using layout(s): #{files}" }
114
+ Array(files).each do |file|
115
+ thefile = file
116
+ thefile = "#{File.dirname(__FILE__)}/layouts/#{file}" unless File.exists?(file)
117
+ if File.exists? thefile
118
+ yml = @layout.merge(YAML.load_file(thefile))
119
+ yml.each do |key, value|
120
+ @layout[key] = recurse_extends(yml, key, {})
121
+ end
122
+ else
123
+ puts "the file: #{thefile}"
124
+ Squib::logger.error { "Layout file not found: #{file}" }
125
+ end
114
126
  end
115
127
  end
116
128
 
@@ -157,6 +169,11 @@ module Squib
157
169
  end
158
170
  end
159
171
 
172
+ def show_info(config, layout)
173
+ Squib::logger.info "Squib v#{Squib::VERSION}"
174
+ Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
175
+ end
176
+
160
177
  ##################
161
178
  ### PUBLIC API ###
162
179
  ##################
@@ -89,6 +89,7 @@ module Squib
89
89
  markup, justify, wrap, ellipsize,
90
90
  spacing, align, valign, hint, angle)
91
91
  Squib.logger.debug {"Placing '#{str}'' with font '#{font}' @ #{x}, #{y}, color: #{color}, angle: #{angle} etc."}
92
+ extents = nil
92
93
  use_cairo do |cc|
93
94
  cc.set_source_color(color)
94
95
  cc.translate(x,y)
@@ -112,7 +113,10 @@ module Squib
112
113
  valign!(cc, layout, x, y, valign)
113
114
  cc.update_pango_layout(layout) ; cc.show_pango_layout(layout)
114
115
  draw_text_hint(cc,x,y,layout,hint,angle)
116
+ extents = { width: layout.extents[1].width / Pango::SCALE,
117
+ height: layout.extents[1].height / Pango::SCALE }
115
118
  end
119
+ return extents
116
120
  end
117
121
 
118
122
  end
@@ -0,0 +1,46 @@
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
@@ -0,0 +1,18 @@
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
data/lib/squib/version.rb CHANGED
@@ -6,5 +6,5 @@ module Squib
6
6
  # Most of the time this is in the alpha of the next release.
7
7
  # e.g. v0.0.5a is on its way to becoming v0.0.5
8
8
  #
9
- VERSION = '0.0.5'
9
+ VERSION = '0.0.6'
10
10
  end
@@ -1,7 +1,7 @@
1
1
  require 'squib'
2
2
 
3
3
  Squib::Deck.new(cards: 2) do
4
-
4
+ background color: :white
5
5
  # If you really need something custom-made, the underlying cairo context
6
6
  # can be accessed directly via each Squib::Card
7
7
  #
@@ -11,8 +11,9 @@ Squib::Deck.new(cards: 2) do
11
11
  # I also recommend wrapping it in a Cairo save/restore, which Squib calls "use_cairo"
12
12
  each do |card|
13
13
  card.use_cairo do |cairo_context|
14
- cairo_context.set_source_color(:white)
15
- cairo_context.paint
14
+ cairo_context.set_source_color(:blue)
15
+ cairo_context.circle(150, 150, 150)
16
+ cairo_context.fill
16
17
  end
17
18
  end
18
19
 
@@ -0,0 +1,20 @@
1
+ require 'squib'
2
+
3
+ Squib::Deck.new(cards: 2) do
4
+ background color: :white
5
+
6
+ # Outputs a hash of arrays with the header names as keys
7
+ data = csv file: 'sample.csv'
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
+ # You can also specify the sheet, starting at 0
14
+ data = xlsx file: 'sample.xlsx', sheet: 2
15
+
16
+ save format: :png, prefix: 'sample_csv_'
17
+ end
18
+
19
+ # CSV is also a Squib-module-level function, so this also works:
20
+ data = Squib.csv file: 'sample.csv'
@@ -1,3 +1,4 @@
1
+ # Used in the layouts.rb sample in conjunction with custom-layout2.yml
1
2
  frame:
2
3
  x: 38
3
4
  y: 38
@@ -9,15 +10,15 @@ title:
9
10
  y: 50
10
11
  width: 625
11
12
  height: 100
12
- align: !ruby/symbol center #see http://www.yaml.org/YAML_for_ruby.html#symbols
13
- valign: !ruby/symbol middle
13
+ align: center #strings also work for most options
14
+ valign: !ruby/symbol middle #yaml also support symbols, see http://www.yaml.org/YAML_for_ruby.html#symbols
14
15
  subtitle:
15
16
  x: 150
16
17
  y: 150
17
18
  width: 575
18
19
  height: 60
19
- align: !ruby/symbol center
20
- valign: !ruby/symbol middle
20
+ align: center
21
+ valign: middle
21
22
  icon:
22
23
  width: 125
23
24
  height: 125