<commit_before>module Harbor::ViewContext::Helpers::Assets
  def javascript(*sources)
    sources.collect do |source|
      asset = asset_for(source, type: 'js')
      if asset
        if compile_assets?
          asset.to_a.map { |dependency| javascript_tag("#{asset_path(dependency)}?body=1") }
        else
          javascript_tag(asset_path(asset))
        end
      else
        source << ".js" unless source =~ /\.js$/
        source = "/#{source}" unless source =~ /^\// || source =~ /http(s)?:\/\//
        javascript_tag(source)
      end
    end.join("\n")
  end

  def stylesheet(*sources)
    sources.collect do |source|
      asset = asset_for(source, type: 'css')
      if asset
        if compile_assets?
          asset.to_a.map { |dependency| javascript_tag("#{asset_path(dependency)}?body=1") }
        else
          stylesheet_tag(asset_path(asset))
        end
      else
        source << ".css" unless source =~ /\.css$/
        source = "/#{source}" unless source =~ /^\// || source =~ /http(s)?:\/\//
        stylesheet_tag(source)
      end
    end.join("\n")
  end

  private

  def javascript_tag(path)
    "<script type=\"text/javascript\" src=\"#{path}\"></script>"
  end

  def stylesheet_tag(path)
    "<link href=\"#{path}\" rel=\"stylesheet\" type=\"text/css\"/>"
  end

  def asset_for(source, ext)
    config.assets.find_asset(source, ext)
  end

  def asset_path(asset)
    config.assets.asset_path(asset)
  end
<commit_msg>Copy & paste is evil! This needs to be refactored :P<commit_after>module Harbor::ViewContext::Helpers::Assets
  def javascript(*sources)
    sources.collect do |source|
      asset = asset_for(source, type: 'js')
      if asset
        if compile_assets?
          asset.to_a.map { |dependency| javascript_tag("#{asset_path(dependency)}?body=1") }
        else
          javascript_tag(asset_path(asset))
        end
      else
        source << ".js" unless source =~ /\.js$/
        source = "/#{source}" unless source =~ /^\// || source =~ /http(s)?:\/\//
        javascript_tag(source)
      end
    end.join("\n")
  end

  def stylesheet(*sources)
    sources.collect do |source|
      asset = asset_for(source, type: 'css')
      if asset
        if compile_assets?
          asset.to_a.map { |dependency| stylesheet_tag("#{asset_path(dependency)}?body=1") }
        else
          stylesheet_tag(asset_path(asset))
        end
      else
        source << ".css" unless source =~ /\.css$/
        source = "/#{source}" unless source =~ /^\// || source =~ /http(s)?:\/\//
        stylesheet_tag(source)
      end
    end.join("\n")
  end

  private

  def javascript_tag(path)
    "<script type=\"text/javascript\" src=\"#{path}\"></script>"
  end

  def stylesheet_tag(path)
    "<link href=\"#{path}\" rel=\"stylesheet\" type=\"text/css\"/>"
  end

  def asset_for(source, ext)
    config.assets.find_asset(source, ext)
  end

  def asset_path(asset)
    config.assets.asset_path(asset)
  end

{'fraction_non_alphanumeric': 0.16166047924400945, 'fraction_numerical': 0.0013499831252109348, 'mean_word_length': 2.450523864959255, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, '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': '5438580', 'n_tokens_mistral': 982, 'n_tokens_neox': 937, 'n_words': 201}