<commit_before>require 'fog/model'

module Fog
  class Local

    class File < Fog::Model

      identity  :key,             'Key'

      attr_accessor :body
      attribute :content_length,  'Content-Length'
      # attribute :content_type,    'Content-Type'
      attribute :last_modified,   'Last-Modified'

      def body
        @body ||= if last_modified
          collection.get(identity).body
        else
          ''
        end
      end

      def directory
        @directory
      end

      def destroy
        requires :directory, :key
        ::File.delete(path)
        true
      end

      def save(options = {})
        requires :body, :directory, :key
        file = ::File.new(path, 'w')
        file.write(body)
        file.close
        merge_attributes(
          :content_length => ::File.size(path),
          :last_modified  => ::File.mtime(path)
        )
        true
      end

      private

      def directory=(new_directory)
        @directory = new_directory
      end

      def path
        connection.path_to(::File.join(directory.key, key))
      end

    end

  end
end
<commit_msg>update attribute to consistently take hash and remove legacy array of aliases usage<commit_after>require 'fog/model'

module Fog
  class Local

    class File < Fog::Model

      identity  :key,             'Key'

      attr_accessor :body
      attribute :content_length,  :aliases => 'Content-Length'
      # attribute :content_type,    :aliases => 'Content-Type'
      attribute :last_modified,   :aliases => 'Last-Modified'

      def body
        @body ||= if last_modified
          collection.get(identity).body
        else
          ''
        end
      end

      def directory
        @directory
      end

      def destroy
        requires :directory, :key
        ::File.delete(path)
        true
      end

      def save(options = {})
        requires :body, :directory, :key
        file = ::File.new(path, 'w')
        file.write(body)
        file.close
        merge_attributes(
          :content_length => ::File.size(path),
          :last_modified  => ::File.mtime(path)
        )
        true
      end

      private

      def directory=(new_directory)
        @directory = new_directory
      end

      def path
        connection.path_to(::File.join(directory.key, key))
      end

    end

  end
end

{'fraction_non_alphanumeric': 0.09380305602716468, 'fraction_numerical': 0.0, 'mean_word_length': 1.7248554913294798, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '95110', 'n_tokens_mistral': 684, 'n_tokens_neox': 661, 'n_words': 167}