diff --git a/docs/dsl/csv.rst b/docs/dsl/csv.rst index 5946028..ce06487 100644 --- a/docs/dsl/csv.rst +++ b/docs/dsl/csv.rst @@ -1,2 +1,35 @@ csv ---- +=== + +Pulls CSV data from .csv files into a hash of arrays keyed by the headers. First row is assumed to be the header row. + +Parsing uses Ruby's CSV, with options ``{headers: true, converters: :numeric}`` +http://www.ruby-doc.org/stdlib-2.0/libdoc/csv/rdoc/CSV.html + +The ``csv`` method is a member of ``Squib::Deck``, but it is also available outside of the Deck DSL with ``Squib.csv()``. This allows a construction like:: + + data = Squib.csv file: 'data.csv' + Squib::Deck.new(cards: data['name'].size) do + end + + +Options +------- + +file + default: ``'deck.csv'`` + + the CSV-formatted file to open. Opens relative to the current directory. + +strip + default: ``true`` + + When ``true``, strips leading and trailing whitespace on values and headers + +explode + default: ``'qty'`` + + Quantity explosion will be applied to the column this name. For example, rows in the csv with a ``'qty'`` of 3 will be duplicated 3 times. + +Examples +-------- diff --git a/docs/dsl/ellipse.rst b/docs/dsl/ellipse.rst index 7effb12..a49ad0c 100644 --- a/docs/dsl/ellipse.rst +++ b/docs/dsl/ellipse.rst @@ -1,7 +1,7 @@ ellipse ------- -Draw an ellipse at the given coordinates. +Draw an ellipse at the given coordinates. An ellipse is an oval that is defined by a bounding rectangle. To draw a circle, see :doc:`circle`. Options ^^^^^^^ diff --git a/docs/dsl/text.rst b/docs/dsl/text.rst index 81e84e2..c7c5f6f 100644 --- a/docs/dsl/text.rst +++ b/docs/dsl/text.rst @@ -9,14 +9,6 @@ Options ------- -definition - This is a definition of something. - And some more stuff. - -x - The x-coordinate of the upper-left corner of the text box. Supports :doc:`/units` - - Examples -------- diff --git a/docs/dsl/xlsx.rst b/docs/dsl/xlsx.rst index 3254360..a5390f1 100644 --- a/docs/dsl/xlsx.rst +++ b/docs/dsl/xlsx.rst @@ -1,2 +1,37 @@ xlsx ----- +==== + +Pulls ExcelX data from .xlsx files into a hash of arrays keyed by the headers. First row is assumed to be the header row. + +The ``csv`` method is a member of ``Squib::Deck``, but it is also available outside of the Deck DSL with ``Squib.csv()``. This allows a construction like:: + + data = Squib.xlsx file: 'data.xlsx' + Squib::Deck.new(cards: data['name'].size) do + end + + +Options +------- + +file + default: ``'deck.xlsx'`` + + the xlsx-formatted file to open. Opens relative to the current directory. + +sheet + default: ``0`` + + The zero-based index of the sheet from which to read. + +strip + default: ``true`` + + When ``true``, strips leading and trailing whitespace on values and headers + +explode + default: ``'qty'`` + + Quantity explosion will be applied to the column this name. For example, rows in the csv with a ``'qty'`` of 3 will be duplicated 3 times. + +Examples +-------- diff --git a/lib/squib/api/data.rb b/lib/squib/api/data.rb index 28464f6..516435e 100644 --- a/lib/squib/api/data.rb +++ b/lib/squib/api/data.rb @@ -101,6 +101,7 @@ module Squib end module_function :check_duplicate_csv_headers + # @api private def explode_quantities(data, qty) return data unless data.key? qty.to_s.strip qtys = data[qty]