<commit_before>module ArtifactFile
  module Matcher
  end
end

module ArtifactFile::Matcher
  module Helper
    attr_accessor :name, :artifact_type, :artifact_name
    attr_accessor :folder, :action, :view_ext
    attr_reader :names, :root_path    
    
    def set_view name
      view_options  = name
      self.folder   = view_options[:folder]
      self.action   = view_options[:action] 
      self.view_ext = view_options[:view_ext] 
      self.artifact_type = :view
    end
    
    def handle_view artifact_type, names
      if artifact_type == :view
        lang_option = last_arg({:lang => 'erb.html'}, names)
        raise ArgumentException, ':folder option must be specified in the last hash argument for #have_views' if !lang_option[:folder]          
        self.folder = lang_option[:folder]
        self.view_ext = lang_option[:lang] || {:lang => 'erb.html'}
      end
    end
    
    def get_artifact_name
      case artifact_type
      when :view                                           
        find_view_method = "#{artifact_type}_file_name"
        File.expand_path(send find_view_method, folder, action, view_ext, :root_path => root_path)          
      else                                                     
        find_existing_artifact_method = "existing_#{artifact_type}_file"
        if respond_to? find_existing_artifact_method
          send find_existing_artifact_method, artifact_name, artifact_type, :root_path => root_path 
        else
          raise "The method ##{find_existing_artifact_method} to find the artifact was not available"
        end
      end
    end
    
    def msg
      "the #{artifact_type} #{artifact_name} to exist"
    end

    def failure_message
      "Expected #{msg}"
    end

    def negative_failure_message<commit_msg>better view ext support<commit_after>module ArtifactFile
  module Matcher
  end
end

module ArtifactFile::Matcher
  module Helper
    attr_accessor :name, :artifact_type, :artifact_name
    attr_accessor :folder, :action, :view_ext
    attr_reader :names, :root_path    
    
    def set_view name
      view_options  = name
      self.folder   = view_options[:folder]
      self.action   = view_options[:action] 
      self.view_ext = view_options[:view_ext] 
      self.artifact_type = :view
    end
    
    def handle_view artifact_type, names
      if artifact_type == :view
        lang_option = last_arg({:lang => 'erb.html'}, names)
        raise ArgumentException, ':folder option must be specified in the last hash argument for #have_views' if !lang_option[:folder]          
        self.folder = lang_option[:folder]
        self.view_ext = get_view_ext(lang_option[:lang] || :erb)
      end
    end
    
    def get_view_ext(ext)
      case ext.to_sym
      when :erb
        'erb.html'
      when :haml
        'haml.html'
      else
        ext.to_s
      end
    end
    
    def get_artifact_name
      case artifact_type
      when :view                                           
        find_view_method = "#{artifact_type}_file_name"
        File.expand_path(send find_view_method, folder, action, view_ext, :root_path => root_path)          
      else                                                     
        find_existing_artifact_method = "existing_#{artifact_type}_file"
        if respond_to? find_existing_artifact_method
          send find_existing_artifact_method, artifact_name, artifact_type, :root_path => root_path 
        else
          raise "The method ##{find_existing_artifact_method} to find the artifact was not available"
        end
      end
    end
    
    def msg
      "the #{artifact_type} #{artifact_name} to exist"
    end

    def failure_message
      "Expected #{msg}"
    end

    def negative_failure_message
{'fraction_non_alphanumeric': 0.07150451887293993, 'fraction_numerical': 0.0, 'mean_word_length': 2.2162393162393164, 'pattern_counts': {'":': 0, '<': 3, '<?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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3403133', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1057, 'n_words': 269}