dc-kwalify 0.7.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/contrib/kwalify +1 -1
  4. data/dc-kwalify.gemspec +27 -0
  5. data/lib/kwalify/main.rb +1 -1
  6. data/lib/kwalify/util/testcase-helper.rb +1 -1
  7. data/lib/kwalify/version.rb +5 -0
  8. data/lib/kwalify.rb +1 -7
  9. metadata +83 -203
  10. data/setup.rb +0 -1585
  11. data/test/Rookbook.yaml +0 -10
  12. data/test/data/users-guide/AddressBook.java.expected +0 -40
  13. data/test/data/users-guide/BABEL.data.yaml +0 -24
  14. data/test/data/users-guide/BABEL.schema.yaml +0 -30
  15. data/test/data/users-guide/ExampleAddressBook.java +0 -47
  16. data/test/data/users-guide/Group.java.expected +0 -24
  17. data/test/data/users-guide/Person.java.expected +0 -44
  18. data/test/data/users-guide/address_book.rb +0 -52
  19. data/test/data/users-guide/address_book.schema.yaml +0 -28
  20. data/test/data/users-guide/address_book.yaml +0 -27
  21. data/test/data/users-guide/answers-schema.yaml +0 -12
  22. data/test/data/users-guide/answers-validator.rb +0 -52
  23. data/test/data/users-guide/babel_genclass.result +0 -26
  24. data/test/data/users-guide/config.schema.yaml +0 -7
  25. data/test/data/users-guide/config.yaml +0 -4
  26. data/test/data/users-guide/document01a.yaml +0 -3
  27. data/test/data/users-guide/document01b.yaml +0 -3
  28. data/test/data/users-guide/document02a.yaml +0 -4
  29. data/test/data/users-guide/document02b.yaml +0 -4
  30. data/test/data/users-guide/document03a.yaml +0 -6
  31. data/test/data/users-guide/document03b.yaml +0 -6
  32. data/test/data/users-guide/document04a.yaml +0 -9
  33. data/test/data/users-guide/document04b.yaml +0 -9
  34. data/test/data/users-guide/document05a.yaml +0 -11
  35. data/test/data/users-guide/document05b.yaml +0 -12
  36. data/test/data/users-guide/document06a.yaml +0 -15
  37. data/test/data/users-guide/document06b.yaml +0 -16
  38. data/test/data/users-guide/document07a.yaml +0 -9
  39. data/test/data/users-guide/document07b.yaml +0 -7
  40. data/test/data/users-guide/document12a.json +0 -10
  41. data/test/data/users-guide/document12b.json +0 -6
  42. data/test/data/users-guide/document13a.yaml +0 -17
  43. data/test/data/users-guide/document14a.yaml +0 -3
  44. data/test/data/users-guide/document14b.yaml +0 -3
  45. data/test/data/users-guide/document15a.yaml +0 -6
  46. data/test/data/users-guide/document15b.yaml +0 -5
  47. data/test/data/users-guide/example_address_book.rb +0 -10
  48. data/test/data/users-guide/example_address_book_java.result +0 -32
  49. data/test/data/users-guide/example_address_book_ruby.result +0 -31
  50. data/test/data/users-guide/genclass_java.result +0 -4
  51. data/test/data/users-guide/howto-validation-with-parsing.rb +0 -28
  52. data/test/data/users-guide/howto-validation.rb +0 -25
  53. data/test/data/users-guide/howto3.rb +0 -6
  54. data/test/data/users-guide/howto3.result +0 -5
  55. data/test/data/users-guide/howto3.yaml +0 -8
  56. data/test/data/users-guide/howto5_databinding.result +0 -111
  57. data/test/data/users-guide/invalid01.result +0 -3
  58. data/test/data/users-guide/invalid02.result +0 -5
  59. data/test/data/users-guide/invalid03.result +0 -5
  60. data/test/data/users-guide/invalid04.result +0 -4
  61. data/test/data/users-guide/invalid05.result +0 -11
  62. data/test/data/users-guide/invalid06.result +0 -4
  63. data/test/data/users-guide/invalid07.result +0 -3
  64. data/test/data/users-guide/invalid08.result +0 -3
  65. data/test/data/users-guide/invalid12.json +0 -8
  66. data/test/data/users-guide/invalid14.result +0 -4
  67. data/test/data/users-guide/invalid15.result +0 -4
  68. data/test/data/users-guide/loadbabel.rb +0 -27
  69. data/test/data/users-guide/loadconfig.rb +0 -16
  70. data/test/data/users-guide/loadconfig.result +0 -6
  71. data/test/data/users-guide/models.rb +0 -22
  72. data/test/data/users-guide/option_ha.result +0 -6
  73. data/test/data/users-guide/option_ha_genclass_java.result +0 -7
  74. data/test/data/users-guide/schema01.yaml +0 -3
  75. data/test/data/users-guide/schema02.yaml +0 -12
  76. data/test/data/users-guide/schema03.yaml +0 -9
  77. data/test/data/users-guide/schema04.yaml +0 -20
  78. data/test/data/users-guide/schema05.yaml +0 -29
  79. data/test/data/users-guide/schema06.yaml +0 -11
  80. data/test/data/users-guide/schema12.json +0 -12
  81. data/test/data/users-guide/schema13.yaml +0 -13
  82. data/test/data/users-guide/schema14.yaml +0 -5
  83. data/test/data/users-guide/schema15.yaml +0 -21
  84. data/test/data/users-guide/valid01.result +0 -2
  85. data/test/data/users-guide/valid02.result +0 -2
  86. data/test/data/users-guide/valid03.result +0 -2
  87. data/test/data/users-guide/valid04.result +0 -2
  88. data/test/data/users-guide/valid05.result +0 -2
  89. data/test/data/users-guide/valid06.result +0 -2
  90. data/test/data/users-guide/valid07.result +0 -2
  91. data/test/data/users-guide/valid08.result +0 -2
  92. data/test/data/users-guide/valid12.result +0 -2
  93. data/test/data/users-guide/valid13.result +0 -2
  94. data/test/data/users-guide/valid14.result +0 -2
  95. data/test/data/users-guide/valid15.result +0 -2
  96. data/test/data/users-guide/validate08.rb +0 -37
  97. data/test/test-action.rb +0 -78
  98. data/test/test-action.yaml +0 -738
  99. data/test/test-databinding.rb +0 -83
  100. data/test/test-databinding.yaml +0 -339
  101. data/test/test-main.rb +0 -157
  102. data/test/test-main.yaml +0 -415
  103. data/test/test-metavalidator.rb +0 -80
  104. data/test/test-metavalidator.yaml +0 -1179
  105. data/test/test-parser-yaml.rb +0 -57
  106. data/test/test-parser-yaml.yaml +0 -1749
  107. data/test/test-rule.rb +0 -26
  108. data/test/test-rule.yaml +0 -317
  109. data/test/test-users-guide.rb +0 -75
  110. data/test/test-util.rb +0 -125
  111. data/test/test-validator.rb +0 -95
  112. data/test/test-validator.yaml +0 -986
  113. data/test/test-yaml-parser.rb +0 -47
  114. data/test/test-yaml-parser.yaml +0 -1226
  115. data/test/test.rb +0 -61
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'kwalify'
4
- require 'yaml'
5
-
6
- ## load schema definition
7
- schema = YAML.load_file('answers-schema.yaml')
8
-
9
- ## create validator for answers
10
- validator = Kwalify::Validator.new(schema) { |value, rule, path, errors|
11
- case rule.name
12
- when 'Answer'
13
- if value['answer'] == 'bad'
14
- reason = value['reason']
15
- if !reason || reason.empty?
16
- msg = "reason is required when answer is 'bad'."
17
- errors << Kwalify::ValidationError.new(msg, path)
18
- end
19
- end
20
- end
21
- }
22
-
23
- ## load YAML document
24
- input = ARGF.read()
25
- document = YAML.load(input)
26
-
27
- ## validate
28
- errors = validator.validate(document)
29
- if errors.empty?
30
- puts "Valid."
31
- else
32
- puts "*** INVALID!"
33
- errors.each do |error|
34
- # error.class == Kwalify::ValidationError
35
- puts " - [#{error.path}] : #{error.message}"
36
- end
37
- end
data/test/test-action.rb DELETED
@@ -1,78 +0,0 @@
1
- ###
2
- ### $Rev$
3
- ### $Release: 0.7.2 $
4
- ### copyright(c) 2005-2010 kuwata-lab all rights reserved.
5
- ###
6
-
7
- require File.dirname(__FILE__) + '/test.rb'
8
-
9
- require 'kwalify/main'
10
-
11
-
12
- module Kwalify
13
- class Main
14
- public :_parse_argv
15
- end
16
- end
17
-
18
-
19
- class File
20
- def self.move(filename, dirname)
21
- File.rename(filename, "#{dirname}/#{filename}")
22
- end
23
- end
24
-
25
-
26
- class ActionTest < Test::Unit::TestCase
27
-
28
- ## define test methods
29
- filename = __FILE__.sub(/\.rb$/, ".yaml")
30
- load_yaml_testdata(filename, :lang=>'ruby')
31
-
32
-
33
- ## temporary directory
34
- @@tmpdir = "tmp.dir"
35
- Dir.mkdir(@@tmpdir) unless test(?d, @@tmpdir)
36
-
37
-
38
- def _test
39
- if @exception
40
- classname = @exception =~ /Kwalify::(.*)/ ? $1 : @exception
41
- @exception_class = Kwalify.const_get(classname)
42
- end
43
- return if $target && $target != @name
44
- raise "*** #{@name}: args is required." unless @args
45
- raise "*** #{@name}: expected is require." unless @expected
46
- #
47
- File.open("#{@name}.schema", 'w') { |f| f.write(@schema) } if @schema
48
- File.open("#{@name}.document", 'w') { |f| f.write(@document) } if @document
49
- #
50
- begin
51
- main = Kwalify::Main.new("kwalify")
52
- $stdout = StringWriter.new
53
- main.execute(@args)
54
- actual = $stdout; $stdout = STDOUT
55
- if @output_files
56
- if @output_message
57
- assert_text_equal(@output_message, actual)
58
- else
59
- assert(actual.nil? || actual=='')
60
- end
61
- @output_files.each do |filename|
62
- actual = File.read(filename)
63
- assert_text_equal(@expected[filename], actual)
64
- end
65
- else
66
- assert_text_equal(@expected, actual)
67
- end
68
- ensure
69
- File.move("#{@name}.schema", @@tmpdir) if @schema
70
- File.move("#{@name}.document", @@tmpdir) if @document
71
- @output_files.each do |filename|
72
- File.move(filename, @@tmpdir) if test(?f, filename)
73
- end if @output_files
74
- end
75
- end
76
-
77
-
78
- end