Commit Graph

903 Commits

Author SHA1 Message Date
Havoc Pennington
2a635478dd fix bug in locating resource includes relative to parent classpath resource
also add various tests related to the parseables
2011-11-21 09:08:43 -05:00
Havoc Pennington
0684ffbea1 make "unresolved subst" exception suggest calling resolve()
this way it's clear what the problem is.
2011-11-19 15:02:12 -05:00
Havoc Pennington
bb43762608 un-hose the test code checking that withFallback is associative and use it more
withFallback didn't used to be reliably associative but now it should be.
2011-11-19 15:01:12 -05:00
Havoc Pennington
f6e3ab48cd make doc task complain about how you should use javadoc 2011-11-18 18:34:30 -05:00
Havoc Pennington
037357c59f Add javadoc task, using self-built jar of javadoc-sbt
javadoc-sbt commit id was 138e530bba49a4d77900415e4c600c45f5ce8667
2011-11-18 18:27:27 -05:00
Havoc Pennington
c16b305c0d add a few more test assertions for withFallback 2011-11-18 17:52:46 -05:00
Havoc Pennington
4f623d9dd5 throw exception if you getInt() and the int is out of range 2011-11-18 17:49:40 -05:00
Havoc Pennington
13362f46b4 fix the example API usage in the README 2011-11-18 17:49:40 -05:00
Havoc Pennington
8b6f4c6156 Refactor withFallback() implementations to share more logic among subtypes
Also add some tests and fix some correctness issues.

If we fall back to a value that has ignoresFallbacks()=true, then we need
to "catch" its ignoresFallbacks.

Don't create new RootConfig objects if the underlying has not changed.

Get rid of ConfigImpl.merge() utility, no longer useful.
2011-11-18 17:46:11 -05:00
Havoc Pennington
7df8e342f6 remove withFallbacks() convenience method
since withFallback() now works properly, it's easy
to do things without withFallbacks().
2011-11-18 17:44:21 -05:00
Havoc Pennington
4b9e5ec325 Fix withFallback() to avoid the mess where it has to be called from the bottom up.
Make ConfigObject have an includeFallbacks flag for whether it has
"ended" and will no longer merge anything.
2011-11-18 17:44:21 -05:00
Havoc Pennington
dc5098d52f put .settings in .gitignore 2011-11-18 17:44:21 -05:00
Havoc Pennington
d4bfdab913 add copyright comment to top of all files 2011-11-18 09:20:02 -05:00
Havoc Pennington
278db76719 add parseFileAnySyntax and parseResourceAnySyntax
To parse a basename.{conf,json,properties}
2011-11-17 23:33:11 -05:00
Havoc Pennington
d700404242 fix AbstractConfigValue.withFallbacks and clean up ConfigDelayedMerge withFallback
Had previously fixed AbstractConfigObject.merge() in the same way. For this
patch, factor out the code from AbstractConfigObject and use it everywhere.

Add some tests for merges with substitutions involved.

Also write some docs for ConfigMergeable explaining the easy way
to do it wrong.
2011-11-17 23:09:29 -05:00
Havoc Pennington
f6395d629d make ConfigException.Null extend Missing instead of WrongType
WrongType makes sense in the context of ConfigObject, but
Missing makes sense in the context of Config.
2011-11-17 21:45:07 -05:00
Havoc Pennington
7cdbe721a9 add ConfigFactory.parseString 2011-11-17 21:33:36 -05:00
Havoc Pennington
31b9ccf983 rename parse() methods to parseFoo()
for clarity and to avoid overload ambiguity
2011-11-17 21:31:45 -05:00
Havoc Pennington
adb80f6017 Split Config out of ConfigObject.
This separates ConfigObject, which is:
  - a tree of maps
  - that can contain ConfigValueType.NULL

from Config, which is:
  - a one-level map from path to non-map values
  - which never returns a ConfigValueType.NULL
2011-11-17 21:16:44 -05:00
Havoc Pennington
2381cf7785 Create Config, SimpleConfig and associate a Config with every ConfigObject. 2011-11-17 15:04:33 -05:00
Havoc Pennington
7d5f72e248 Add Config.fromPathMap() which takes map with paths
Share implementation of this with the Properties parser;
it makes the Properties parser somewhat less efficient due
to creating the intermediate Path objects, but should not matter.
2011-11-17 12:09:12 -05:00
Havoc Pennington
88e81d7c67 add Path.parent() and Path.last() methods
Neither is very efficient, but we'll live.
2011-11-17 12:08:27 -05:00
Havoc Pennington
d8e54099e9 add more docs about paths vs. keys 2011-11-17 10:36:06 -05:00
Havoc Pennington
2886f73772 improve some path-related error messages 2011-11-17 10:15:41 -05:00
Havoc Pennington
159bec9d03 an explicit { HOME : null } should block lookup of ${HOME} in the environment. 2011-11-17 00:56:44 -05:00
Havoc Pennington
5f6f718566 fix some indentation that Eclipse messed up 2011-11-17 00:50:47 -05:00
Havoc Pennington
817bbb73eb prohibit control characters in quoted strings per JSON spec 2011-11-17 00:44:19 -05:00
Havoc Pennington
c3fe5509a7 test that ConfigParseOptions.setIncluder works. 2011-11-17 00:19:52 -05:00
Havoc Pennington
c5fc564c56 Fix Parseable.parse() to use passed-in options
This was causing at least a couple bugs; in one test, a properties file
was being parsed with conf syntax; and includes suddenly could not
be missing if the parent file could not be missing.
2011-11-16 23:47:55 -05:00
Havoc Pennington
0bb9d19727 test "10.0foo" path expression, and correct the spec
The spec described parsing this as a 1-element path but
the implementation parsed it as 2 elements which is probably
a better behavior because it's less surprising. The simple
rule is now "only quoted periods are special".
2011-11-16 23:23:46 -05:00
Havoc Pennington
9dc6f77078 Fix behavior when merging object,primitive,object.
The AbstractConfigObject.merge() method was wrong; it merged in the
wrong order, which produced incorrect results. But there was a test
verifying that the results were wrong! So it's OK right?
Anyway, fix the test, fix the code, be sure it's crystal clear in spec.
2011-11-16 22:07:14 -05:00
Havoc Pennington
e1329e54bf test the current behavior of duplicate keys set to object, then primitive, then object 2011-11-16 21:25:29 -05:00
Havoc Pennington
4676023f1c add the Play 1.2 "yabe" example application.conf as test05.conf 2011-11-16 21:11:06 -05:00
Havoc Pennington
e782f6c1ad fix line numbers in error messages. (start with 1.) 2011-11-16 21:04:59 -05:00
Havoc Pennington
e1628ee6de use newNumber when doing fromAnyRef on a Number with unknown subclass 2011-11-16 15:08:50 -05:00
Havoc Pennington
d1e12fdd36 move newNumber to ConfigNumber rather than AbstractConfigValue 2011-11-16 15:08:29 -05:00
Havoc Pennington
3610dc8d76 support "/" in unquoted strings (and therefore keys) 2011-11-16 11:03:16 -05:00
Havoc Pennington
20b75542e4 support "on" and "off" when converting string to boolean 2011-11-16 10:34:40 -05:00
Havoc Pennington
61b1281e90 Convert numbers to ConfigInt when possible, then ConfigLong, and ConfigDouble only when required
Had to overhaul and clean up equality of ConfigNumber as part of this.
2011-11-16 10:05:44 -05:00
Havoc Pennington
054e27ccd0 add comment about not having ConfigValue.parent() 2011-11-16 09:36:06 -05:00
Havoc Pennington
b7a73dc85b remove pluggable ConfigTransformer
Doesn't seem to have a useful purpose, was a bad idea.
Just hardcode the built-in automatic type conversions.
2011-11-16 09:33:18 -05:00
Havoc Pennington
ece196c146 mention foo.bar=10, foo.baz=12 style syntax (single line properties-style) 2011-11-15 23:35:24 -05:00
Havoc Pennington
ae10fadc04 two tests were identical, make them different again 2011-11-15 23:33:19 -05:00
Havoc Pennington
f81ab20caa implement ConfigObject.hasPath() 2011-11-15 23:30:03 -05:00
Havoc Pennington
f32c8bdd78 fix parsing of empty string path, and fix test suite which wasn't catching it 2011-11-15 23:28:08 -05:00
Havoc Pennington
e9fe426f7f fix unicodeTrim on all-whitespace strings 2011-11-15 23:26:43 -05:00
Havoc Pennington
41b9d5c68b Implement fromAnyRef and friends to wrap values in ConfigValue. 2011-11-15 22:46:53 -05:00
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