configtoolkit 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/FAQ.txt +113 -25
  2. data/Hash.txt +128 -0
  3. data/History.txt +45 -2
  4. data/KeyValue.txt +235 -0
  5. data/Manifest.txt +66 -4
  6. data/README.txt +666 -202
  7. data/Rakefile +3 -5
  8. data/Ruby.txt +172 -0
  9. data/YAML.txt +188 -0
  10. data/examples/hash_example.rb +71 -0
  11. data/examples/key_value_example.dump.cfg +5 -0
  12. data/examples/key_value_example.normal1.cfg +20 -0
  13. data/examples/key_value_example.normal2.cfg +15 -0
  14. data/examples/key_value_example.rb +72 -0
  15. data/examples/key_value_example.wacky.cfg +13 -0
  16. data/examples/load_example.rb +32 -0
  17. data/examples/load_example.yaml +34 -0
  18. data/examples/load_group_example.rb +28 -0
  19. data/examples/load_group_example.yaml +33 -0
  20. data/examples/machineconfig.rb +77 -0
  21. data/examples/ruby_example.rb +32 -0
  22. data/examples/ruby_example.rcfg +52 -0
  23. data/examples/usage_example.rb +93 -0
  24. data/examples/yaml_example.dump.yaml +12 -0
  25. data/examples/yaml_example.rb +48 -0
  26. data/examples/yaml_example.yaml +59 -0
  27. data/lib/configtoolkit.rb +1 -1
  28. data/lib/configtoolkit/baseconfig.rb +522 -418
  29. data/lib/configtoolkit/hasharrayvisitor.rb +242 -0
  30. data/lib/configtoolkit/hashreader.rb +41 -0
  31. data/lib/configtoolkit/hashwriter.rb +45 -0
  32. data/lib/configtoolkit/keyvalueconfig.rb +105 -0
  33. data/lib/configtoolkit/keyvaluereader.rb +597 -0
  34. data/lib/configtoolkit/keyvaluewriter.rb +157 -0
  35. data/lib/configtoolkit/prettyprintwriter.rb +167 -0
  36. data/lib/configtoolkit/reader.rb +62 -0
  37. data/lib/configtoolkit/rubyreader.rb +270 -0
  38. data/lib/configtoolkit/types.rb +42 -26
  39. data/lib/configtoolkit/writer.rb +116 -0
  40. data/lib/configtoolkit/yamlreader.rb +10 -6
  41. data/lib/configtoolkit/yamlwriter.rb +113 -71
  42. data/test/bad_array_index.rcfg +1 -0
  43. data/test/bad_containing_object_assignment.rcfg +2 -0
  44. data/test/bad_directive.cfg +1 -0
  45. data/test/bad_include1.cfg +2 -0
  46. data/test/bad_include2.cfg +3 -0
  47. data/test/bad_parameter_reference.rcfg +1 -0
  48. data/test/contained_sample.cfg +10 -0
  49. data/test/contained_sample.pretty_print +30 -0
  50. data/test/contained_sample.rcfg +22 -0
  51. data/test/contained_sample.yaml +22 -21
  52. data/test/containers.cfg +6 -0
  53. data/test/exta_string_after_container.cfg +2 -0
  54. data/test/extra_container_closing.cfg +2 -0
  55. data/test/extra_string_after_container.cfg +2 -0
  56. data/test/extra_string_after_nested_container.cfg +1 -0
  57. data/test/missing_array_closing.cfg +2 -0
  58. data/test/missing_array_element.cfg +2 -0
  59. data/test/missing_directive.cfg +1 -0
  60. data/test/missing_hash_closing.cfg +2 -0
  61. data/test/missing_hash_element.cfg +2 -0
  62. data/test/missing_hash_value.cfg +1 -0
  63. data/test/missing_include_argument.cfg +1 -0
  64. data/test/missing_key_value_delimiter.cfg +1 -0
  65. data/test/readerwritertest.rb +28 -7
  66. data/test/sample.cfg +10 -0
  67. data/test/sample.pretty_print +30 -0
  68. data/test/sample.rcfg +26 -0
  69. data/test/test_baseconfig.rb +152 -38
  70. data/test/test_hash.rb +82 -0
  71. data/test/test_keyvalue.rb +185 -0
  72. data/test/test_prettyprint.rb +28 -0
  73. data/test/test_ruby.rb +50 -0
  74. data/test/test_yaml.rb +33 -26
  75. data/test/wacky_sample1.cfg +16 -0
  76. data/test/wacky_sample2.cfg +5 -0
  77. data/test/wacky_sample3.cfg +4 -0
  78. data/test/wacky_sample4.cfg +1 -0
  79. metadata +101 -10
  80. data/lib/configtoolkit/toolkit.rb +0 -20
  81. data/test/common.rb +0 -5
data/test/test_hash.rb ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'readerwritertest'
4
+
5
+ require 'configtoolkit/hashreader'
6
+ require 'configtoolkit/hashwriter'
7
+
8
+ class HASHTest < Test::Unit::TestCase
9
+ include ReaderWriterTest
10
+
11
+ SAMPLE_CONFIG_HASH = {
12
+ :req_integer => 6,
13
+ :req_big_integer => 90000000000,
14
+ :req_float => 3.14,
15
+ :req_string => "sample string2",
16
+ :req_boolean => true,
17
+ :req_pathname => Pathname.new("/usr/designingpatterns/bin"),
18
+ :req_uri => URI("http://blogs.designingpatterns.com"),
19
+ :req_symbol => :sample_symbol2,
20
+ :nested_config => {
21
+ :req_nested_integer => 34,
22
+ :req_nested_array => [
23
+ {
24
+ :req_second_nested_pathname => Pathname.new("/usr/designingpatterns/Applications/pattmake"),
25
+ :req_second_nested_array => [6, 20]
26
+ },
27
+ {
28
+ :req_second_nested_pathname => Pathname.new("/usr"),
29
+ :req_second_nested_array => [205, 206]
30
+ }
31
+ ]
32
+ },
33
+ :opt_integer => 56
34
+ }
35
+
36
+ CONTAINED_SAMPLE_CONFIG_HASH = {
37
+ :first => {
38
+ :second => {
39
+ :req_integer => 5,
40
+ :req_big_integer => 10000000000,
41
+ :req_float => 5.678,
42
+ :req_string => "sample string",
43
+ :req_boolean => false,
44
+ :req_pathname => Pathname.new("/usr/designingpatterns"),
45
+ :req_uri => URI("http://www.designingpatterns.com"),
46
+ :req_symbol => :sample_symbol,
47
+ :nested_config => {
48
+ :req_nested_integer => 33,
49
+ :req_nested_array => [
50
+ {
51
+ :req_second_nested_pathname => Pathname.new("/usr/designingpatterns/Applications"),
52
+ :req_second_nested_array => [5, 19]
53
+ },
54
+ {
55
+ :req_second_nested_pathname => Pathname.new("/usr/designingpatterns/Applications/etc"),
56
+ :req_second_nested_array => [200, 201]
57
+ }
58
+ ]
59
+ },
60
+ :opt_integer => 42
61
+ }
62
+ }
63
+ }
64
+
65
+ def test_reader_writer
66
+ run_reader_test(ConfigToolkit::HashReader,
67
+ "",
68
+ REFERENCE_SAMPLE_CONFIG,
69
+ SAMPLE_CONFIG_HASH)
70
+
71
+ writer = ConfigToolkit::HashWriter.new()
72
+ REFERENCE_SAMPLE_CONFIG.dump(writer)
73
+ assert_equal(SAMPLE_CONFIG_HASH, writer.config_hash)
74
+
75
+ run_reader_test(ConfigToolkit::HashReader,
76
+ "first.second",
77
+ REFERENCE_CONTAINED_SAMPLE_CONFIG,
78
+ CONTAINED_SAMPLE_CONFIG_HASH)
79
+ REFERENCE_CONTAINED_SAMPLE_CONFIG.dump(writer)
80
+ assert_equal(CONTAINED_SAMPLE_CONFIG_HASH, writer.config_hash)
81
+ end
82
+ end
@@ -0,0 +1,185 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'readerwritertest'
4
+
5
+ require 'configtoolkit/keyvaluereader'
6
+ require 'configtoolkit/keyvaluewriter'
7
+ require 'configtoolkit/hashreader'
8
+
9
+ require 'rubygems'
10
+ require 'assertions'
11
+ require 'relative'
12
+
13
+ class KeyValueTest < Test::Unit::TestCase
14
+ include ReaderWriterTest
15
+
16
+ WACKY_KEY_VALUE_CONFIG = ConfigToolkit::KeyValueConfig.load(
17
+ ConfigToolkit::HashReader.new(:key_value_delimiter => ":>",
18
+ :comment_line_prefix => ";;",
19
+ :directive_line_prefix => "##",
20
+ :array_opening => "(",
21
+ :array_closing => "|",
22
+ :hash_opening => "+",
23
+ :hash_closing => "-",
24
+ :hash_key_value_delimiter => ">>>>")
25
+ )
26
+
27
+ def test_reader
28
+ run_reader_test(ConfigToolkit::KeyValueReader,
29
+ "",
30
+ REFERENCE_SAMPLE_CONFIG,
31
+ File.expand_path_relative_to_caller("sample.cfg"))
32
+
33
+ run_reader_test(ConfigToolkit::KeyValueReader,
34
+ "",
35
+ REFERENCE_SAMPLE_CONFIG,
36
+ File.new(File.expand_path_relative_to_caller("sample.cfg"), "r"))
37
+
38
+ run_reader_test(ConfigToolkit::KeyValueReader,
39
+ "first.second",
40
+ REFERENCE_CONTAINED_SAMPLE_CONFIG,
41
+ File.expand_path_relative_to_caller("contained_sample.cfg"))
42
+
43
+ #
44
+ # Try reading a config file containing REFERENCE_SAMPLE_CONFIG but using
45
+ # a wacky key-value format.
46
+ #
47
+ wacky_reader = ConfigToolkit::KeyValueReader.new(File.expand_path_relative_to_caller("wacky_sample1.cfg"), WACKY_KEY_VALUE_CONFIG)
48
+ config = SampleConfig.load(wacky_reader)
49
+ assert_equal(REFERENCE_SAMPLE_CONFIG, config)
50
+ end
51
+
52
+ def verify_reader_error(file_name, reader_config, message)
53
+ reader = ConfigToolkit::KeyValueReader.new(file_name, reader_config)
54
+
55
+ assert_raise_message(message, ConfigToolkit::Error) do
56
+ reader.read()
57
+ end
58
+ end
59
+
60
+ def test_containers
61
+ #
62
+ # Read the same config file, once with containers allowed (default) and
63
+ # once without. Verify that the results reflect whether or not containers
64
+ # are allowed.
65
+ #
66
+ reader = ConfigToolkit::KeyValueReader.new(File.expand_path_relative_to_caller("containers.cfg"))
67
+ assert_equal({:favorite_ice_cream => {:flavor => "butter pecan", :topping= => "caramel"}}, reader.read())
68
+
69
+ config = ConfigToolkit::KeyValueConfig.load(ConfigToolkit::HashReader.new(:allow_containers => false))
70
+ reader = ConfigToolkit::KeyValueReader.new(File.expand_path_relative_to_caller("containers.cfg"), config)
71
+ assert_equal({:favorite_ice_cream => "{flavor => butter pecan, topping= => caramel}"}, reader.read())
72
+ end
73
+
74
+ def test_reader_errors
75
+ path = File.expand_path_relative_to_caller("missing_include_argument.cfg")
76
+ verify_reader_error(path,
77
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
78
+ "Error parsing line #1 of #{path}: missing filename for include directive!")
79
+
80
+ path = File.expand_path_relative_to_caller("bad_include1.cfg")
81
+ bad_path = File.expand_path_relative_to_caller("bad_include2.cfg")
82
+ verify_reader_error(path,
83
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
84
+ "Error parsing line #3 of #{bad_path}: missing key-value delimiter '='!")
85
+
86
+ path = File.expand_path_relative_to_caller("bad_directive.cfg")
87
+ verify_reader_error(path,
88
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
89
+ "Error parsing line #1 of #{path}: unknown directive 'bogus'!")
90
+
91
+ path = File.expand_path_relative_to_caller("extra_container_closing.cfg")
92
+ verify_reader_error(path,
93
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
94
+ "Error parsing line #2 of #{path}: unmatched '}'!")
95
+
96
+ path = File.expand_path_relative_to_caller("extra_string_after_nested_container.cfg")
97
+ verify_reader_error(path,
98
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
99
+ "Error parsing line #1 of #{path}: extraneous character 'b' after container!")
100
+
101
+ path = File.expand_path_relative_to_caller("extra_string_after_container.cfg")
102
+ verify_reader_error(path,
103
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
104
+ "Error parsing line #2 of #{path}: extraneous string 'abcd' after container!")
105
+
106
+ path = File.expand_path_relative_to_caller("missing_hash_value.cfg")
107
+ verify_reader_error(path,
108
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
109
+ "Error parsing line #1 of #{path}: hash key 'topping' is missing a value!")
110
+
111
+ path = File.expand_path_relative_to_caller("missing_hash_element.cfg")
112
+ verify_reader_error(path,
113
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
114
+ "Error parsing line #2 of #{path}: missing container element before ','!")
115
+
116
+ path = File.expand_path_relative_to_caller("missing_array_element.cfg")
117
+ verify_reader_error(path,
118
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
119
+ "Error parsing line #2 of #{path}: missing container element before ','!")
120
+
121
+ path = File.expand_path_relative_to_caller("missing_hash_closing.cfg")
122
+ verify_reader_error(path,
123
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
124
+ "Error parsing line #2 of #{path}: missing hash closing '}'!")
125
+
126
+ path = File.expand_path_relative_to_caller("missing_array_closing.cfg")
127
+ verify_reader_error(path,
128
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
129
+ "Error parsing line #2 of #{path}: missing array closing ']'!")
130
+
131
+ path = File.expand_path_relative_to_caller("missing_directive.cfg")
132
+ verify_reader_error(path,
133
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
134
+ "Error parsing line #1 of #{path}: missing directive on line starting with directive prefix '*'!")
135
+
136
+ path = File.expand_path_relative_to_caller("missing_key_value_delimiter.cfg")
137
+ verify_reader_error(path,
138
+ ConfigToolkit::KeyValueConfig::DEFAULT_CONFIG,
139
+ "Error parsing line #1 of #{path}: missing key-value delimiter '='!")
140
+
141
+ assert_raise_message("Error parsing line #1 of <unknown>: only can process relative include directives in File streams!", ConfigToolkit::Error) do
142
+ string_stream = StringIO.new("*include bogus")
143
+ ConfigToolkit::KeyValueReader.new(string_stream).read()
144
+ end
145
+ end
146
+
147
+
148
+ def test_writer
149
+ run_writer_test(ConfigToolkit::KeyValueWriter,
150
+ :sort_lines_and_line_contents,
151
+ REFERENCE_SAMPLE_CONFIG,
152
+ File.expand_path_relative_to_caller("sample.cfg"),
153
+ File.expand_path_relative_to_caller("sample.dumped.cfg"),
154
+ File.expand_path_relative_to_caller("sample.dumped.cfg"))
155
+
156
+ run_writer_test(ConfigToolkit::KeyValueWriter,
157
+ :sort_lines_and_line_contents,
158
+ REFERENCE_CONTAINED_SAMPLE_CONFIG,
159
+ File.expand_path_relative_to_caller("contained_sample.cfg"),
160
+ File.expand_path_relative_to_caller("contained_sample.dumped.cfg"),
161
+ File.expand_path_relative_to_caller("contained_sample.dumped.cfg"))
162
+ end
163
+
164
+ def test_reader_writer
165
+ run_reader_writer_test(ConfigToolkit::KeyValueReader,
166
+ ConfigToolkit::KeyValueWriter,
167
+ REFERENCE_SAMPLE_CONFIG,
168
+ [File.expand_path_relative_to_caller("sample.cfg")],
169
+ [File.expand_path_relative_to_caller("sample.dumped.cfg")])
170
+
171
+ run_reader_writer_test(ConfigToolkit::KeyValueReader,
172
+ ConfigToolkit::KeyValueWriter,
173
+ REFERENCE_SAMPLE_CONFIG,
174
+ [File.expand_path_relative_to_caller("wacky_sample1.cfg"),
175
+ WACKY_KEY_VALUE_CONFIG],
176
+ [File.expand_path_relative_to_caller("wacky_sample.dumped.cfg"),
177
+ WACKY_KEY_VALUE_CONFIG])
178
+
179
+ run_reader_writer_test(ConfigToolkit::KeyValueReader,
180
+ ConfigToolkit::KeyValueWriter,
181
+ REFERENCE_CONTAINED_SAMPLE_CONFIG,
182
+ [File.expand_path_relative_to_caller("contained_sample.cfg")],
183
+ [File.expand_path_relative_to_caller("contained_sample.dumped.cfg")])
184
+ end
185
+ end
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'readerwritertest'
4
+
5
+ require 'configtoolkit/prettyprintwriter'
6
+
7
+ require 'rubygems'
8
+ require 'relative'
9
+
10
+ class PrettyPrintTest < Test::Unit::TestCase
11
+ include ReaderWriterTest
12
+
13
+ def test_writer
14
+ run_writer_test(ConfigToolkit::PrettyPrintWriter,
15
+ :sort_lines,
16
+ REFERENCE_SAMPLE_CONFIG,
17
+ File.expand_path_relative_to_caller("sample.pretty_print"),
18
+ File.expand_path_relative_to_caller("sample.dumped.pretty_print"),
19
+ File.expand_path_relative_to_caller("sample.dumped.pretty_print"))
20
+
21
+ run_writer_test(ConfigToolkit::PrettyPrintWriter,
22
+ :sort_lines,
23
+ REFERENCE_CONTAINED_SAMPLE_CONFIG,
24
+ File.expand_path_relative_to_caller("contained_sample.pretty_print"),
25
+ File.expand_path_relative_to_caller("contained_sample.dumped.pretty_print"),
26
+ File.expand_path_relative_to_caller("contained_sample.dumped.pretty_print"))
27
+ end
28
+ end
data/test/test_ruby.rb ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'readerwritertest'
4
+
5
+ require 'configtoolkit/rubyreader'
6
+
7
+ require 'rubygems'
8
+ require 'assertions'
9
+ require 'relative'
10
+
11
+ class RubyTest < Test::Unit::TestCase
12
+ include ReaderWriterTest
13
+
14
+ def test_reader
15
+ run_reader_test(ConfigToolkit::RubyReader,
16
+ "",
17
+ REFERENCE_SAMPLE_CONFIG,
18
+ File.expand_path_relative_to_caller("sample.rcfg"))
19
+
20
+ run_reader_test(ConfigToolkit::RubyReader,
21
+ "",
22
+ REFERENCE_SAMPLE_CONFIG,
23
+ File.new(File.expand_path_relative_to_caller("sample.rcfg"), "r"))
24
+
25
+ run_reader_test(ConfigToolkit::RubyReader,
26
+ "first.second",
27
+ REFERENCE_CONTAINED_SAMPLE_CONFIG,
28
+ File.expand_path_relative_to_caller("contained_sample.rcfg"))
29
+ end
30
+
31
+ def verify_reader_error(file_name, message)
32
+ reader = ConfigToolkit::RubyReader.new(file_name)
33
+
34
+ assert_raise_message(message, ConfigToolkit::Error) do
35
+ reader.read()
36
+ end
37
+ end
38
+
39
+ def test_reader_errors
40
+ verify_reader_error(File.expand_path_relative_to_caller("bad_containing_object_assignment.rcfg"),
41
+ "cannot assign to object config.first.second")
42
+
43
+ verify_reader_error(File.expand_path_relative_to_caller("bad_array_index.rcfg"),
44
+ "cannot index with array notation into config.unknown_array")
45
+
46
+ assert_raise(NoMethodError) do
47
+ ConfigToolkit::RubyReader.new(File.expand_path_relative_to_caller("bad_parameter_reference.rcfg")).read()
48
+ end
49
+ end
50
+ end
data/test/test_yaml.rb CHANGED
@@ -1,76 +1,83 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'common'
4
3
  require 'readerwritertest'
5
4
 
6
5
  require 'configtoolkit/yamlreader'
7
6
  require 'configtoolkit/yamlwriter'
8
7
 
8
+ require 'rubygems'
9
+ require 'assertions'
10
+ require 'relative'
11
+
9
12
  class YAMLTest < Test::Unit::TestCase
10
13
  include ReaderWriterTest
11
14
 
12
- def test_readers
15
+ def test_reader
13
16
  run_reader_test(ConfigToolkit::YAMLReader,
14
17
  "",
15
18
  REFERENCE_SAMPLE_CONFIG,
16
- get_test_config_file_name("sample.standard_yaml_classes.yaml"))
19
+ File.expand_path_relative_to_caller("sample.standard_yaml_classes.yaml"))
17
20
 
18
21
  run_reader_test(ConfigToolkit::YAMLReader,
19
22
  "",
20
23
  REFERENCE_SAMPLE_CONFIG,
21
- get_test_config_file_name("sample.ruby_yaml_classes.yaml"))
24
+ File.expand_path_relative_to_caller("sample.ruby_yaml_classes.yaml"))
22
25
 
23
26
  run_reader_test(ConfigToolkit::YAMLReader,
24
27
  "",
25
28
  REFERENCE_SAMPLE_CONFIG,
26
- File.new(get_test_config_file_name("sample.ruby_yaml_classes.yaml"), "r"))
29
+ File.new(File.expand_path_relative_to_caller("sample.ruby_yaml_classes.yaml"), "r"))
27
30
 
28
31
  run_reader_test(ConfigToolkit::YAMLReader,
29
- "contained_sample",
32
+ "first.second",
30
33
  REFERENCE_CONTAINED_SAMPLE_CONFIG,
31
- get_test_config_file_name("contained_sample.yaml"))
34
+ File.expand_path_relative_to_caller("contained_sample.yaml"))
32
35
  end
33
-
34
- def test_writers
36
+
37
+ def test_writer
35
38
  run_writer_test(ConfigToolkit::YAMLWriter,
39
+ :sort_lines,
36
40
  REFERENCE_SAMPLE_CONFIG,
37
- get_test_config_file_name("sample.standard_yaml_classes.yaml"),
38
- get_test_config_file_name("sample.standard_yaml_classes.dumped.yaml"),
39
- get_test_config_file_name("sample.standard_yaml_classes.dumped.yaml"),
41
+ File.expand_path_relative_to_caller("sample.standard_yaml_classes.yaml"),
42
+ File.expand_path_relative_to_caller("sample.standard_yaml_classes.dumped.yaml"),
43
+ File.expand_path_relative_to_caller("sample.standard_yaml_classes.dumped.yaml"),
40
44
  true)
41
45
 
42
46
  run_writer_test(ConfigToolkit::YAMLWriter,
47
+ :sort_lines,
43
48
  REFERENCE_SAMPLE_CONFIG,
44
- get_test_config_file_name("sample.ruby_yaml_classes.yaml"),
45
- get_test_config_file_name("sample.ruby_yaml_classes.dumped.yaml"),
46
- get_test_config_file_name("sample.ruby_yaml_classes.dumped.yaml"),
49
+ File.expand_path_relative_to_caller("sample.ruby_yaml_classes.yaml"),
50
+ File.expand_path_relative_to_caller("sample.ruby_yaml_classes.dumped.yaml"),
51
+ File.expand_path_relative_to_caller("sample.ruby_yaml_classes.dumped.yaml"),
47
52
  false)
48
53
 
49
54
  run_writer_test(ConfigToolkit::YAMLWriter,
55
+ :sort_lines,
50
56
  REFERENCE_SAMPLE_CONFIG,
51
- get_test_config_file_name("sample.standard_yaml_classes.yaml"),
52
- get_test_config_file_name("sample.standard_yaml_classes.dumped.yaml"),
53
- File.new(get_test_config_file_name("sample.standard_yaml_classes.dumped.yaml"), "w"),
57
+ File.expand_path_relative_to_caller("sample.standard_yaml_classes.yaml"),
58
+ File.expand_path_relative_to_caller("sample.standard_yaml_classes.dumped.yaml"),
59
+ File.new(File.expand_path_relative_to_caller("sample.standard_yaml_classes.dumped.yaml"), "w"),
54
60
  true)
55
61
 
56
62
  run_writer_test(ConfigToolkit::YAMLWriter,
63
+ :sort_lines,
57
64
  REFERENCE_CONTAINED_SAMPLE_CONFIG,
58
- get_test_config_file_name("contained_sample.yaml"),
59
- get_test_config_file_name("contained_sample.dumped.yaml"),
60
- get_test_config_file_name("contained_sample.dumped.yaml"),
65
+ File.expand_path_relative_to_caller("contained_sample.yaml"),
66
+ File.expand_path_relative_to_caller("contained_sample.dumped.yaml"),
67
+ File.expand_path_relative_to_caller("contained_sample.dumped.yaml"),
61
68
  true)
62
69
  end
63
70
 
64
- def test_readers_writers
71
+ def test_reader_writer
65
72
  run_reader_writer_test(ConfigToolkit::YAMLReader,
66
73
  ConfigToolkit::YAMLWriter,
67
74
  REFERENCE_SAMPLE_CONFIG,
68
- [get_test_config_file_name("sample.standard_yaml_classes.dumped.yaml")],
69
- [get_test_config_file_name("sample.standard_yaml_classes.dumped.yaml"), false])
75
+ [File.expand_path_relative_to_caller("sample.standard_yaml_classes.dumped.yaml")],
76
+ [File.expand_path_relative_to_caller("sample.standard_yaml_classes.dumped.yaml"), false])
70
77
  run_reader_writer_test(ConfigToolkit::YAMLReader,
71
78
  ConfigToolkit::YAMLWriter,
72
79
  REFERENCE_CONTAINED_SAMPLE_CONFIG,
73
- [get_test_config_file_name("contained_sample.yaml")],
74
- [get_test_config_file_name("contained_sample.dumped.yaml"), true])
80
+ [File.expand_path_relative_to_caller("contained_sample.yaml")],
81
+ [File.expand_path_relative_to_caller("contained_sample.dumped.yaml"), true])
75
82
  end
76
83
  end