Commit Graph

106 Commits

Author SHA1 Message Date
Havoc Pennington
3bdaaabf02 implement equals/hashCode/toString for SimpleConfigOrigin 2011-11-15 22:09:55 -05:00
Havoc Pennington
aefdb58e04 fix indentation, eclipse keeps screwing it up 2011-11-15 21:11:38 -05:00
Havoc Pennington
ed75c315bc add Config.empty variants that take origin description; use singleton for default-named empty object 2011-11-15 21:08:29 -05:00
Havoc Pennington
1841dd9c67 Add a real README, license, and rewrite spec. 2011-11-15 19:14:22 -05:00
Havoc Pennington
aae70ecb8e extensively fix fromProperties() and add tests
fromProperties() now parses paths with a strict "split on period"

It now handles more than one level of nested object.

It's now defined that if a properties file defines both an
object and a string at the same key, the object wins.
2011-11-15 19:13:12 -05:00
Havoc Pennington
d59786925d add a couple corner case tests related to include keyword 2011-11-15 16:37:47 -05:00
Havoc Pennington
68a22668bd change getMemorySize to getMemorySizeInBytes
Preserves the memory size vs. disk size distinction (powers of two vs. ten)
But specifies that it will be in bytes, for consistency with getMilliseconds
and clarity in general.
2011-11-15 16:37:06 -05:00
Havoc Pennington
598c5d045f support terabytes when parsing a memory size 2011-11-15 16:31:37 -05:00
Havoc Pennington
6ca952e516 Fix code to find includes relative to other includes. Support ParseOptions for load(). 2011-11-14 23:52:14 -05:00
Havoc Pennington
d257c3bbd9 attempt to rationalize the loader/includer code
Introduce ConfigIncluder pluggable includer interface.

Move all the parse-something logic from Config, Loader,
ConfigImpl, Parser into the Parseable abstraction.
2011-11-14 15:42:50 -05:00
Havoc Pennington
9b3efbd2d0 do a better job with origin when there's an empty config. add Config.empty(). 2011-11-14 10:26:53 -05:00
Havoc Pennington
54cd4ec3dd Overhaul the public API.
This patch is a little half-baked (it needs tests, and
there are a few bugs I know about). Fixes will be along.
2011-11-14 02:13:25 -05:00
Havoc Pennington
f1bedacdfc get rid of ConfigConfig, wasn't the right API.
Will replace it with something better later.
2011-11-12 22:59:43 -05:00
Havoc Pennington
31a8e9ee57 Save the original text of parsed numbers
Value concatenation is supposed to provide an illusion that
you can just type long unquoted sentences, but really they
are a series of tokens. Be sure we don't weirdly reformat
any numbers that happen to appear in unquoted text.
2011-11-12 22:42:25 -05:00
Havoc Pennington
52f34925dc Fix equality between ConfigObject of different types
By pulling equals/hashCode up into AbstractConfigObject
2011-11-12 22:19:24 -05:00
Havoc Pennington
6528ac5d1e check Map.get, Map.containsKey, Map.containsValue implementations with non-string parameter 2011-11-12 22:19:03 -05:00
Havoc Pennington
367b1b27fa remove a few unused methods 2011-11-12 22:07:55 -05:00
Havoc Pennington
e66eaddfc7 add a test for null in value concatenation 2011-11-12 21:53:40 -05:00
Havoc Pennington
7b0e5a1471 make whitespace handling Unicode-correct.
This is maybe a little above and beyond what will ever matter in practice.
2011-11-12 21:47:35 -05:00
Havoc Pennington
b0fdc6456c Relativize substitutions when including a file
This is needed because we resolve substitutions only
as the last step, and against the whole tree not
against each file.

Special handling is needed so that fallback to
system properties and environment variables still
works properly.
2011-11-12 19:23:09 -05:00
Havoc Pennington
b034ce8de3 remove unused import 2011-11-12 18:02:01 -05:00
Havoc Pennington
5327b5d5f5 add a couple of trivial benchmarks
Basically they just reveal there's nothing worth
performance tuning here.
2011-11-12 18:01:03 -05:00
Havoc Pennington
7a63eab4ab buffer the reader instead of the stream
seems to make more sense since the reader could be smarter about it?
2011-11-12 18:00:07 -05:00
Havoc Pennington
926a726ea3 fork jvm for test, run, and test:run 2011-11-12 17:45:12 -05:00
Havoc Pennington
a706c74396 move new BufferedInputStream inside try{} block
Not sure this makes any material difference.
2011-11-12 17:44:43 -05:00
Havoc Pennington
d5fba4b8a7 buffer the input stream for loading properties 2011-11-12 17:44:18 -05:00
Havoc Pennington
b1b2403a5d add akka-reference.conf as a test case 2011-11-12 17:08:08 -05:00
Havoc Pennington
0d4feca770 if we get UnsupportedEncodingException include it as cause in the ConfigException
"Least likely thing to matter, ever"
2011-11-12 16:52:50 -05:00
Havoc Pennington
466a096398 add properties-style.conf test
Showing .conf format with a properties-looking style
2011-11-12 16:43:38 -05:00
Havoc Pennington
75a1b12284 Allow omitting commas as long as there's a newline 2011-11-12 16:36:07 -05:00
Havoc Pennington
16fa1cec0d test weird empty documents with whitespace and comments 2011-11-12 15:57:25 -05:00
Havoc Pennington
178cd17dad allow one comma after last element in object or array 2011-11-12 15:25:19 -05:00
Havoc Pennington
4051d07870 allow omitting curly braces on root object 2011-11-12 15:02:20 -05:00
Havoc Pennington
39de5aa444 allow omitting the colon if the value is an object 2011-11-12 14:36:45 -05:00
Havoc Pennington
55595e4c39 allow '=' in addition to ':' to separate key from value 2011-11-12 14:28:01 -05:00
Havoc Pennington
508c5910ad Support # and // comments 2011-11-12 12:06:56 -05:00
Havoc Pennington
796937f3ac prohibit /, #, and + from unquoted strings
because the spec proposes syntactic meanings for these
2011-11-12 10:05:39 -05:00
Havoc Pennington
be560731b8 add test for an array as not-first element of another array
Adds a line of coverage ;-)
2011-11-12 10:01:12 -05:00
Havoc Pennington
c27fa2cd68 fix a stray "return" in Scala that was making many tests not run
Then fix a few of the tests that now run. Fortunately the bugs
were all in the tests, not in the actual code.
2011-11-12 09:58:28 -05:00
Havoc Pennington
145cb40ec2 Implement include keyword 2011-11-12 09:57:57 -05:00
Havoc Pennington
5a51d590af make get() and getValue() on AbstractConfigObject return a more specific type 2011-11-12 09:26:36 -05:00
Havoc Pennington
795579f952 use SimpleConfigObject.empty() in one more spot 2011-11-12 08:39:13 -05:00
Havoc Pennington
c18f10c6dc Implement unquoted path keys, { foo.bar : 42 } 2011-11-12 01:42:43 -05:00
Havoc Pennington
a3128871ac allow duplicate keys in .conf with later key winning 2011-11-12 00:30:23 -05:00
Havoc Pennington
df3b3792da make resolveSubstitutions() do nothing on already-resolved objects.
This way if people resolve() gratuitously, there's no performance
issue. Also, tracking resolved state gives us the option to complain
about usage of unresolved objects.
2011-11-11 23:57:49 -05:00
Havoc Pennington
10babb5e8c rename Unresolved to Unmergeable 2011-11-11 22:58:26 -05:00
Havoc Pennington
9cf7b4d65a implement transformed() with a protected newCopy method instead of wrapper object 2011-11-11 22:28:23 -05:00
Havoc Pennington
839c588277 add a ConfigRoot type returned by load()
The point is to only support the resolve() method on the root object.
2011-11-11 22:11:57 -05:00
Havoc Pennington
529b3b1f55 completely drop "transformer" arg to ConfigObject constructors
If you want to change the transformer, use the transformed() method.
2011-11-11 17:28:00 -05:00
Havoc Pennington
8c00a97243 clean up merge() so it doesn't need origin or transformer
origin can be computed by combining origins of merged values.

transformer should be set prior to merge; probably it should
be an error to merge with mismatched transformers.
2011-11-11 17:18:26 -05:00