Module: FoodCritic::Chef
- Included in:
- Api
- Defined in:
- lib/foodcritic/chef.rb
Overview
Encapsulates functions that previously were calls to the Chef gem.
Defined Under Namespace
Classes: Search
Instance Method Summary collapse
- #chef_dsl_methods ⇒ Object
- #chef_node_methods ⇒ Object
-
#resource_action?(resource_type, action) ⇒ Boolean
Is the specified action valid for the type of resource?.
-
#resource_attribute?(resource_type, attribute_name) ⇒ Boolean
Is the specified attribute valid for the type of resource?.
-
#valid_query?(query) ⇒ Boolean
Is this a valid Lucene query?.
Instance Method Details
#chef_dsl_methods ⇒ Object
4 5 6 7 |
# File 'lib/foodcritic/chef.rb', line 4 def chef_dsl_methods @dsl_metadata[:dsl_methods].map(&:to_sym) end |
#chef_node_methods ⇒ Object
9 10 11 12 |
# File 'lib/foodcritic/chef.rb', line 9 def chef_node_methods @dsl_metadata[:node_methods].map(&:to_sym) end |
#resource_action?(resource_type, action) ⇒ Boolean
Is the specified action valid for the type of resource?
15 16 17 |
# File 'lib/foodcritic/chef.rb', line 15 def resource_action?(resource_type, action) resource_check?(:actions, resource_type, action) end |
#resource_attribute?(resource_type, attribute_name) ⇒ Boolean
Is the specified attribute valid for the type of resource?
20 21 22 |
# File 'lib/foodcritic/chef.rb', line 20 def resource_attribute?(resource_type, attribute_name) resource_check?(:attributes, resource_type, attribute_name) end |
#valid_query?(query) ⇒ Boolean
Is this a valid Lucene query?
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/foodcritic/chef.rb', line 25 def valid_query?(query) raise ArgumentError, "Query cannot be nil or empty" if query.to_s.empty? # Attempt to create a search query parser search = FoodCritic::Chef::Search.new search.create_parser(search.chef_search_grammars) if search.parser? search.parser.parse(query.to_s) else # If we didn't manage to get a parser then we can't know if the query # is valid or not. true end end |