tpkg 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/Portfile +39 -0
- data/Portfile.template +39 -0
- data/README.md +43 -0
- data/Rakefile +468 -18
- data/bin/gem2tpkg +2 -2
- data/bin/tpkg +18 -13
- data/bin/tpkg_uploader +132 -0
- data/ca.pem +1 -0
- data/control +7 -0
- data/depend +3 -0
- data/externals-etch/authorized_keys +40 -0
- data/externals-etch/group +9 -0
- data/externals-etch/iptables +38 -0
- data/externals-etch/limits +30 -0
- data/externals-etch/nfs +30 -0
- data/externals-etch/sudo +30 -0
- data/externals-etch/supplemental_groups +8 -0
- data/externals-etch/sysctl +30 -0
- data/externals-etch/user +41 -0
- data/externals/group +39 -0
- data/externals/supplemental_groups +48 -0
- data/externals/user +39 -0
- data/lib/tpkg.rb +260 -991
- data/lib/tpkg/os.rb +164 -0
- data/lib/tpkg/os/debian.rb +159 -0
- data/lib/tpkg/os/freebsd.rb +113 -0
- data/lib/tpkg/os/macosx.rb +113 -0
- data/lib/tpkg/os/redhat.rb +173 -0
- data/lib/tpkg/os/solaris.rb +101 -0
- data/lib/tpkg/os/windows.rb +26 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify.rb +67 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/errors.rb +127 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/kwalify.schema.yaml +58 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/main.rb +442 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/messages.rb +173 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/meta-validator.rb +275 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/parser/base.rb +127 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/parser/yaml.rb +841 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/rule.rb +559 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-java.eruby +222 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-php.eruby +104 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/templates/genclass-ruby.eruby +113 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/types.rb +156 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util.rb +158 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/assert-text-equal.rb +46 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/hash-interface.rb +18 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/hashlike.rb +51 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/option-parser.rb +220 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/ordered-hash.rb +57 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/util/testcase-helper.rb +112 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/validator.rb +282 -0
- data/lib/tpkg/thirdparty/kwalify-0.7.2/lib/kwalify/yaml-parser.rb +870 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh.rb +219 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/agent.rb +179 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/constants.rb +18 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/key_manager.rb +219 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/abstract.rb +60 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/password.rb +39 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/methods/publickey.rb +92 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/pageant.rb +183 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/authentication/session.rb +134 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/buffer.rb +340 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/buffered_io.rb +198 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/config.rb +205 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/channel.rb +630 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/constants.rb +33 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/session.rb +597 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/connection/term.rb +178 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/errors.rb +85 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/key_factory.rb +102 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/known_hosts.rb +129 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/loggable.rb +61 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/packet.rb +102 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/prompt.rb +93 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/command.rb +75 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/errors.rb +14 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/http.rb +94 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/socks4.rb +70 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/proxy/socks5.rb +142 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/ruby_compat.rb +43 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/service/forward.rb +288 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test.rb +89 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/channel.rb +129 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/extensions.rb +152 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/kex.rb +44 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/local_packet.rb +51 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/packet.rb +81 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/remote_packet.rb +38 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/script.rb +157 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/test/socket.rb +64 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/algorithms.rb +384 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/cipher_factory.rb +97 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/constants.rb +30 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac.rb +31 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/abstract.rb +79 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/md5.rb +12 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/none.rb +15 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/sha1.rb +13 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/identity_cipher.rb +55 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex.rb +13 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/openssl.rb +127 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/packet_stream.rb +235 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/server_version.rb +71 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/session.rb +276 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/transport/state.rb +206 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/lenient.rb +30 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/null.rb +12 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/verifiers/strict.rb +53 -0
- data/lib/tpkg/thirdparty/net-ssh-2.1.0/lib/net/ssh/version.rb +62 -0
- data/lib/tpkg/version.rb +3 -0
- data/man/man1/cpan2tpkg.1 +82 -0
- data/man/man1/gem2tpkg.1 +120 -0
- data/man/man1/tpkg.1 +411 -0
- data/pkginfo +8 -0
- data/postinstall.solaris +11 -0
- data/postremove.solaris +16 -0
- data/schema/schema-1.0.5.yml +0 -0
- data/schema/schema-1.0.6.yml +0 -0
- data/schema/schema-1.0.7.yml +0 -0
- data/schema/schema-1.0.8.yml +0 -0
- data/schema/schema-1.0.9.yml +0 -0
- data/schema/schema.yml +0 -0
- data/schema/tpkg-1.0.0.dtd +0 -0
- data/schema/tpkg-1.0.1.dtd +0 -0
- data/schema/tpkg-1.0.2.dtd +0 -0
- data/schema/tpkg-1.0.3.dtd +0 -0
- data/schema/tpkg-1.0.4.dtd +0 -0
- data/schema/tpkg-1.0.5.dtd +0 -0
- data/schema/tpkg-1.0.6.dtd +0 -0
- data/schema/tpkg-1.0.7.dtd +0 -0
- data/schema/tpkg-1.0.8.dtd +0 -0
- data/schema/tpkg-1.0.9.dtd +0 -0
- data/schema/tpkg.dtd +0 -0
- data/test/TODO +30 -0
- data/test/premadetestpkg/pkg_without_file_metadata-1.0-1.tpkg +0 -0
- data/test/test_checksum.rb +53 -0
- data/test/test_compress.rb +55 -0
- data/test/test_conflict.rb +41 -0
- data/test/test_crontabs.rb +398 -0
- data/test/test_dependency.rb +1113 -0
- data/test/test_downgrade.rb +80 -0
- data/test/test_download.rb +95 -0
- data/test/test_encrypt.rb +136 -0
- data/test/test_filemetadata.rb +131 -0
- data/test/test_initscript.rb +93 -0
- data/test/test_install.rb +186 -0
- data/test/test_lock.rb +82 -0
- data/test/test_make.rb +410 -0
- data/test/test_metadata.rb +805 -0
- data/test/test_misc.rb +379 -0
- data/test/test_options.rb +1711 -0
- data/test/test_os.rb +193 -0
- data/test/test_os_debian.rb +99 -0
- data/test/test_os_freebsd.rb +89 -0
- data/test/test_os_macosx.rb +79 -0
- data/test/test_os_redhat.rb +124 -0
- data/test/test_os_solaris.rb +85 -0
- data/test/test_os_windows.rb +26 -0
- data/test/test_query.rb +134 -0
- data/test/test_remove.rb +539 -0
- data/test/test_tar.rb +99 -0
- data/test/test_unpack.rb +977 -0
- data/test/test_upgrade.rb +398 -0
- data/test/test_version.rb +54 -0
- data/test/testcmds/crontab +14 -0
- data/test/testcmds/debian/apt-cache +145 -0
- data/test/testcmds/debian/dpkg-query +16 -0
- data/test/testcmds/freebsd/pkg_info +13 -0
- data/test/testcmds/macosx/port +35 -0
- data/test/testcmds/redhat/rpmbuild +6 -0
- data/test/testcmds/redhat/yum +90 -0
- data/test/testcmds/solaris/pkginfo +25 -0
- data/test/testcmds/solaris/pkgutil +36 -0
- data/test/testpkg/reloc/encfile +2 -0
- data/test/testpkg/reloc/file +2 -0
- data/test/testpkg/reloc/precryptfile +1 -0
- data/test/testpkg/reloc/precryptfile.plaintext +3 -0
- data/test/testpkg/tpkg-bad-ownergroup.xml +25 -0
- data/test/testpkg/tpkg-bad-ownergroup.yml +18 -0
- data/test/testpkg/tpkg-default-perms.xml +28 -0
- data/test/testpkg/tpkg-default-perms.yml +20 -0
- data/test/testpkg/tpkg-good-ownergroup.xml +25 -0
- data/test/testpkg/tpkg-good-ownergroup.yml +18 -0
- data/test/testpkg/tpkg-nativedeps.yml +13 -0
- data/test/testpkg/tpkg-nofiles.xml +14 -0
- data/test/testpkg/tpkg-nofiles.yml +9 -0
- data/test/testpkg/tpkg.xml +35 -0
- data/test/testpkg/tpkg.yml +25 -0
- data/test/tpkgtest.rb +300 -0
- data/tpkg.conf +16 -0
- data/tpkg.gemspec +24 -0
- data/tpkg.spec +28 -0
- data/tpkg.xml +17 -0
- data/tpkg_profile.sh +32 -0
- metadata +306 -31
@@ -0,0 +1,173 @@
|
|
1
|
+
###
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.2 $
|
4
|
+
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
5
|
+
###
|
6
|
+
|
7
|
+
module Kwalify
|
8
|
+
|
9
|
+
@@messages = {}
|
10
|
+
|
11
|
+
def self.msg(key)
|
12
|
+
return @@messages[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
@@messages[:command_help] = <<END
|
18
|
+
kwalify - schema validator and data binding tool for YAML and JSON
|
19
|
+
## Usage1: validate yaml document
|
20
|
+
kwalify [..options..] -f schema.yaml doc.yaml [doc2.yaml ...]
|
21
|
+
## Usage2: validate schema definition
|
22
|
+
kwalify [..options..] -m schema.yaml [schema2.yaml ...]
|
23
|
+
## Usage3: do action
|
24
|
+
kwalify [..options..] -a action -f schema.yaml [schema2.yaml ...]
|
25
|
+
-h, --help : help
|
26
|
+
-v : version
|
27
|
+
-q : quiet
|
28
|
+
-s : silent (obsolete, use '-q' instead)
|
29
|
+
-f schema.yaml : schema definition file
|
30
|
+
-m : meta-validation mode
|
31
|
+
-t : expand tab characters
|
32
|
+
-l : show linenumber when errored (experimental)
|
33
|
+
-E : show errors in emacs-style (experimental, implies '-l')
|
34
|
+
-a action : action ('genclass-ruby', 'genclass-php', 'genclass-java')
|
35
|
+
(try '-ha genclass-ruby' for details)
|
36
|
+
-I path : template path (for '-a')
|
37
|
+
-P : allow preceding alias
|
38
|
+
END
|
39
|
+
# -z : syntax checking of schema file
|
40
|
+
# -I path : path for template of action
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
##----- begin
|
45
|
+
# filename: lib/kwalify/main.rb
|
46
|
+
@@messages[:command_option_actionnoschema] = "schema filename is not specified."
|
47
|
+
@@messages[:command_option_noaction] = "command-line option '-f' or '-m' required."
|
48
|
+
@@messages[:command_option_notemplate] = "%s: invalid action (template not found).\n"
|
49
|
+
@@messages[:schema_empty] = "%s: empty schema.\n"
|
50
|
+
@@messages[:validation_empty] = "%s#%d: empty."
|
51
|
+
@@messages[:validation_empty] = "%s#%d: empty.\n"
|
52
|
+
@@messages[:validation_valid] = "%s#%d: valid."
|
53
|
+
@@messages[:command_option_schema_required] = "-%s: schema filename required."
|
54
|
+
@@messages[:command_option_action_required] = "-%s: action required."
|
55
|
+
@@messages[:command_option_tpath_required] = "-%s: template path required."
|
56
|
+
@@messages[:command_property_invalid] = "%s: invalid property."
|
57
|
+
@@messages[:command_option_invalid] = "-%s: invalid command option."
|
58
|
+
# --
|
59
|
+
# filename: lib/kwalify/rule.rb
|
60
|
+
@@messages[:schema_notmap] = "schema definition is not a mapping."
|
61
|
+
@@messages[:key_unknown] = "unknown key."
|
62
|
+
@@messages[:type_notstr] = "not a string."
|
63
|
+
@@messages[:type_unknown] = "unknown type."
|
64
|
+
@@messages[:class_notmap] = "available only with map type."
|
65
|
+
@@messages[:required_notbool] = "not a boolean."
|
66
|
+
@@messages[:pattern_notstr] = "not a string (or regexp)"
|
67
|
+
@@messages[:pattern_notmatch] = "should be '/..../'."
|
68
|
+
@@messages[:pattern_syntaxerr] = "has regexp error."
|
69
|
+
@@messages[:enum_notseq] = "not a sequence."
|
70
|
+
@@messages[:enum_notscalar] = "not available with seq or map."
|
71
|
+
@@messages[:enum_type_unmatch] = "%s type expected."
|
72
|
+
@@messages[:enum_duplicate] = "duplicated enum value."
|
73
|
+
@@messages[:assert_notstr] = "not a string."
|
74
|
+
@@messages[:assert_noval] = "'val' is not used."
|
75
|
+
@@messages[:assert_syntaxerr] = "expression syntax error."
|
76
|
+
@@messages[:range_notmap] = "not a mapping."
|
77
|
+
@@messages[:range_notscalar] = "is available only with scalar type."
|
78
|
+
@@messages[:range_type_unmatch] = "not a %s."
|
79
|
+
@@messages[:range_undefined] = "undefined key."
|
80
|
+
@@messages[:range_twomax] = "both 'max' and 'max-ex' are not available at once."
|
81
|
+
@@messages[:range_twomin] = "both 'min' and 'min-ex' are not available at once."
|
82
|
+
@@messages[:range_maxltmin] = "max '%s' is less than min '%s'."
|
83
|
+
@@messages[:range_maxleminex] = "max '%s' is less than or equal to min-ex '%s'."
|
84
|
+
@@messages[:range_maxexlemin] = "max-ex '%s' is less than or equal to min '%s'."
|
85
|
+
@@messages[:range_maxexleminex] = "max-ex '%s' is less than or equal to min-ex '%s'."
|
86
|
+
@@messages[:length_notmap] = "not a mapping."
|
87
|
+
@@messages[:length_nottext] = "is available only with string or text."
|
88
|
+
@@messages[:length_notint] = "not an integer."
|
89
|
+
@@messages[:length_undefined] = "undefined key."
|
90
|
+
@@messages[:length_twomax] = "both 'max' and 'max-ex' are not available at once."
|
91
|
+
@@messages[:length_twomin] = "both 'min' and 'min-ex' are not available at once."
|
92
|
+
@@messages[:length_maxltmin] = "max '%s' is less than min '%s'."
|
93
|
+
@@messages[:length_maxleminex] = "max '%s' is less than or equal to min-ex '%s'."
|
94
|
+
@@messages[:length_maxexlemin] = "max-ex '%s' is less than or equal to min '%s'."
|
95
|
+
@@messages[:length_maxexleminex] = "max-ex '%s' is less than or equal to min-ex '%s'."
|
96
|
+
@@messages[:ident_notbool] = "not a boolean."
|
97
|
+
@@messages[:ident_notscalar] = "is available only with a scalar type."
|
98
|
+
@@messages[:ident_onroot] = "is not available on root element."
|
99
|
+
@@messages[:ident_notmap] = "is available only with an element of mapping."
|
100
|
+
@@messages[:unique_notbool] = "not a boolean."
|
101
|
+
@@messages[:unique_notscalar] = "is available only with a scalar type."
|
102
|
+
@@messages[:unique_onroot] = "is not available on root element."
|
103
|
+
@@messages[:default_nonscalarval] = "not a scalar."
|
104
|
+
@@messages[:default_notscalar] = "is available only with a scalar type."
|
105
|
+
@@messages[:default_unmatch] = "not a %s."
|
106
|
+
@@messages[:sequence_notseq] = "not a sequence."
|
107
|
+
@@messages[:sequence_noelem] = "required one element."
|
108
|
+
@@messages[:sequence_toomany] = "required just one element."
|
109
|
+
@@messages[:mapping_notmap] = "not a mapping."
|
110
|
+
@@messages[:mapping_noelem] = "required at least one element."
|
111
|
+
@@messages[:seq_nosequence] = "type 'seq' requires 'sequence:'."
|
112
|
+
@@messages[:seq_conflict] = "not available with sequence."
|
113
|
+
@@messages[:map_nomapping] = "type 'map' requires 'mapping:'."
|
114
|
+
@@messages[:map_conflict] = "not available with mapping."
|
115
|
+
@@messages[:scalar_conflict] = "not available with scalar type."
|
116
|
+
@@messages[:enum_conflict] = "not available with 'enum:'."
|
117
|
+
@@messages[:default_conflict] = "not available when 'required:' is true."
|
118
|
+
# --
|
119
|
+
# filename: lib/kwalify/validator.rb
|
120
|
+
@@messages[:required_novalue] = "value required but none."
|
121
|
+
@@messages[:type_unmatch] = "not a %s."
|
122
|
+
@@messages[:key_undefined] = "key '%s' is undefined."
|
123
|
+
@@messages[:required_nokey] = "key '%s:' is required."
|
124
|
+
@@messages[:value_notunique] = "is already used at '%s'."
|
125
|
+
@@messages[:assert_failed] = "assertion expression failed (%s)."
|
126
|
+
@@messages[:enum_notexist] = "invalid %s value."
|
127
|
+
@@messages[:pattern_unmatch] = "not matched to pattern %s."
|
128
|
+
@@messages[:range_toolarge] = "too large (> max %s)."
|
129
|
+
@@messages[:range_toosmall] = "too small (< min %s)."
|
130
|
+
@@messages[:range_toolargeex] = "too large (>= max %s)."
|
131
|
+
@@messages[:range_toosmallex] = "too small (<= min %s)."
|
132
|
+
@@messages[:length_toolong] = "too long (length %d > max %d)."
|
133
|
+
@@messages[:length_tooshort] = "too short (length %d < min %d)."
|
134
|
+
@@messages[:length_toolongex] = "too long (length %d >= max %d)."
|
135
|
+
@@messages[:length_tooshortex] = "too short (length %d <= min %d)."
|
136
|
+
# --
|
137
|
+
# filename: lib/kwalify/yaml-parser.rb
|
138
|
+
@@messages[:flow_hastail] = "flow style sequence is closed but got '%s'."
|
139
|
+
@@messages[:flow_eof] = "found EOF when parsing flow style."
|
140
|
+
@@messages[:flow_alias_label] = "alias name expected."
|
141
|
+
@@messages[:flow_anchor_label] = "anchor name expected."
|
142
|
+
@@messages[:flow_noseqitem] = "sequence item required (or last comma is extra)."
|
143
|
+
@@messages[:flow_seqnotclosed] = "flow style sequence requires ']'."
|
144
|
+
@@messages[:flow_mapnoitem] = "mapping item required (or last comma is extra)."
|
145
|
+
@@messages[:flow_mapnotclosed] = "flow style mapping requires '}'."
|
146
|
+
@@messages[:flow_nocolon] = "':' expected but got %s."
|
147
|
+
@@messages[:flow_str_notclosed] = "%s: string not closed."
|
148
|
+
@@messages[:anchor_duplicated] = "anchor '%s' is already used."
|
149
|
+
@@messages[:alias_extradata] = "alias cannot take any data."
|
150
|
+
@@messages[:anchor_notfound] = "anchor '%s' not found"
|
151
|
+
@@messages[:sequence_noitem] = "sequence item is expected."
|
152
|
+
@@messages[:sequence_badindent] = "illegal indent of sequence."
|
153
|
+
@@messages[:mapping_noitem] = "mapping item is expected."
|
154
|
+
@@messages[:mapping_badindent] = "illegal indent of mapping."
|
155
|
+
# --
|
156
|
+
##----- end
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
@@words = {}
|
162
|
+
|
163
|
+
def self.word(key)
|
164
|
+
return @@words[key] || key
|
165
|
+
end
|
166
|
+
|
167
|
+
@@words['str'] = 'string'
|
168
|
+
@@words['int'] = 'integer'
|
169
|
+
@@words['bool'] = 'boolean'
|
170
|
+
@@words['seq'] = 'sequence'
|
171
|
+
@@words['map'] = 'mapping'
|
172
|
+
|
173
|
+
end
|
@@ -0,0 +1,275 @@
|
|
1
|
+
###
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.2 $
|
4
|
+
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
5
|
+
###
|
6
|
+
|
7
|
+
require 'kwalify/errors'
|
8
|
+
require 'kwalify/rule'
|
9
|
+
require 'kwalify/validator'
|
10
|
+
require 'kwalify/parser/yaml'
|
11
|
+
#require 'yaml'
|
12
|
+
|
13
|
+
module Kwalify
|
14
|
+
|
15
|
+
|
16
|
+
##
|
17
|
+
## ex.
|
18
|
+
## meta_validator = Kwalify::MetaValidator.instance()
|
19
|
+
## schema = File.load_file('schema.yaml')
|
20
|
+
## errors = meta_validator.validate(schema)
|
21
|
+
## if !errors.empty?
|
22
|
+
## errors.each do |error|
|
23
|
+
## puts "[#{error.path}] #{error.message}"
|
24
|
+
## end
|
25
|
+
## end
|
26
|
+
##
|
27
|
+
class MetaValidator < Validator
|
28
|
+
|
29
|
+
filename = File.join(File.dirname(__FILE__), 'kwalify.schema.yaml')
|
30
|
+
META_SCHEMA = File.read(filename)
|
31
|
+
|
32
|
+
def self.instance()
|
33
|
+
unless @instance
|
34
|
+
schema = Kwalify::Yaml::Parser.new().parse(META_SCHEMA)
|
35
|
+
@instance = MetaValidator.new(schema)
|
36
|
+
end
|
37
|
+
return @instance
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(schema, &block)
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate_hook(value, rule, path, errors)
|
45
|
+
return if value.nil? ## realy?
|
46
|
+
return unless rule.name == "MAIN"
|
47
|
+
#
|
48
|
+
hash = value
|
49
|
+
type = hash['type']
|
50
|
+
type = Types::DEFAULT_TYPE if type.nil?
|
51
|
+
klass = Types.type_class(type)
|
52
|
+
#unless klass
|
53
|
+
# errors << validate_error(:type_unknown, rule, "#{path}/type", type)
|
54
|
+
#end
|
55
|
+
#
|
56
|
+
if hash.key?('class')
|
57
|
+
val = hash['class']
|
58
|
+
unless val.nil? || type == 'map'
|
59
|
+
errors << validate_error(:class_notmap, rule, "#{path}/class", 'class:')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
#
|
63
|
+
if hash.key?('pattern')
|
64
|
+
val = hash['pattern']
|
65
|
+
pat = (val =~ /\A\/(.*)\/([mi]?[mi]?)\z/ ? $1 : val)
|
66
|
+
begin
|
67
|
+
Regexp.compile(pat)
|
68
|
+
rescue RegexpError => ex
|
69
|
+
errors << validate_error(:pattern_syntaxerr, rule, "#{path}/pattern", val)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
#
|
73
|
+
if hash.key?('enum')
|
74
|
+
if Types.collection_type?(type)
|
75
|
+
errors << validate_error(:enum_notscalar, rule, path, 'enum:')
|
76
|
+
else
|
77
|
+
#elem_table = {}
|
78
|
+
hash['enum'].each do |elem|
|
79
|
+
#if elem_table[elem]
|
80
|
+
# errors << validate_error(:enum_duplicate, rule, "#{path}/enum", elem.to_s)
|
81
|
+
#end
|
82
|
+
#elem_table[elem] = true
|
83
|
+
unless elem.is_a?(klass)
|
84
|
+
errors << validate_error(:enum_type_unmatch, rule, "#{path}/enum", elem, [Kwalify.word(type)])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
#
|
90
|
+
if hash.key?('assert')
|
91
|
+
val = hash['assert']
|
92
|
+
#val =~ /\bval\b/ or errors << validate_error(:assert_noval, rule, "#{path}/assert", val)
|
93
|
+
begin
|
94
|
+
eval "proc { |val| #{val} }"
|
95
|
+
rescue ::SyntaxError => ex
|
96
|
+
errors << validate_error(:assert_syntaxerr, rule, "#{path}/assert", val)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
#
|
100
|
+
if hash.key?('range')
|
101
|
+
val = hash['range']
|
102
|
+
curr_path = path + "/range"
|
103
|
+
#if ! val.is_a?(Hash)
|
104
|
+
# errors << validate_error(:range_notmap, rule, curr_path, val)
|
105
|
+
#elsif ...
|
106
|
+
if Types.collection_type?(type) || type == 'bool' || type == 'any'
|
107
|
+
errors << validate_error(:range_notscalar, rule, path, 'range:')
|
108
|
+
else
|
109
|
+
val.each do |rkey, rval|
|
110
|
+
#case rkey
|
111
|
+
#when 'max', 'min', 'max-ex', 'min-ex'
|
112
|
+
unless rval.is_a?(klass)
|
113
|
+
typename = Kwalify.word(type) || type
|
114
|
+
errors << validate_error(:range_type_unmatch, rule, "#{curr_path}/#{rkey}", rval, [typename])
|
115
|
+
end
|
116
|
+
#else
|
117
|
+
# errors << validate_error(:range_undefined, rule, curr_path, "#{rkey}:")
|
118
|
+
#end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
if val.key?('max') && val.key?('max-ex')
|
122
|
+
errors << validate_error(:range_twomax, rule, curr_path, nil)
|
123
|
+
end
|
124
|
+
if val.key?('min') && val.key?('min-ex')
|
125
|
+
errors << validate_error(:range_twomin, rule, curr_path, nil)
|
126
|
+
end
|
127
|
+
max, min, max_ex, min_ex = val['max'], val['min'], val['max-ex'], val['min-ex']
|
128
|
+
if max
|
129
|
+
if min && max < min
|
130
|
+
errors << validate_error(:range_maxltmin, rule, curr_path, nil, [max, min])
|
131
|
+
elsif min_ex && max <= min_ex
|
132
|
+
errors << validate_error(:range_maxleminex, rule, curr_path, nil, [max, min_ex])
|
133
|
+
end
|
134
|
+
elsif max_ex
|
135
|
+
if min && max_ex <= min
|
136
|
+
errors << validate_error(:range_maxexlemin, rule, curr_path, nil, [max_ex, min])
|
137
|
+
elsif min_ex && max_ex <= min_ex
|
138
|
+
errors << validate_error(:range_maxexleminex, rule, curr_path, nil, [max_ex, min_ex])
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
#
|
143
|
+
if hash.key?('length')
|
144
|
+
val = hash['length']
|
145
|
+
curr_path = path + "/length"
|
146
|
+
#val.is_a?(Hash) or errors << validate_error(:length_notmap, rule, curr_path, val)
|
147
|
+
unless type == 'str' || type == 'text'
|
148
|
+
errors << validate_error(:length_nottext, rule, path, 'length:')
|
149
|
+
end
|
150
|
+
#val.each do |lkey, lval|
|
151
|
+
# #case lkey
|
152
|
+
# #when 'max', 'min', 'max-ex', 'min-ex'
|
153
|
+
# unless lval.is_a?(Integer)
|
154
|
+
# errors << validate_error(:length_notint, rule, "#{curr_path}/#{lkey}", lval)
|
155
|
+
# end
|
156
|
+
# #else
|
157
|
+
# # errors << validate_error(:length_undefined, rule, curr_path, "#{lkey}:")
|
158
|
+
# #end
|
159
|
+
#end
|
160
|
+
if val.key?('max') && val.key?('max-ex')
|
161
|
+
errors << validate_error(:length_twomax, rule, curr_path, nil)
|
162
|
+
end
|
163
|
+
if val.key?('min') && val.key?('min-ex')
|
164
|
+
errors << validate_error(:length_twomin, rule, curr_path, nil)
|
165
|
+
end
|
166
|
+
max, min, max_ex, min_ex = val['max'], val['min'], val['max-ex'], val['min-ex']
|
167
|
+
if max
|
168
|
+
if min && max < min
|
169
|
+
errors << validate_error(:length_maxltmin, rule, curr_path, nil, [max, min])
|
170
|
+
elsif min_ex && max <= min_ex
|
171
|
+
errors << validate_error(:length_maxleminex, rule, curr_path, nil, [max, min_ex])
|
172
|
+
end
|
173
|
+
elsif max_ex
|
174
|
+
if min && max_ex <= min
|
175
|
+
errors << validate_error(:length_maxexlemin, rule, curr_path, nil, [max_ex, min])
|
176
|
+
elsif min_ex && max_ex <= min_ex
|
177
|
+
errors << validate_error(:length_maxexleminex, rule, curr_path, nil, [max_ex, min_ex])
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
#
|
182
|
+
if hash.key?('unique')
|
183
|
+
if hash['unique'] && Types.collection_type?(type)
|
184
|
+
errors << validate_error(:unique_notscalar, rule, path, "unique:")
|
185
|
+
end
|
186
|
+
if path.empty?
|
187
|
+
errors << validate_error(:unique_onroot, rule, "/", "unique:")
|
188
|
+
end
|
189
|
+
end
|
190
|
+
#
|
191
|
+
if hash.key?('ident')
|
192
|
+
if hash['ident'] && Types.collection_type?(type)
|
193
|
+
errors << validate_error(:ident_notscalar, rule, path, "ident:")
|
194
|
+
end
|
195
|
+
if path.empty?
|
196
|
+
errors << validate_error(:ident_onroot, rule, "/", "ident:")
|
197
|
+
end
|
198
|
+
end
|
199
|
+
#
|
200
|
+
if hash.key?('default')
|
201
|
+
val = hash['default']
|
202
|
+
if Types.collection_type?(type)
|
203
|
+
errors << validate_error(:default_notscalar, rule, path, "default:")
|
204
|
+
elsif !val.nil? && !val.is_a?(klass)
|
205
|
+
errors << validate_error(:default_unmatch, rule, "#{path}/default", val, [Kwalify.word(type)])
|
206
|
+
end
|
207
|
+
end
|
208
|
+
#
|
209
|
+
if hash.key?('sequence')
|
210
|
+
val = hash['sequence']
|
211
|
+
#if !val.nil? && !val.is_a?(Array)
|
212
|
+
# errors << validate_error(:sequence_notseq, rule, "#{path}/sequence", val)
|
213
|
+
#elsif ...
|
214
|
+
if val.nil? || val.empty?
|
215
|
+
errors << validate_error(:sequence_noelem, rule, "#{path}/sequence", val)
|
216
|
+
elsif val.length > 1
|
217
|
+
errors << validate_error(:sequence_toomany, rule, "#{path}/sequence", val)
|
218
|
+
else
|
219
|
+
elem = val[0]
|
220
|
+
assert_error("elem.class=#{elem.class}") unless elem.is_a?(Hash)
|
221
|
+
if elem['ident'] && elem['type'] != 'map'
|
222
|
+
errors << validate_error(:ident_notmap, nil, "#{path}/sequence/0", 'ident:')
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
#
|
227
|
+
if hash.key?('mapping')
|
228
|
+
val = hash['mapping']
|
229
|
+
if !val.nil? && !val.is_a?(Hash)
|
230
|
+
errors << validate_error(:mapping_notmap, rule, "#{path}/mapping", val)
|
231
|
+
elsif val.nil? || (val.empty? && !val.default)
|
232
|
+
errors << validate_error(:mapping_noelem, rule, "#{path}/mapping", val)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
#
|
236
|
+
if type == 'seq'
|
237
|
+
errors << validate_error(:seq_nosequence, rule, path, nil) unless hash.key?('sequence')
|
238
|
+
#errors << validate_error(:seq_conflict, rule, path, 'enum:') if hash.key?('enum')
|
239
|
+
errors << validate_error(:seq_conflict, rule, path, 'pattern:') if hash.key?('pattern')
|
240
|
+
errors << validate_error(:seq_conflict, rule, path, 'mapping:') if hash.key?('mapping')
|
241
|
+
#errors << validate_error(:seq_conflict, rule, path, 'range:') if hash.key?('range')
|
242
|
+
#errors << validate_error(:seq_conflict, rule, path, 'length:') if hash.key?('length')
|
243
|
+
elsif type == 'map'
|
244
|
+
errors << validate_error(:map_nomapping, rule, path, nil) unless hash.key?('mapping')
|
245
|
+
#errors << validate_error(:map_conflict, rule, path, 'enum:') if hash.key?('enum')
|
246
|
+
errors << validate_error(:map_conflict, rule, path, 'pattern:') if hash.key?('pattern')
|
247
|
+
errors << validate_error(:map_conflict, rule, path, 'sequence:') if hash.key?('sequence')
|
248
|
+
#errors << validate_error(:map_conflict, rule, path, 'range:') if hash.key?('range')
|
249
|
+
#errors << validate_error(:map_conflict, rule, path, 'length:') if hash.key?('length')
|
250
|
+
else
|
251
|
+
errors << validate_error(:scalar_conflict, rule, path, 'sequence:') if hash.key?('sequence')
|
252
|
+
errors << validate_error(:scalar_conflict, rule, path, 'mapping:') if hash.key?('mapping')
|
253
|
+
if hash.key?('enum')
|
254
|
+
errors << validate_error(:enum_conflict, rule, path, 'range:') if hash.key?('range')
|
255
|
+
errors << validate_error(:enum_conflict, rule, path, 'length:') if hash.key?('length')
|
256
|
+
errors << validate_error(:enum_conflict, rule, path, 'pattern:') if hash.key?('pattern')
|
257
|
+
end
|
258
|
+
if hash.key?('default')
|
259
|
+
errors << validate_error(:default_conflict, rule, path, 'default:') if hash['required']
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
end # end of def validate_hook()
|
264
|
+
|
265
|
+
|
266
|
+
end # end of class MetaValidator
|
267
|
+
|
268
|
+
|
269
|
+
META_VALIDATOR = MetaValidator.instance()
|
270
|
+
|
271
|
+
def self.meta_validator # obsolete
|
272
|
+
return META_VALIDATOR
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
###
|
2
|
+
### $Rev$
|
3
|
+
### $Release: 0.7.2 $
|
4
|
+
### copyright(c) 2005-2010 kuwata-lab all rights reserved.
|
5
|
+
###
|
6
|
+
|
7
|
+
require 'strscan'
|
8
|
+
require 'kwalify/errors'
|
9
|
+
require 'kwalify/util'
|
10
|
+
|
11
|
+
|
12
|
+
##
|
13
|
+
## base class for Yaml::Parser
|
14
|
+
##
|
15
|
+
class Kwalify::BaseParser
|
16
|
+
|
17
|
+
|
18
|
+
def reset(input, filename=nil, untabify=false)
|
19
|
+
input = Kwalify::Util.untabify(input) if untabify
|
20
|
+
@scanner = StringScanner.new(input)
|
21
|
+
@filename = filename
|
22
|
+
@linenum = 1
|
23
|
+
@column = 1
|
24
|
+
end
|
25
|
+
attr_reader :filename, :linenum, :column
|
26
|
+
|
27
|
+
|
28
|
+
def scan(regexp)
|
29
|
+
ret = @scanner.scan(regexp)
|
30
|
+
return nil if ret.nil?
|
31
|
+
_set_column_and_linenum(ret)
|
32
|
+
return ret
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def _set_column_and_linenum(s)
|
37
|
+
pos = s.rindex(?\n)
|
38
|
+
if pos
|
39
|
+
@column = s.length - pos
|
40
|
+
@linenum += s.count("\n")
|
41
|
+
else
|
42
|
+
@column += s.length
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def match?(regexp)
|
48
|
+
return @scanner.match?(regexp)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def group(n)
|
53
|
+
return @scanner[n]
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def eos?
|
58
|
+
return @scanner.eos?
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def peep(n=1)
|
63
|
+
return @scanner.peep(n)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def _getch
|
68
|
+
ch = @scanner.getch()
|
69
|
+
if ch == "\n"
|
70
|
+
@linenum += 1
|
71
|
+
@column = 0
|
72
|
+
else
|
73
|
+
@column += 1
|
74
|
+
end
|
75
|
+
return ch
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
CHAR_TABLE = { "\""=>"\"", "\\"=>"\\", "n"=>"\n", "r"=>"\r", "t"=>"\t", "b"=>"\b" }
|
80
|
+
|
81
|
+
def scan_string
|
82
|
+
ch = _getch()
|
83
|
+
ch == '"' || ch == "'" or raise "assertion error"
|
84
|
+
endch = ch
|
85
|
+
s = ''
|
86
|
+
while !(ch = _getch()).nil? && ch != endch
|
87
|
+
if ch != '\\'
|
88
|
+
s << ch
|
89
|
+
elsif (ch = _getch()).nil?
|
90
|
+
raise _syntax_error("%s: string is not closed." % (endch == '"' ? "'\"'" : '"\'"'))
|
91
|
+
elsif endch == '"'
|
92
|
+
if CHAR_TABLE.key?(ch)
|
93
|
+
s << CHAR_TABLE[ch]
|
94
|
+
elsif ch == 'u'
|
95
|
+
ch2 = scan(/(?:[0-9a-f][0-9a-f]){1,4}/)
|
96
|
+
unless ch2
|
97
|
+
raise _syntax_error("\\x: invalid unicode format.")
|
98
|
+
end
|
99
|
+
s << [ch2.hex].pack('U*')
|
100
|
+
elsif ch == 'x'
|
101
|
+
ch2 = scan(/[0-9a-zA-Z][0-9a-zA-Z]/)
|
102
|
+
unless ch2
|
103
|
+
raise _syntax_error("\\x: invalid binary format.")
|
104
|
+
end
|
105
|
+
s << [ch2].pack('H2')
|
106
|
+
else
|
107
|
+
s << "\\" << ch
|
108
|
+
end
|
109
|
+
elsif endch == "'"
|
110
|
+
ch == '\'' || ch == '\\' ? s << ch : s << '\\' << ch
|
111
|
+
else
|
112
|
+
raise "unreachable"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
#_getch()
|
116
|
+
return s
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
def _syntax_error(message, path=nil, linenum=@linenum, column=@column)
|
121
|
+
#message = _build_message(message_key)
|
122
|
+
return _error(Kwalify::SyntaxError, message.to_s, path, linenum, column)
|
123
|
+
end
|
124
|
+
protected :_syntax_error
|
125
|
+
|
126
|
+
|
127
|
+
end
|