Class: Udb::CliCommands::Validate
Instance Method Summary
collapse
banner, subcommand_prefix
Instance Method Details
#cfg(name_or_path) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/udb/cli.rb', line 87
def cfg(name_or_path)
raise ArgumentError, "Spec directory does not exist: #{options[:std]}" unless File.directory?(options[:std])
Udb.global_options.parallel_z3 = options[:z3parallel]
cfg_file =
if File.file?(name_or_path)
Pathname.new(name_or_path)
elsif File.file?("#{options[:config_dir]}/#{name_or_path}.yaml")
Pathname.new("#{options[:config_dir]}/#{name_or_path}.yaml")
elsif File.file?("#{options[:config_dir]}/profile/#{name_or_path}.yaml")
Pathname.new("#{options[:config_dir]}/profile/#{name_or_path}.yaml")
else
raise ArgumentError, "Cannot find config: #{name_or_path}"
end
resolver =
Udb::Resolver.new(
std_path_override: Pathname.new(options[:std]),
gen_path_override: Pathname.new(options[:gen]),
custom_path_override: Pathname.new(options[:custom])
)
begin
cfg_arch = resolver.cfg_arch_for(cfg_file.realpath)
rescue InvalidConfigError
say "Config is #{pastel.red.bold("invalid")}"
exit 1
end
result =
if options[:strict_partial]
cfg_arch.partial_config_strictly_specified?
else
cfg_arch.valid?
end
if result.valid
say "Config #{pastel.bold(cfg_arch.name)} is #{pastel.green.bold("valid")}"
else
say "Config #{pastel.bold(cfg_arch.name)} is #{pastel.red.bold("invalid")}"
say ""
result.reasons.each do |r|
say " * #{pastel.yellow.bold(r.gsub("\n", "\n "))}"
end
exit 1
end
end
|
#spec ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/udb/cli.rb', line 50
def spec
cfg_file =
if File.file?(options[:config])
Pathname.new(options[:config])
elsif File.file?("#{options[:config_dir]}/#{options[:config]}.yaml")
Pathname.new("#{options[:config_dir]}/#{options[:config]}.yaml")
else
raise ArgumentError, "Cannot find config: #{options[:config]}"
end
resolver =
Udb::Resolver.new(
std_path_override: Pathname.new(options[:std]),
gen_path_override: Pathname.new(options[:gen]),
custom_path_override: Pathname.new(options[:custom])
)
cfg_arch = resolver.cfg_arch_for(cfg_file.realpath)
puts "Checking arch files against schema.."
cfg_arch.validate($resolver, show_progress: true)
puts "All files validate against their schema"
end
|