Commit Graph

26 Commits

Author SHA1 Message Date
Paul Hinze c95f21cec1 config: make formatlist work on lists of length 1
removes treat-lists-as-scalar special casing for formatlist

/cc @radeksimko

fixes #2240
2015-06-25 18:55:28 -05:00
Paul Hinze e88aeede9b core: allow distinguishing between empty lists and strings
Had to handle a lot of implicit leaning on a few properties of the old
representation:

 * Old representation allowed plain strings to be treated as lists
   without problem (i.e. shoved into strings.Split), now strings need to
   be checked whether they are a list before they are treated as one
   (i.e. shoved into StringList(s).Slice()).
 * Tested behavior of 0 and 1 length lists in formatlist() was a side
   effect of the representation. Needs to be special cased now to
   maintain the behavior.
 * Found a pretty old context test failure that was wrong in several
   different ways. It's covered by TestContext2Apply_multiVar so I
   removed it.
2015-06-25 18:53:35 -05:00
Paul Hinze 7238b3b4af core: encapsulate representation of StringList
Now the only code that cares about how StringLists are represented lives
inside string_list.go

...which gives us the ability to change it! :)
2015-06-25 17:55:57 -05:00
Paul Hinze 10b3abf405 config: introduce StringList to abstract over list hack
This is the initial pure "all tests passing without a diff" stage. The
plan is to change the internal representation of StringList to include a
suffix delimiter, which will allow us to recognize empty and
single-element lists.
2015-06-25 17:55:56 -05:00
Radek Simko 6a60fa4bfe config: concat function supports lists (combines more lists into one) 2015-06-13 08:54:01 +01:00
Radek Simko e9e41dfd05 Improve test error messages 2015-06-13 08:54:01 +01:00
Paul Hinze b781c6c446 core: keys() and values() funcs for map variables
they work on maps with both keys and values that are string types, which
AFAICT are the only types of maps we have right now.

closes #1915
2015-06-02 16:49:51 -05:00
Josh Bleecher Snyder 02e751e356 config: add formatlist
formatlist distributes formatting over lists.
See the docs for details.

As a colleague commented:

"It happens all the time that we want a set of
outputs, but in a slightly different way than
just simple joining or concatting."

formatlist (combined with join)
makes it easy to satisfy those needs.
2015-05-12 16:11:42 -07:00
Paul Hinze 5874fa06ff Merge pull request #1495 from TimeIncOSS/length-func
config: Add length to built-in functions
2015-04-15 11:54:46 -05:00
Radek Simko 6a720d087c length added to built-in functions 2015-04-15 16:20:11 +01:00
Radek Simko 8eb6984a89 Test helpers to print expected output 2015-04-13 14:12:43 +01:00
Mitchell Hashimoto b39ddc7d47 config: add format function 2015-03-02 10:26:06 -08:00
Mitchell Hashimoto 5895494897 config: test bad regexp for replace 2015-03-02 09:44:45 -08:00
Mitchell Hashimoto 2f33a24385 config: add replace function 2015-03-02 09:37:40 -08:00
Bryce Kahle adccaad252 Add split function 2015-01-28 16:59:16 -05:00
Mitchell Hashimoto 2abeb2d9ac config: use new API 2015-01-14 22:03:15 -08:00
Mitchell Hashimoto 8ae14f06b3 config: variables must be typed 2015-01-14 10:40:43 -08:00
Mitchell Hashimoto 92af4801a1 config: reintroduce concat 2015-01-13 12:47:54 -08:00
Mitchell Hashimoto 4af4c9e16c config: add lookup function back 2015-01-13 12:06:04 -08:00
Mitchell Hashimoto 1ccad4d729 config: convert fucntions, put functions into Scope 2015-01-13 11:50:44 -08:00
Rob Costanzo 8da91e9636 Added an element interpolation lookup function for accessing a specific index from a list with splat variables 2014-11-07 10:24:21 -08:00
Mitchell Hashimoto 61b46c8612 config: add join() function 2014-10-09 21:22:35 -07:00
Mitchell Hashimoto 2fb001dcf9 config: add `concat` function [GH-191] 2014-08-19 13:14:45 -07:00
Mitchell Hashimoto 0d12c3f5b8 config: fmt 2014-07-22 18:35:53 -07:00
Mitchell Hashimoto 80385c7682 config: add file() function for reading file contents 2014-07-22 18:35:36 -07:00
Mitchell Hashimoto 8b5cc5d534 config: lookup function works + tests 2014-07-21 13:12:43 -07:00