<commit_before>module HtmlMockup::Release::Processors
  class Mockup < Base
    
    attr_accessor :project
    
    def initialize(options={})
      @options = {
        :env => {},
        :match => Tilt.mappings.keys.map{|ext| "**/*.#{ext}" }
      }
      
      @options.update(options) if options            
    end

    def call(release, options={})
      self.project = release.project
      
      options = {}.update(@options).update(options)
      
      options[:env].update("MOCKUP_PROJECT" => project)
      
      release.log(self, "Processing mockup files")
      
      release.get_files(options[:match]).each do |file_path|
        self.run_on_file!(file_path, @options[:env])
      end
    end
    
    
    def run_on_file!(file_path, env = {})
      source = self.extract_source_from_file(file_path, env)
      File.open(file_path,"w"){|f| f.write(source) }
    end
    
    # Runs the extractor on a single file and return processed source.
    def extract_source_from_file(file_path, env = {})
      HtmlMockup::Template.open(file_path, :partial_path => self.project.partial_path).render(env.dup)
    end    
    <commit_msg>Pass the layouts_path to the template form the mockup processor<commit_after>module HtmlMockup::Release::Processors
  class Mockup < Base
    
    attr_accessor :project
    
    def initialize(options={})
      @options = {
        :env => {},
        :match => Tilt.mappings.keys.map{|ext| "**/*.#{ext}" }
      }
      
      @options.update(options) if options            
    end

    def call(release, options={})
      self.project = release.project
      
      options = {}.update(@options).update(options)
      
      options[:env].update("MOCKUP_PROJECT" => project)
      
      release.log(self, "Processing mockup files")
      
      release.get_files(options[:match]).each do |file_path|
        self.run_on_file!(file_path, @options[:env])
      end
    end
    
    
    def run_on_file!(file_path, env = {})
      source = self.extract_source_from_file(file_path, env)
      File.open(file_path,"w"){|f| f.write(source) }
    end
    
    # Runs the extractor on a single file and return processed source.
    def extract_source_from_file(file_path, env = {})
      HtmlMockup::Template.open(file_path, :partials_path => self.project.partial_path, :layouts_path => self.project.layouts_path).render(env.dup)
    end    
    
{'fraction_non_alphanumeric': 0.1270371918094442, 'fraction_numerical': 0.0, 'mean_word_length': 2.57847533632287, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '6710006', 'n_tokens_mistral': 758, 'n_tokens_neox': 754, 'n_words': 141}