Description: We install into vendor_ruby, and ship data in /usr/share/foodcritic
 require from vendor_ruby instead of a relative require.
 Find chef_dsl_metadata in /usr/share/foodcritic.
Author: Stefano Rivera <stefanor@debian.org>
Forwarded: not-needed
Last-Updated: 2013-06-05

--- a/bin/foodcritic
+++ b/bin/foodcritic
@@ -1,5 +1,5 @@
 #!/usr/bin/env ruby
-require_relative '../lib/foodcritic'
+require 'foodcritic'
 module FoodCritic
   cmd_line = CommandLine.new(ARGV)
   review, status = Linter.check(cmd_line)
--- a/lib/foodcritic/chef.rb
+++ b/lib/foodcritic/chef.rb
@@ -60,8 +60,13 @@
     end
 
     def metadata_path(chef_version)
-      File.join(File.dirname(__FILE__), '..', '..',
-                "chef_dsl_metadata/chef_#{chef_version}.json")
+      local_metadata = File.join(File.dirname(__FILE__), '..', '..',
+                                 'chef_dsl_metadata')
+      if Dir.exists? local_metadata
+        "#{local_metadata}/chef_#{chef_version}.json"
+      else
+        "/usr/share/foodcritic/chef_dsl_metadata/chef_#{chef_version}.json"
+      end
     end
 
     def resource_check?(key, resource_type, field)
@@ -87,9 +92,7 @@
       #   could break our ability to load the grammar).
       # Grammars are not available from Chef 11+.
       def chef_search_grammars
-        Gem.path.map do |gem_path|
-          Dir["#{gem_path}/gems/chef-*/**/lucene.treetop"]
-        end.flatten.sort.reverse
+        Dir["/usr/lib/ruby/vendor_ruby/chef/**/lucene.treetop"]
       end
 
       # Create the search parser from the first loadable grammar.
