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.run(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)
@@ -85,7 +90,12 @@
       # lucene.treetop used to be provided by chef gem
       # We're keeping a local copy from chef 10.x
       def chef_search_grammars
-        [File.expand_path('../../..', __FILE__) + "/misc/lucene.treetop"]
+        local_grammar = File.expand_path('../../../misc/lucene.treetop', __FILE__)
+        if File.exists? local_grammar
+          [local_grammar]
+        else
+          ['/usr/share/foodcritic/misc/lucene.treetop']
+        end
       end
 
       # Create the search parser from the first loadable grammar.
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -11,4 +11,4 @@
 require 'minitest/pride'
 require 'minitest/spec'
 
-require_relative '../lib/foodcritic'
+require 'foodcritic'
