<commit_before>#
# Copyright:: Copyright (c) 2014 Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef-dk/cookbook_omnifetch'
require 'chef-dk/exceptions'

module ChefDK
  module Policyfile

    class StorageConfig

      attr_accessor :relative_paths_root
      attr_accessor :cache_path

      attr_reader :policyfile_filename
      attr_reader :policyfile_lock_filename

      def initialize(options = {})
        @relative_paths_root = Dir.pwd
        @cache_path = CookbookOmnifetch.storage_path
        @policyfile_filename = "<< Policyfile filename not specified >>"
        @policyfile_lock_filename = "<< Policyfile lock filename not specified >>"
        handle_options(options)
      end

      def use_policyfile(policyfile_filename)
        unless policyfile_filename.end_with?(".rb")
          raise InvalidPolicyfileFilename, "Policyfile filenames must end with `.rb' extension (you gave: `#{policyfile_filename}')"
        end
        @policyfile_filename = policyfile_filename
        @policyfile_lock_filename = policyfile_filename.sub(/\.rb\Z/, '.lock.json')
        @relative_paths_root = File.dirname(policyfile_filename)
        self
      end

      def use_policyfile_lock(policyfile_lock_filename)
        @policyfile_lock_filename = policyfile_lock_filename
        @policyfile_filename = policyfile_lock_filename.sub(/\.lock\.json\Z/, '.rb')
        @relative_paths_root = File.dirname(policyfile_lock_filename)
        self
      end

      def policyfile_expanded_path
        File.expand_path(policyfile_filename, relative_paths_root)
      end
<commit_msg>Accept foo.lock.json as well as foo.rb when loading a policyfile<commit_after>#
# Copyright:: Copyright (c) 2014 Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef-dk/cookbook_omnifetch'
require 'chef-dk/exceptions'

module ChefDK
  module Policyfile

    class StorageConfig

      attr_accessor :relative_paths_root
      attr_accessor :cache_path

      attr_reader :policyfile_filename
      attr_reader :policyfile_lock_filename

      def initialize(options = {})
        @relative_paths_root = Dir.pwd
        @cache_path = CookbookOmnifetch.storage_path
        @policyfile_filename = "<< Policyfile filename not specified >>"
        @policyfile_lock_filename = "<< Policyfile lock filename not specified >>"
        handle_options(options)
      end

      def use_policyfile(policyfile_filename)
        if policyfile_filename.end_with?(".lock.json")
          policyfile_filename = policyfile_filename.sub(/\.lock.json\Z/, '.rb')
        end
        unless policyfile_filename.end_with?(".rb")
          raise InvalidPolicyfileFilename, "Policyfile filenames must end with `.rb' extension (you gave: `#{policyfile_filename}')"
        end
        @policyfile_filename = policyfile_filename
        @policyfile_lock_filename = policyfile_filename.sub(/\.rb\Z/, '.lock.json')
        @relative_paths_root = File.dirname(policyfile_filename)
        self
      end

      def use_policyfile_lock(policyfile_lock_filename)
        @policyfile_lock_filename = policyfile_lock_filename
        @policyfile_filename = policyfile_lock_filename.sub(/\.lock\.json\Z/, '.rb')
        @relative_paths_root = File.dirname(policyfile_lock_filename)
        self
      end

      def policyfile_expanded_path
        File.expand_path(policyfile_filename, relative_paths_root)
      end

{'fraction_non_alphanumeric': 0.07960088691796009, 'fraction_numerical': 0.004434589800443459, 'mean_word_length': 3.4975074775672983, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3617273', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1243, 'n_words': 355}