From: Stefano Rivera <stefanor@debian.org>
Date: Sat, 19 May 2018 22:27:57 +0200
Subject: 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.
Forwarded: not-needed
Last-Updated: 2013-06-05
---
 bin/foodcritic         |  2 +-
 lib/foodcritic/chef.rb | 16 +++++++++++++---
 spec/spec_helper.rb    |  2 +-
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/bin/foodcritic b/bin/foodcritic
index 8652a47..8094b49 100755
--- a/bin/foodcritic
+++ b/bin/foodcritic
@@ -1,3 +1,3 @@
 #!/usr/bin/env ruby
-require_relative "../lib/foodcritic"
+require "foodcritic"
 exit FoodCritic::CommandLine.main
diff --git a/lib/foodcritic/chef.rb b/lib/foodcritic/chef.rb
index 17e87e6..a2dfb54 100644
--- a/lib/foodcritic/chef.rb
+++ b/lib/foodcritic/chef.rb
@@ -60,8 +60,13 @@ module FoodCritic
     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 @@ module FoodCritic
       # 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.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 85f6018..1ef5d56 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -129,4 +129,4 @@ RSpec.configure do |config|
   config.include FunctionalHelpers, functional: true
 end
 
-require_relative "../lib/foodcritic"
+require "foodcritic"
