Rakefile in junoser-0.5.6 vs Rakefile in junoser-0.6.0

- old
+ new

@@ -18,11 +18,11 @@ i.close o.close end def move_wildcards(element) - ['ipaddr', 'ipv6addr', 'ipprefix'].each do |pattern| + %w[ipaddr ipv6addr ipprefix].each do |pattern| element.xpath(%[.//xsd:element[@type="#{pattern}"]/xsd:annotation/xsd:appinfo/flag[text()="nokeyword"]/../../..]).each do |wildcard| parent = wildcard.parent removed = wildcard.remove parent << removed end @@ -58,12 +58,24 @@ task 'find-srx-methods' do vsrx = File.read('vsrx.rb') vmx = File.read('lib/junoser/parser.rb') vsrx.scan(/^ +([0-9a-z_]+) *$/).flatten.uniq.sort.each do |method| - next if ['arg', 'end', 'ipaddr', 'time'].include?(method) + next if %w[arg end ipaddr time].include?(method) puts method unless vsrx =~ /rule\(:#{method}\)/m || vmx =~ /rule\(:#{method}\)/m + end +end + +namespace :rule do + desc 'Show rule tree' + task :tree, [:path] do |_, args| + if args.path + raise "File not found: #{args.path}" unless File.exist?(args.path) + Junoser::RuleTree::Parser.new(File.read(args.path)).print + else + Junoser::RuleTree::Parser.new($stdin.read).print + end end end Rake::TestTask.new do |t| t.libs << 'test'