Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7114

Help to create a New rule in foodcritic

Newsgroups comp.lang.ruby
Date 2015-05-10 18:53 -0700
Message-ID <728419e3-8bbf-4fa5-9bf9-d7c6fc1b090c@googlegroups.com> (permalink)
Subject Help to create a New rule in foodcritic
From Kiran Krishnamurthy <kiranhk@gmail.com>

Show all headers | View raw


I am new to Ruby and FoodCritic(http://acrmp.github.io/foodcritic/). Can you please help me with writing a food critic rule. The following is the config I have:

name "server1"
description "server 1 Environment"
cookbook_versions({
    "configname1" => "",
    "configname2" => "= 1.0.0",
    "configname3" => "= 0.1.0",
})

override_attributes(
     "dbdetails" => {
     "DBUserName" => "xyz",
     "DBPassword" => "abc",
     "JDBCurl" => "jdbc:oracle:thin:@xzy:1521:abc"
})

this is what I am starting to write in the food critic rule:

rule "ABC001", "All cookbook versions dependencies must have version " do
tags %w{correctness metadata hasversion}
metadata do |ast|
   ast.xpath(%q{//command[ident/@value='cookbook_versions'})
end
end

the ast.xpath will give me the cookbook_versions after that, how do I get the child elements configname1, configname2, configname3 etc and check if it has the version details on the right side?

thanks for your help

Back to comp.lang.ruby | Previous | Next | Find similar


Thread

Help to create a New rule in foodcritic Kiran Krishnamurthy <kiranhk@gmail.com> - 2015-05-10 18:53 -0700

csiph-web