rkwalify 1.4.0.pre.preview1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +39 -0
  3. data/.gitignore +61 -0
  4. data/.overcommit.yml +33 -0
  5. data/.rubocop.yml +9 -0
  6. data/.rubocop_todo.yml +1369 -0
  7. data/.ruby-version +1 -0
  8. data/Attic/README-0.7.2.md +53 -0
  9. data/Attic/features/cli.feature +9 -0
  10. data/Attic/features/step_definitions/validation_steps.rb +20 -0
  11. data/Attic/features/support/env.rb +4 -0
  12. data/Attic/features/validate_schema.feature +12 -0
  13. data/Attic/s+h +53 -0
  14. data/Attic/setup.rb +1556 -0
  15. data/Attic/spec/my_cli_tool_spec.rb +52 -0
  16. data/Attic/spec/rspec-ex_spec.rb +10 -0
  17. data/Attic/spec/spec_helper.rb +104 -0
  18. data/Attic/test-15.1.rb +28 -0
  19. data/CHANGELOG.md +292 -0
  20. data/CONTRIBUTING.md +23 -0
  21. data/CONTRIBUTORS.md +8 -0
  22. data/Gemfile +16 -0
  23. data/Gemfile.lock +146 -0
  24. data/MIT-LICENSE +21 -0
  25. data/README.md +53 -0
  26. data/ROLL-OUT-STRATEGY.md +77 -0
  27. data/Rakefile +11 -0
  28. data/bin/kwalify.rb +4167 -0
  29. data/bin/kwalify.schema.yaml +59 -0
  30. data/contrib/inline-require +181 -0
  31. data/contrib/kwalify +4167 -0
  32. data/contrib/kwalify-0.7.2 +4160 -0
  33. data/devbin/README.md +22 -0
  34. data/devbin/chk-rad-repo.sh +20 -0
  35. data/devbin/chkcopyrights.sh +42 -0
  36. data/devbin/chkspelling.sh +16 -0
  37. data/devbin/got-all-rel-numbers.sh +5 -0
  38. data/devbin/mkbig-rkwalify.sh +7 -0
  39. data/devbin/mkgem_file.sh +5 -0
  40. data/devbin/runtests.sh +6 -0
  41. data/devbin/ug-tests.golden +242 -0
  42. data/devbin/ug-tests.sh +145 -0
  43. data/devbin/update-rel-numbers.sh +7 -0
  44. data/doc/docstyle.css +188 -0
  45. data/doc/img/fig01.png +0 -0
  46. data/doc/users-guide.html +2051 -0
  47. data/doc-api/classes/CommandOptionError.html +184 -0
  48. data/doc-api/classes/CommandOptionParser.html +325 -0
  49. data/doc-api/classes/Kwalify/AssertionError.html +148 -0
  50. data/doc-api/classes/Kwalify/BaseError.html +297 -0
  51. data/doc-api/classes/Kwalify/BaseParser.html +461 -0
  52. data/doc-api/classes/Kwalify/CommandOptionError.html +168 -0
  53. data/doc-api/classes/Kwalify/ErrorHelper.html +223 -0
  54. data/doc-api/classes/Kwalify/HashInterface.html +118 -0
  55. data/doc-api/classes/Kwalify/Json.html +105 -0
  56. data/doc-api/classes/Kwalify/KwalifyError.html +111 -0
  57. data/doc-api/classes/Kwalify/Main.html +339 -0
  58. data/doc-api/classes/Kwalify/MetaValidator.html +448 -0
  59. data/doc-api/classes/Kwalify/Parser.html +155 -0
  60. data/doc-api/classes/Kwalify/PlainYamlParser/Alias.html +165 -0
  61. data/doc-api/classes/Kwalify/PlainYamlParser.html +523 -0
  62. data/doc-api/classes/Kwalify/Rule.html +433 -0
  63. data/doc-api/classes/Kwalify/SchemaError.html +148 -0
  64. data/doc-api/classes/Kwalify/SyntaxError.html +185 -0
  65. data/doc-api/classes/Kwalify/Types.html +302 -0
  66. data/doc-api/classes/Kwalify/Util/HashLike.html +246 -0
  67. data/doc-api/classes/Kwalify/Util/OrderedHash.html +330 -0
  68. data/doc-api/classes/Kwalify/Util.html +390 -0
  69. data/doc-api/classes/Kwalify/ValidationError.html +148 -0
  70. data/doc-api/classes/Kwalify/Validator.html +381 -0
  71. data/doc-api/classes/Kwalify/Yaml/Parser.html +1538 -0
  72. data/doc-api/classes/Kwalify/Yaml.html +194 -0
  73. data/doc-api/classes/Kwalify/YamlParser.html +542 -0
  74. data/doc-api/classes/Kwalify/YamlSyntaxError.html +119 -0
  75. data/doc-api/classes/Kwalify.html +292 -0
  76. data/doc-api/classes/Test/Unit.html +101 -0
  77. data/doc-api/classes/Test.html +107 -0
  78. data/doc-api/created.rid +1 -0
  79. data/doc-api/files/__/README_txt.html +153 -0
  80. data/doc-api/files/kwalify/errors_rb.html +114 -0
  81. data/doc-api/files/kwalify/main_rb.html +118 -0
  82. data/doc-api/files/kwalify/messages_rb.html +107 -0
  83. data/doc-api/files/kwalify/meta-validator_rb.html +117 -0
  84. data/doc-api/files/kwalify/parser/base_rb.html +116 -0
  85. data/doc-api/files/kwalify/parser/yaml_rb.html +117 -0
  86. data/doc-api/files/kwalify/rule_rb.html +116 -0
  87. data/doc-api/files/kwalify/types_rb.html +114 -0
  88. data/doc-api/files/kwalify/util/assert-text-equal_rb.html +115 -0
  89. data/doc-api/files/kwalify/util/hash-interface_rb.html +114 -0
  90. data/doc-api/files/kwalify/util/hashlike_rb.html +107 -0
  91. data/doc-api/files/kwalify/util/option-parser_rb.html +107 -0
  92. data/doc-api/files/kwalify/util/ordered-hash_rb.html +107 -0
  93. data/doc-api/files/kwalify/util/testcase-helper_rb.html +115 -0
  94. data/doc-api/files/kwalify/util_rb.html +107 -0
  95. data/doc-api/files/kwalify/validator_rb.html +117 -0
  96. data/doc-api/files/kwalify/yaml-parser_rb.html +117 -0
  97. data/doc-api/files/kwalify_rb.html +121 -0
  98. data/doc-api/fr_class_index.html +57 -0
  99. data/doc-api/fr_file_index.html +45 -0
  100. data/doc-api/fr_method_index.html +168 -0
  101. data/doc-api/index.html +24 -0
  102. data/doc-api/rdoc-style.css +208 -0
  103. data/examples/address-book/Makefile +10 -0
  104. data/examples/address-book/address-book.schema.yaml +45 -0
  105. data/examples/address-book/address-book.yaml +36 -0
  106. data/examples/data-binding/BABEL.data.yaml +63 -0
  107. data/examples/data-binding/BABEL.schema.yaml +31 -0
  108. data/examples/data-binding/Makefile +8 -0
  109. data/examples/data-binding/Rakefile +13 -0
  110. data/examples/data-binding/main.rb +25 -0
  111. data/examples/invoice/Makefile +9 -0
  112. data/examples/invoice/invoice.schema.yaml +43 -0
  113. data/examples/invoice/invoice.yaml +32 -0
  114. data/examples/tapkit/Makefile +10 -0
  115. data/examples/tapkit/main.rb +7 -0
  116. data/examples/tapkit/tapkit.schema.yaml +146 -0
  117. data/examples/tapkit/tapkit.yaml +85 -0
  118. data/lib/kwalify/errors.rb +127 -0
  119. data/lib/kwalify/kwalify.schema.yaml +58 -0
  120. data/lib/kwalify/main.rb +442 -0
  121. data/lib/kwalify/messages.rb +173 -0
  122. data/lib/kwalify/meta-validator.rb +276 -0
  123. data/lib/kwalify/parser/base.rb +128 -0
  124. data/lib/kwalify/parser/yaml.rb +841 -0
  125. data/lib/kwalify/rule.rb +562 -0
  126. data/lib/kwalify/templates/genclass-java.eruby +222 -0
  127. data/lib/kwalify/templates/genclass-php.eruby +104 -0
  128. data/lib/kwalify/templates/genclass-ruby.eruby +113 -0
  129. data/lib/kwalify/types.rb +156 -0
  130. data/lib/kwalify/util/assert-text-equal.rb +46 -0
  131. data/lib/kwalify/util/hash-interface.rb +18 -0
  132. data/lib/kwalify/util/hashlike.rb +51 -0
  133. data/lib/kwalify/util/option-parser.rb +220 -0
  134. data/lib/kwalify/util/ordered-hash.rb +57 -0
  135. data/lib/kwalify/util/testcase-helper.rb +112 -0
  136. data/lib/kwalify/util.rb +159 -0
  137. data/lib/kwalify/validator.rb +282 -0
  138. data/lib/kwalify/version.rb +5 -0
  139. data/lib/kwalify/yaml-parser.rb +871 -0
  140. data/lib/kwalify.rb +61 -0
  141. data/rkwalify.gemspec +26 -0
  142. data/test/Rookbook.yaml +15 -0
  143. data/test/data/users-guide/AddressBook.java.expected +40 -0
  144. data/test/data/users-guide/BABEL.data.yaml +24 -0
  145. data/test/data/users-guide/BABEL.schema.yaml +30 -0
  146. data/test/data/users-guide/ExampleAddressBook.java +47 -0
  147. data/test/data/users-guide/Group.java.expected +24 -0
  148. data/test/data/users-guide/Person.java.expected +44 -0
  149. data/test/data/users-guide/address_book.rb +52 -0
  150. data/test/data/users-guide/address_book.schema.yaml +28 -0
  151. data/test/data/users-guide/address_book.yaml +27 -0
  152. data/test/data/users-guide/answers-schema.yaml +12 -0
  153. data/test/data/users-guide/answers-validator.rb +53 -0
  154. data/test/data/users-guide/babel_genclass.result +26 -0
  155. data/test/data/users-guide/config.schema.yaml +7 -0
  156. data/test/data/users-guide/config.yaml +4 -0
  157. data/test/data/users-guide/document01a.yaml +3 -0
  158. data/test/data/users-guide/document01b.yaml +3 -0
  159. data/test/data/users-guide/document02a.yaml +4 -0
  160. data/test/data/users-guide/document02b.yaml +4 -0
  161. data/test/data/users-guide/document03a.yaml +6 -0
  162. data/test/data/users-guide/document03b.yaml +6 -0
  163. data/test/data/users-guide/document04a.yaml +9 -0
  164. data/test/data/users-guide/document04b.yaml +9 -0
  165. data/test/data/users-guide/document05a.yaml +11 -0
  166. data/test/data/users-guide/document05b.yaml +12 -0
  167. data/test/data/users-guide/document06a.yaml +15 -0
  168. data/test/data/users-guide/document06b.yaml +16 -0
  169. data/test/data/users-guide/document07a.yaml +9 -0
  170. data/test/data/users-guide/document07b.yaml +7 -0
  171. data/test/data/users-guide/document12a.json +10 -0
  172. data/test/data/users-guide/document12b.json +6 -0
  173. data/test/data/users-guide/document13a.yaml +17 -0
  174. data/test/data/users-guide/document14a.yaml +3 -0
  175. data/test/data/users-guide/document14b.yaml +3 -0
  176. data/test/data/users-guide/document15a.yaml +6 -0
  177. data/test/data/users-guide/document15b.yaml +5 -0
  178. data/test/data/users-guide/example_address_book.rb +11 -0
  179. data/test/data/users-guide/example_address_book_java.result +32 -0
  180. data/test/data/users-guide/example_address_book_ruby.result +31 -0
  181. data/test/data/users-guide/genclass_java.result +4 -0
  182. data/test/data/users-guide/howto-validation-with-parsing.rb +28 -0
  183. data/test/data/users-guide/howto-validation.rb +25 -0
  184. data/test/data/users-guide/howto3.rb +6 -0
  185. data/test/data/users-guide/howto3.result +5 -0
  186. data/test/data/users-guide/howto3.yaml +8 -0
  187. data/test/data/users-guide/howto5_databinding.result +111 -0
  188. data/test/data/users-guide/invalid01.result +3 -0
  189. data/test/data/users-guide/invalid02.result +5 -0
  190. data/test/data/users-guide/invalid03.result +5 -0
  191. data/test/data/users-guide/invalid04.result +4 -0
  192. data/test/data/users-guide/invalid05.result +11 -0
  193. data/test/data/users-guide/invalid06.result +4 -0
  194. data/test/data/users-guide/invalid07.result +3 -0
  195. data/test/data/users-guide/invalid08.result +3 -0
  196. data/test/data/users-guide/invalid12.json +8 -0
  197. data/test/data/users-guide/invalid14.result +4 -0
  198. data/test/data/users-guide/invalid15.result +4 -0
  199. data/test/data/users-guide/loadbabel.rb +27 -0
  200. data/test/data/users-guide/loadconfig.rb +17 -0
  201. data/test/data/users-guide/loadconfig.result +6 -0
  202. data/test/data/users-guide/models.rb +24 -0
  203. data/test/data/users-guide/option_ha.result +6 -0
  204. data/test/data/users-guide/option_ha_genclass_java.result +7 -0
  205. data/test/data/users-guide/schema01.yaml +3 -0
  206. data/test/data/users-guide/schema02.yaml +12 -0
  207. data/test/data/users-guide/schema03.yaml +9 -0
  208. data/test/data/users-guide/schema04.yaml +20 -0
  209. data/test/data/users-guide/schema05.yaml +29 -0
  210. data/test/data/users-guide/schema06.yaml +11 -0
  211. data/test/data/users-guide/schema12.json +12 -0
  212. data/test/data/users-guide/schema13.yaml +13 -0
  213. data/test/data/users-guide/schema14.yaml +5 -0
  214. data/test/data/users-guide/schema15.yaml +21 -0
  215. data/test/data/users-guide/valid01.result +2 -0
  216. data/test/data/users-guide/valid02.result +2 -0
  217. data/test/data/users-guide/valid03.result +2 -0
  218. data/test/data/users-guide/valid04.result +2 -0
  219. data/test/data/users-guide/valid05.result +2 -0
  220. data/test/data/users-guide/valid06.result +2 -0
  221. data/test/data/users-guide/valid07.result +2 -0
  222. data/test/data/users-guide/valid08.result +2 -0
  223. data/test/data/users-guide/valid12.result +2 -0
  224. data/test/data/users-guide/valid13.result +2 -0
  225. data/test/data/users-guide/valid14.result +2 -0
  226. data/test/data/users-guide/valid15.result +2 -0
  227. data/test/data/users-guide/validate08.rb +37 -0
  228. data/test/test-action.rb +73 -0
  229. data/test/test-action.yaml +738 -0
  230. data/test/test-databinding.rb +84 -0
  231. data/test/test-databinding.yaml +339 -0
  232. data/test/test-main.rb +156 -0
  233. data/test/test-main.yaml +409 -0
  234. data/test/test-metavalidator.rb +80 -0
  235. data/test/test-metavalidator.yaml +1179 -0
  236. data/test/test-parser-yaml.rb +57 -0
  237. data/test/test-parser-yaml.yaml +1750 -0
  238. data/test/test-rule.rb +26 -0
  239. data/test/test-rule.yaml +317 -0
  240. data/test/test-users-guide.rb +82 -0
  241. data/test/test-util.rb +125 -0
  242. data/test/test-validator.rb +95 -0
  243. data/test/test-validator.yaml +986 -0
  244. data/test/test-yaml-parser.rb +47 -0
  245. data/test/test-yaml-parser.yaml +1226 -0
  246. data/test/test.rb +75 -0
  247. metadata +293 -0
@@ -0,0 +1,52 @@
1
+ # spec/my_cli_tool_spec.rb
2
+ require 'spec_helper'
3
+
4
+ describe 'My CLI Tool' do
5
+ context 'when run with a specific argument' do
6
+ let(:command) { 'rkwalify --version' }
7
+
8
+ before(:each) do
9
+ run_command_and_stop(command)
10
+ end
11
+
12
+ it 'outputs the correct version to stdout' do
13
+ expect(all_stdout).to include('1.0.0')
14
+ end
15
+
16
+ it 'exits with a status of 0' do
17
+ expect(last_command_started).to have_exit_status(0)
18
+ end
19
+ end
20
+
21
+ context 'when an error occurs' do
22
+ let(:command) { 'my-cli-tool --invalid-option' }
23
+
24
+ before(:each) do
25
+ run_command_and_stop(command)
26
+ end
27
+
28
+ it 'outputs an error message to stderr' do
29
+ expect(all_stderr).to include('Invalid option')
30
+ end
31
+
32
+ it 'exits with a non-zero status' do
33
+ expect(last_command_started).to have_exit_status(1) # Assuming a non-zero exit for errors
34
+ end
35
+ end
36
+
37
+ context 'when it creates a file' do
38
+ let(:command) { 'my-cli-tool create-file my_file.txt' }
39
+
40
+ before(:each) do
41
+ run_command_and_stop(command)
42
+ end
43
+
44
+ it 'creates the specified file' do
45
+ expect('my_file.txt').to be_an_existing_file
46
+ end
47
+
48
+ it 'writes the expected content to the file' do
49
+ expect(file_content('my_file.txt')).to eq("File created successfully.\n")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+ require 'aruba/rspec'
3
+
4
+ RSpec.describe 'my_cli', type: :aruba do
5
+ it 'runs with --help' do
6
+ run_command('my_cli --help')
7
+ expect(last_command_started).to be_successfully_executed
8
+ expect(last_command_started).to have_output /Usage:/
9
+ end
10
+ end
@@ -0,0 +1,104 @@
1
+ require 'rspec/core'
2
+ require 'aruba'
3
+ require 'aruba/rspec'
4
+
5
+ # This file was generated by the `rspec --init` command. Conventionally, all
6
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
8
+ # this file to always be loaded, without a need to explicitly require it in any
9
+ # files.
10
+ #
11
+ # Given that it is always loaded, you are encouraged to keep this file as
12
+ # light-weight as possible. Requiring heavyweight dependencies from this file
13
+ # will add to the boot time of your test suite on EVERY test run, even for an
14
+ # individual file that may not need all of that loaded. Instead, consider making
15
+ # a separate helper file that requires the additional dependencies and performs
16
+ # the additional setup, and require it from the spec files that actually need
17
+ # it.
18
+ #
19
+ # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
20
+ RSpec.configure do |config|
21
+ config.include Aruba::Api
22
+
23
+ # rspec-expectations config goes here. You can use an alternate
24
+ # assertion/expectation library such as wrong or the stdlib/minitest
25
+ # assertions if you prefer.
26
+ config.expect_with :rspec do |expectations|
27
+ # This option will default to `true` in RSpec 4. It makes the `description`
28
+ # and `failure_message` of custom matchers include text for helper methods
29
+ # defined using `chain`, e.g.:
30
+ # be_bigger_than(2).and_smaller_than(4).description
31
+ # # => "be bigger than 2 and smaller than 4"
32
+ # ...rather than:
33
+ # # => "be bigger than 2"
34
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
+ end
36
+
37
+ # rspec-mocks config goes here. You can use an alternate test double
38
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
39
+ config.mock_with :rspec do |mocks|
40
+ # Prevents you from mocking or stubbing a method that does not exist on
41
+ # a real object. This is generally recommended, and will default to
42
+ # `true` in RSpec 4.
43
+ mocks.verify_partial_doubles = true
44
+ end
45
+
46
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
47
+ # have no way to turn it off -- the option exists only for backwards
48
+ # compatibility in RSpec 3). It causes shared context metadata to be
49
+ # inherited by the metadata hash of host groups and examples, rather than
50
+ # triggering implicit auto-inclusion in groups with matching metadata.
51
+ config.shared_context_metadata_behavior = :apply_to_host_groups
52
+
53
+ # The settings below are suggested to provide a good initial experience
54
+ # with RSpec, but feel free to customize to your heart's content.
55
+ =begin
56
+ # This allows you to limit a spec run to individual examples or groups
57
+ # you care about by tagging them with `:focus` metadata. When nothing
58
+ # is tagged with `:focus`, all examples get run. RSpec also provides
59
+ # aliases for `it`, `describe`, and `context` that include `:focus`
60
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
61
+ config.filter_run_when_matching :focus
62
+
63
+ # Allows RSpec to persist some state between runs in order to support
64
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
65
+ # you configure your source control system to ignore this file.
66
+ config.example_status_persistence_file_path = "spec/examples.txt"
67
+
68
+ # Limits the available syntax to the non-monkey patched syntax that is
69
+ # recommended. For more details, see:
70
+ # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
71
+ config.disable_monkey_patching!
72
+
73
+ # This setting enables warnings. It's recommended, but in some cases may
74
+ # be too noisy due to issues in dependencies.
75
+ config.warnings = true
76
+
77
+ # Many RSpec users commonly either run the entire suite or an individual
78
+ # file, and it's useful to allow more verbose output when running an
79
+ # individual spec file.
80
+ if config.files_to_run.one?
81
+ # Use the documentation formatter for detailed output,
82
+ # unless a formatter has already been configured
83
+ # (e.g. via a command-line flag).
84
+ config.default_formatter = "doc"
85
+ end
86
+
87
+ # Print the 10 slowest examples and example groups at the
88
+ # end of the spec run, to help surface which specs are running
89
+ # particularly slow.
90
+ config.profile_examples = 10
91
+
92
+ # Run specs in random order to surface order dependencies. If you find an
93
+ # order dependency and want to debug it, you can fix the order by providing
94
+ # the seed, which is printed after each run.
95
+ # --seed 1234
96
+ config.order = :random
97
+
98
+ # Seed global randomization in this process using the `--seed` CLI option.
99
+ # Setting this allows you to use `--seed` to deterministically reproduce
100
+ # test failures related to randomization by passing the same `--seed` value
101
+ # as the one that triggered the failure.
102
+ Kernel.srand config.seed
103
+ =end
104
+ end
@@ -0,0 +1,28 @@
1
+ require 'kwalify'
2
+ #require 'yaml'
3
+
4
+ ## load schema data
5
+ schema = Kwalify::Yaml.load_file('kwalify.schema.yaml')
6
+ ## or
7
+ #schema = YAML.load_file('kwalify.schema.yaml')
8
+
9
+ ## create validator
10
+ validator = Kwalify::Validator.new(schema)
11
+
12
+ ## create parser with validator
13
+ ## (if validator is ommitted, no validation executed.)
14
+ parser = Kwalify::Yaml::Parser.new(validator)
15
+
16
+ ## parse document with validation
17
+ filename = 'document.yaml'
18
+ document = parser.parse_file(filename)
19
+ ## or
20
+ #document = parser.parse(File.read(filename), filename)
21
+
22
+ ## show errors if exist
23
+ errors = parser.errors()
24
+ if errors && !errors.empty?
25
+ for e in errors
26
+ puts "#{e.linenum}:#{e.column} [#{e.path}] #{e.message}"
27
+ end
28
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,292 @@
1
+ .=title: ChangeLog
2
+ .?release: $Release: 1.4.0-preview1 $
3
+ .?lastupdate: $Date$
4
+ .?version: $Rev$
5
+
6
+
7
+ ## Release 1.4.0-preview1 (2026-02-10)
8
+
9
+ * Release information in [CHANGELOG](CHANGELOG.md).
10
+
11
+ * See more details [Roll Out Strategy](ROLL-OUT-STRATEGY.md) regarding approach taken.
12
+
13
+ * See [commit history](commits/main) for more details.
14
+
15
+ * Known issues are documented as [issues](issues).
16
+
17
+ ## Release 0.7.3 (2026-02-10)
18
+
19
+ * (Tagged as 0.7.3) Copied original [Kwalify-1.7.2 code](https://rubygems.org/downloads/kwalify-0.7.2.gem) then [dc-kwalify's](https://github.com/dafyddcrosby/dc-kwalify) 1.0.0 code into repo.
20
+
21
+ ## Release 0.7.2 (2010-07-18)
22
+
23
+ .* bugfix:
24
+
25
+ .- Fix a bug that kwalify command raised error when YAML
26
+ document is empty (thanks to Nuttall).
27
+
28
+ .- Fix a bug that Kwalify::Util.untabify() removed tailing empty strings.
29
+
30
+ ## Release 0.7.1 (2008-01-28)
31
+
32
+ .* bugfix:
33
+
34
+ .- 'Duplicated key' error is now not raised if corresponding rule
35
+ has 'default:' constraint.
36
+
37
+ .- Path is now copied in Kwalify::ValidationError#initialize()
38
+
39
+
40
+ ## Release 0.7.0 (2008-01-27)
41
+
42
+ .* enhancements:
43
+
44
+ .- YAML parser is rewrited from scratch.
45
+ The new parser class Kwalify::Yaml::Parser is available.
46
+ The old parser class Kwalify::YamlParser is stil available,
47
+ but it is not recommended to use.
48
+
49
+ .- Validator is integrated with yaml parser.
50
+ It is able to parse and validate at once.
51
+ .--------------------
52
+ ## create validator
53
+ require 'kwalify'
54
+ schema = Kwalify::Yaml.load_file('schema.yaml')
55
+ validator = Kwalify::Validator.new(schema)
56
+ ## parse with validation
57
+ parser = Kwalify::Yaml::Parser.new(validator)
58
+ ydoc = parser.parse(File.read('data.yaml'))
59
+ ## show validation errors if exist
60
+ errors = parser.errors()
61
+ if errors && !errors.empty?
62
+ for e in errors
63
+ puts "** %d:%d [%s] %s" % [e.linenum, e.column, e.path, e.message]
64
+ end
65
+ end
66
+ .--------------------
67
+
68
+ .- Data binding is integrated into Kwalify::Yaml::Parser.
69
+ If you set Kwalify::Yaml::Parser#data_binding to true
70
+ and you specified class names in schema file,
71
+ parser creates instance objects instead of Hash objects.
72
+ It means that you don't need to add '!ruby/Classname'
73
+ for each data.
74
+ .? schema file (config.schema.yaml)
75
+ .--------------------
76
+ type: map
77
+ class: Config
78
+ mapping:
79
+ "host": { type: str, required: true }
80
+ "port": { type: int }
81
+ "user": { type: str, required: true }
82
+ "pass": { type: str, required: true }
83
+ .--------------------
84
+ .? configuration file (config.yaml)
85
+ .--------------------
86
+ host: localhost
87
+ port: 8080
88
+ user: user1
89
+ pass: password1
90
+ .--------------------
91
+ .? ruby program (ex1.rb)
92
+ .--------------------
93
+ ## class definition
94
+ require 'kwalify/util/hashlike'
95
+ class Config
96
+ include Kwalify::Util::HashLike # defines [], []=, ...
97
+ attr_accessor :host, :posrt, :user, :pass
98
+ end
99
+ ## create validator object
100
+ require 'kwalify'
101
+ schema = Kwalify::Yaml.load_file('config.schema.yaml')
102
+ validator = Kwalify::Validator.new(schema)
103
+ ## parse configuration file with data binding
104
+ parser = Kwalify::Yaml::Parser.new(validator)
105
+ parser.data_binding = true # enable data binding
106
+ config = parser.parse_file('config.yaml')
107
+ p config #=> #<Config:0x542590 @user="user1", @port=8080,
108
+ # @pass="password1", @host="localhost">
109
+ .--------------------
110
+
111
+ .- Preceding alias supported.
112
+ If you set Kwalify::Yaml::Parser#preceding_alias to true,
113
+ parser allows aliases to apprear before corresponding anchor
114
+ appears.
115
+ This is very useful when node graph is complex.
116
+ .--------------------
117
+ - name: Foo
118
+ parent: *bar # preceding alias
119
+ - &bar
120
+ name: Bar
121
+ parent: *baz # preceding alias
122
+ - &baz
123
+ name: Baz
124
+ .--------------------
125
+
126
+ .- New command-line option '-P' enables preceding alias.
127
+
128
+ .- Kwalify::Yaml.load() and Kwalify::Yaml.load_file() are added.
129
+ They are similar to YAML.load() and YAML.load_file() but they
130
+ use Kwalify::Yaml::Parser object.
131
+
132
+ .- New utilify method Kwalify::Util.traverse_schema() provided.
133
+ .--------------------
134
+ require 'kwalify'
135
+ require 'kwalify/util'
136
+ schema = Kwalify::Yaml.load('schema.yaml')
137
+ Kwalify::Util.traverse_schema(schema) do |rulehash|
138
+ if classname = rulehash['class']
139
+ ## add namespace to class name
140
+ rulehash['class'] = "Foo::Bar::#{classname}"
141
+ end
142
+ end
143
+ .--------------------
144
+
145
+ .- Add 'kwalify/util/hashlike.rb' which contains definition of
146
+ Kwalify::Util::HashLike module.
147
+ This module defines [], []=, keys(), key?(), and each() methods,
148
+ and these are required for data-binding.
149
+
150
+ .- Action 'genclass-ruby' supports '--hashlike' property.
151
+
152
+ .- Action 'genclass-ruby' supports '--initialize=false' property.
153
+
154
+ .- Add action 'geclass-php'
155
+
156
+ .- '\xXX' and '\uXXXX' are supported in Kwalify::Yaml::Parser.
157
+
158
+ .- New constrant 'default:' is added to kwalify.schema.yaml.
159
+ This constrant have no effect to validation and parsing,
160
+ and it is used only in 'genclass-xxx' action.
161
+
162
+
163
+ .* changes:
164
+
165
+ .- Action 'genclass-ruby' and 'genclass-java' are changed to
166
+ generate boolean accessors.
167
+ For example, attribute 'active' is specified as 'type: bool'
168
+ in schema file, action 'genclass-ruby' generates
169
+ "def active? ; @active; end"
170
+ and action 'genclass-java' generates
171
+ "public boolean isActive() { return _active; }".
172
+
173
+ .- Command-line option '-s' (silent) is obsolete and replaced with
174
+ '-q' (quiet). Option '-s' is still available but it is recommended
175
+ to use '-q'.
176
+
177
+ .- License is changed from LGPL to MIT-LICENSE.
178
+
179
+
180
+ ## Release 0.6.0 (2006-05-30)
181
+
182
+ .* enhancements:
183
+
184
+ .- Class definition generation support.
185
+ New command-line option '-a genclass-ruby' or '-a genclass-java' generates
186
+ class definitions in Ruby or Java from schema file.
187
+
188
+
189
+ ## Release 0.5.1 (2005-12-20)
190
+
191
+ .* enhances:
192
+
193
+ .- add new command-line option '-E' which show errors in
194
+ emacs-compatible style.
195
+
196
+
197
+ ## Release 0.5.0 (2005-12-17)
198
+
199
+ .* enhancements:
200
+
201
+ .- Meta-validation check for 'max < min', 'max-ex <= min-ex', and so on.
202
+ .- Many test-cases are added
203
+
204
+ .* changes:
205
+
206
+ .- 'Parser' class is renamed to 'YamlParser'
207
+ .- 'PlainParser' class is renamed to 'PlainYamlParser'
208
+ .- YamlParser#set_error_linenums() is renamed to set_errors_linenum()
209
+ .- ValidatorError#<=> added
210
+ .- ParseError class is renamed to YamlSyntaxError
211
+
212
+
213
+ ## Release 0.4.1 (2005-10-26)
214
+
215
+ .* bugfix:
216
+
217
+ .- Support Ruby 1.8.3 (around YAML::Syck::DomainType)
218
+ .- Show correct error line number when key is undefined or unknown.
219
+
220
+
221
+ ## Release 0.4.0 (2005-10-25)
222
+
223
+ .* enhancements:
224
+
225
+ .- New command-line option '-l' prints error line numbers.
226
+ .- Supports default rule of mapping.
227
+
228
+
229
+ ## Release 0.3.0 (2005-09-30)
230
+
231
+ .* enhancements:
232
+
233
+ .- Support 'max-ex' and 'min-ex' (max/min exclusive) support with 'range:'
234
+ .- Support 'max-ex' and 'min-ex' (max/min exclusive) support with 'length:'
235
+ .- Support 'unique' constraint
236
+
237
+
238
+ ## Release 0.2.0 (2005-09-25)
239
+
240
+ .* enhancements:
241
+
242
+ .- New type 'scalar' and 'timestamp' added
243
+ .- Add new rule 'range:' which validates value range.
244
+ See users' guide for details.
245
+ .- Add new rule 'length:' which validate length of string value.
246
+ See users' guide for details.
247
+ .- Add experimental rule 'assert:' which validates value with an
248
+ expression. See users' guide for details.
249
+ .- New method 'Kwalify::Validator#validate_hook()' is added.
250
+ This method is called by Kwalify::Validator#validate().
251
+ See users' guide for details.
252
+ .- New class 'MetaValidator' added.
253
+ .- New test script 'test/test-metavalidator.rb' added.
254
+
255
+ .* changes:
256
+
257
+ .- Type name changed to suite YAML data type:
258
+ .= string -> str
259
+ .= integer -> int
260
+ .= boolean -> bool
261
+ .- Error index starts with 0 (before starts with 1).
262
+ .- Class 'Schema' is renamed to 'Rule'.
263
+
264
+
265
+ ## Release 0.1.0 (2005-08-01)
266
+
267
+ .- beta release
268
+
269
+ ---
270
+
271
+ ## FILE TYPES
272
+
273
+ ### DOCS
274
+
275
+ * README.md, MIT-LICENSE, CONTRIBUTORS.md, CHANGELOG.md,
276
+ * doc, doc-api
277
+
278
+ ### CODE, YAML/JSON
279
+ * lib, .github, Gemfiler, kwalify.gemspec, Gemfile.lock, Rakefile,
280
+ * .rvmrc, .ruby-version, .ruby-gemset, .bundle
281
+ * .rubocop_todo.yml, .rubocop.yml, .overcommit.yml
282
+ * bin, tmp
283
+ * Manifest.txt, rkwalify-*.gem
284
+ * examples, contrib
285
+
286
+ ### TESTS
287
+
288
+ * test, coverage
289
+
290
+ ### INTERNAL
291
+
292
+ * .gitignore, .git, o_r, Attic
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,23 @@
1
+ ### WAYS TO CONTRIBUTE
2
+
3
+ ## Reporting Issues
4
+
5
+ * Proofread [doc](https://github.com/jasnow/rkwalify/tree/main/doc) and [doc-api](https://github.com/jasnow/rkwalify/tree/main/doc-api) directories.
6
+
7
+ * Uncomment and debug/upgrade test/test.rb [categories](https://github.com/jasnow/rkwalify/issues/2).
8
+
9
+ * Identity problems and create an [issue](https://github.com/jasnow/rkwalify/issues).
10
+
11
+ * Reply to open [issues](https://github.com/jasnow/rkwalify/issues) to help troubleshoot and fix existing bugs.
12
+
13
+ ## Sending Pull Requests
14
+
15
+ * Work existing [issues](https://github.com/jasnow/rkwalify/issues) and submit as [Pull Requests](https://github.com/jasnow/rkwalify/pulls).
16
+
17
+ ## Other Ways to Contribute
18
+
19
+ * Submit your repo as example of rkwalify use.
20
+
21
+ * TBD
22
+
23
+ Thanks again for your interest on contributing to the project!
data/CONTRIBUTORS.md ADDED
@@ -0,0 +1,8 @@
1
+ ### Acknowledgements
2
+
3
+ This gem would not be possible without volunteers willing to
4
+ submit pull requests. In no particular order, we'd like to thank:
5
+
6
+ * [Makoto Kuwata](https://github.com/kwatch)
7
+ * [David T. Crosby](https://github.com/dafyddcrosby)
8
+ * [Al Snow](https://github.com/jasnow)
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :development, :test, optional: true do
8
+ gem 'rubocop', require: false
9
+ gem 'rubocop-performance', require: false
10
+ gem 'rubocop-rails', require: false
11
+ gem 'rubocop-rake', require: false
12
+
13
+ gem 'simplecov', require: false
14
+
15
+ gem 'test-unit'
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,146 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rkwalify (1.4.0.pre.preview1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (8.1.2)
10
+ base64
11
+ bigdecimal
12
+ concurrent-ruby (~> 1.0, >= 1.3.1)
13
+ connection_pool (>= 2.2.5)
14
+ drb
15
+ i18n (>= 1.6, < 2)
16
+ json
17
+ logger (>= 1.4.2)
18
+ minitest (>= 5.1)
19
+ securerandom (>= 0.3)
20
+ tzinfo (~> 2.0, >= 2.0.5)
21
+ uri (>= 0.13.1)
22
+ ast (2.4.3)
23
+ base64 (0.3.0)
24
+ bigdecimal (4.0.1)
25
+ concurrent-ruby (1.3.6)
26
+ connection_pool (3.0.2)
27
+ docile (1.4.1)
28
+ drb (2.2.3)
29
+ i18n (1.14.8)
30
+ concurrent-ruby (~> 1.0)
31
+ json (2.18.1)
32
+ language_server-protocol (3.17.0.5)
33
+ lint_roller (1.1.0)
34
+ logger (1.7.0)
35
+ minitest (6.0.1)
36
+ prism (~> 1.5)
37
+ parallel (1.27.0)
38
+ parser (3.3.10.1)
39
+ ast (~> 2.4.1)
40
+ racc
41
+ power_assert (3.0.1)
42
+ prism (1.9.0)
43
+ racc (1.8.1)
44
+ rack (3.2.4)
45
+ rainbow (3.1.1)
46
+ regexp_parser (2.11.3)
47
+ rubocop (1.84.2)
48
+ json (~> 2.3)
49
+ language_server-protocol (~> 3.17.0.2)
50
+ lint_roller (~> 1.1.0)
51
+ parallel (~> 1.10)
52
+ parser (>= 3.3.0.2)
53
+ rainbow (>= 2.2.2, < 4.0)
54
+ regexp_parser (>= 2.9.3, < 3.0)
55
+ rubocop-ast (>= 1.49.0, < 2.0)
56
+ ruby-progressbar (~> 1.7)
57
+ unicode-display_width (>= 2.4.0, < 4.0)
58
+ rubocop-ast (1.49.0)
59
+ parser (>= 3.3.7.2)
60
+ prism (~> 1.7)
61
+ rubocop-performance (1.26.1)
62
+ lint_roller (~> 1.1)
63
+ rubocop (>= 1.75.0, < 2.0)
64
+ rubocop-ast (>= 1.47.1, < 2.0)
65
+ rubocop-rails (2.34.3)
66
+ activesupport (>= 4.2.0)
67
+ lint_roller (~> 1.1)
68
+ rack (>= 1.1)
69
+ rubocop (>= 1.75.0, < 2.0)
70
+ rubocop-ast (>= 1.44.0, < 2.0)
71
+ rubocop-rake (0.7.1)
72
+ lint_roller (~> 1.1)
73
+ rubocop (>= 1.72.1)
74
+ ruby-progressbar (1.13.0)
75
+ securerandom (0.4.1)
76
+ simplecov (0.22.0)
77
+ docile (~> 1.1)
78
+ simplecov-html (~> 0.11)
79
+ simplecov_json_formatter (~> 0.1)
80
+ simplecov-html (0.13.2)
81
+ simplecov_json_formatter (0.1.4)
82
+ test-unit (3.7.7)
83
+ power_assert
84
+ tzinfo (2.0.6)
85
+ concurrent-ruby (~> 1.0)
86
+ unicode-display_width (3.2.0)
87
+ unicode-emoji (~> 4.1)
88
+ unicode-emoji (4.2.0)
89
+ uri (1.1.1)
90
+
91
+ PLATFORMS
92
+ ruby
93
+ universal-darwin
94
+ x86_64-linux
95
+
96
+ DEPENDENCIES
97
+ rkwalify!
98
+ rubocop
99
+ rubocop-performance
100
+ rubocop-rails
101
+ rubocop-rake
102
+ simplecov
103
+ test-unit
104
+
105
+ CHECKSUMS
106
+ activesupport (8.1.2) sha256=88842578ccd0d40f658289b0e8c842acfe9af751afee2e0744a7873f50b6fdae
107
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
108
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
109
+ bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
110
+ concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
111
+ connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
112
+ docile (1.4.1) sha256=96159be799bfa73cdb721b840e9802126e4e03dfc26863db73647204c727f21e
113
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
114
+ i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5
115
+ json (2.18.1) sha256=fe112755501b8d0466b5ada6cf50c8c3f41e897fa128ac5d263ec09eedc9f986
116
+ language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
117
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
118
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
119
+ minitest (6.0.1) sha256=7854c74f48e2e975969062833adc4013f249a4b212f5e7b9d5c040bf838d54bb
120
+ parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
121
+ parser (3.3.10.1) sha256=06f6a725d2cd91e5e7f2b7c32ba143631e1f7c8ae2fb918fc4cebec187e6a688
122
+ power_assert (3.0.1) sha256=8ce9876716cc74e863fcd4cdcdc52d792bd983598d1af3447083a3a9a4d34103
123
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
124
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
125
+ rack (3.2.4) sha256=5d74b6f75082a643f43c1e76b419c40f0e5527fcfee1e669ac1e6b73c0ccb6f6
126
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
127
+ regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
128
+ rkwalify (1.4.0.pre.preview1)
129
+ rubocop (1.84.2) sha256=5692cea54168f3dc8cb79a6fe95c5424b7ea893c707ad7a4307b0585e88dbf5f
130
+ rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
131
+ rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
132
+ rubocop-rails (2.34.3) sha256=10d37989024865ecda8199f311f3faca990143fbac967de943f88aca11eb9ad2
133
+ rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
134
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
135
+ securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
136
+ simplecov (0.22.0) sha256=fe2622c7834ff23b98066bb0a854284b2729a569ac659f82621fc22ef36213a5
137
+ simplecov-html (0.13.2) sha256=bd0b8e54e7c2d7685927e8d6286466359b6f16b18cb0df47b508e8d73c777246
138
+ simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
139
+ test-unit (3.7.7) sha256=3c89d5ff0690a16bef9946156c4624390402b9d54dfcf4ce9cbd5b06bead1e45
140
+ tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
141
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
142
+ unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
143
+ uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
144
+
145
+ BUNDLED WITH
146
+ 4.0.6