Module: DataShift::Delimiters
- Included in:
- Binder, Binder, ColumnPacker, ColumnPacker, Populator, Populator, Populators::HasMany, Populators::HasMany, Querying, Querying
- Defined in:
- lib/datashift/delimiters.rb
Instance Attribute Summary collapse
- #attribute_list_end ⇒ Object
-
#attribute_list_start ⇒ Object
Delimiters for => 2, :efg => ‘some text.
- #csv_delimiter ⇒ Object
-
#key_value_sep ⇒ Object
seperator for identifying normal key value pairs.
-
#text_delim ⇒ Object
surround text in suitable quotes e.g “hello world, how are you” => ‘ “hello world, how are you” ’.
Instance Method Summary collapse
-
#column_delim ⇒ Object
As well as just the column name, support embedding find operators for that column in the heading ..
- #column_delim=(x) ⇒ Object
- #eol ⇒ Object
-
#multi_assoc_delim ⇒ Object
Multiple objects can be embedded in single columns.
- #multi_assoc_delim=(x) ⇒ Object
-
#multi_facet_delim ⇒ Object
Objects can be created with multiple facets in single columns.
-
#multi_value_delim ⇒ Object
The simple seperator for a list of values whether it be “Colour:red,green,blue”.split(Delimiters::multi_value_delim) => [red,green,blue] => value, n2 => v2.split(Delimiters::multi_value_delim) => [ [name => value], [n2 => v2] ].
- #multi_value_delim=(x) ⇒ Object
-
#name_value_delim ⇒ Object
Support multiple associations being added to a base object to be specified in a single column.
- #name_value_delim=(x) ⇒ Object
- #setmulti_facet_delim(x) ⇒ Object
Instance Attribute Details
#attribute_list_end ⇒ Object
111 112 113 |
# File 'lib/datashift/delimiters.rb', line 111 def attribute_list_end @attribute_list_end ||= '}' end |
#attribute_list_start ⇒ Object
Delimiters for => 2, :efg => ‘some text
105 106 107 |
# File 'lib/datashift/delimiters.rb', line 105 def attribute_list_start @attribute_list_start ||= '{' end |
#csv_delimiter ⇒ Object
121 122 123 |
# File 'lib/datashift/delimiters.rb', line 121 def csv_delimiter @csv_delimiter ||= ',' end |
#key_value_sep ⇒ Object
seperator for identifying normal key value pairs
138 139 140 |
# File 'lib/datashift/delimiters.rb', line 138 def key_value_sep @key_value_sep ||= ' ' # for now assume everyone wants newer less verbose style end |
#text_delim ⇒ Object
surround text in suitable quotes e.g “hello world, how are you” => ‘ “hello world, how are you” ’
132 133 134 |
# File 'lib/datashift/delimiters.rb', line 132 def text_delim @text_delim ||= "\'" end |
Instance Method Details
#column_delim ⇒ Object
As well as just the column name, support embedding find operators for that column in the heading .. i.e Column header => ‘BlogPosts:user_id’ … association has many BlogPosts selected via find_by_user_id
in the heading .. i.e Column header => ‘BlogPosts:user_name:John Smith’ … association has many BlogPosts selected via find_by_user_name(“John Smith”)
22 23 24 25 |
# File 'lib/datashift/delimiters.rb', line 22 def column_delim @column_delim ||= ':' @column_delim end |
#column_delim=(x) ⇒ Object
27 28 29 |
# File 'lib/datashift/delimiters.rb', line 27 def column_delim=(x) @column_delim = x end |
#eol ⇒ Object
127 128 129 |
# File 'lib/datashift/delimiters.rb', line 127 def eol "\n" end |
#multi_assoc_delim ⇒ Object
Multiple objects can be embedded in single columns. In this example a single Category column contains 3 separate entries, New, SecondHand, Retro object creation/update via hash (which hopefully we should be able to just forward to AR)
| Category |
'name =>New, :a => 1, :b => 2|name => SecondHand, :a => 6, :b => 34|Name:Old, :a => 12, :b => 67', 'Next Column'
94 95 96 97 |
# File 'lib/datashift/delimiters.rb', line 94 def multi_assoc_delim @multi_assoc_delim ||= '|' @multi_assoc_delim end |
#multi_assoc_delim=(x) ⇒ Object
99 100 101 |
# File 'lib/datashift/delimiters.rb', line 99 def multi_assoc_delim=(x) @multi_assoc_delim = x end |
#multi_facet_delim ⇒ Object
Objects can be created with multiple facets in single columns. In this example a single Product can be configured with a consolidated mime and print types
mime_type:jpeg,PDF ; print_type:colour equivalent to
=> mime_type:jpeg;print_type:colour | mime_type:PDF; print_type:colour
79 80 81 |
# File 'lib/datashift/delimiters.rb', line 79 def multi_facet_delim @multi_facet_delim ||= ';' end |
#multi_value_delim ⇒ Object
The simple seperator for a list of values whether it be
"Colour:red,green,blue".split(Delimiters::multi_value_delim) => [red,green,blue]
{name => value, n2 => v2}.split(Delimiters::multi_value_delim) => [ [name => value], [n2 => v2] ]
64 65 66 |
# File 'lib/datashift/delimiters.rb', line 64 def multi_value_delim @multi_value_delim ||= ',' end |
#multi_value_delim=(x) ⇒ Object
68 69 70 |
# File 'lib/datashift/delimiters.rb', line 68 def multi_value_delim=(x) @multi_value_delim = x end |
#name_value_delim ⇒ Object
Support multiple associations being added to a base object to be specified in a single column.
Entry represents the association to find via supplied name, value to use in the lookup.
Default syntax :
Name1:value1, value2|Name2:value1, value2, value3|Name3:value1, value2
E.G.
Association Properties, has a column named Size, and another called Colour,
and this combination could be used to lookup multiple associations to add to the main model Jumper
Size:small # => generates find_by_size( 'small' )
Size:large # => generates find_by_size( 'large' )
Colour:red,green,blue # => generates find_all_by_colour( ['red','green','blue'] )
Size:large|Size:medium|Size:large
=> Find 3 different associations, perform lookup via column called Size
=> Jumper.properties << [ small, medium, large ]
51 52 53 54 |
# File 'lib/datashift/delimiters.rb', line 51 def name_value_delim @name_value_delim ||= ':' @name_value_delim end |
#name_value_delim=(x) ⇒ Object
56 57 58 |
# File 'lib/datashift/delimiters.rb', line 56 def name_value_delim=(x) @name_value_delim = x end |
#setmulti_facet_delim(x) ⇒ Object
83 84 85 |
# File 'lib/datashift/delimiters.rb', line 83 def setmulti_facet_delim(x) @multi_facet_delim = x end |