<commit_before>require "coffee-rails-source-maps/version"

# Based on https://gist.github.com/naan/5096056
# config/initializers/source_maps.rb

if Rails.env.development?
  module CoffeeScript

    class << self

      def compile(script, options = {})
        script = script.read if script.respond_to?(:read)

        if options.key?(:no_wrap) && !options.key?(:bare)
          options[:bare] = options[:no_wrap]
        else
          options[:bare] = false
        end

        pathname = options[:pathname]
        if pathname.nil?
          return Source.context.call("CoffeeScript.compile", script, options)
        else
          clean_name = pathname.basename.to_s.split(".").first
          # adding source maps option. (source maps option requires filename option.)
          options[:sourceMap] = true
          options[:filename]  = "#{clean_name}.coffee"

          ret = Source.context.call("CoffeeScript.compile", script, options)

          rel_path = if pathname.to_s.start_with?(Bundler.bundle_path.to_s)
            Pathname('bundler').join(pathname.relative_path_from(Bundler.bundle_path)).dirname
          else
            pathname.relative_path_from(Rails.root).dirname
          end<commit_msg>Make sure CoffeeScript is loaded before overwrite<commit_after>require "coffee-rails-source-maps/version"

# Based on https://gist.github.com/naan/5096056
# config/initializers/source_maps.rb

if Rails.env.development?
  require 'coffee-script' #make sure CoffeeScript is loaded before we overwrite it.
  module CoffeeScript

    class << self

      def compile(script, options = {})
        script = script.read if script.respond_to?(:read)

        if options.key?(:no_wrap) && !options.key?(:bare)
          options[:bare] = options[:no_wrap]
        else
          options[:bare] = false
        end

        pathname = options[:pathname]
        if pathname.nil?
          return Source.context.call("CoffeeScript.compile", script, options)
        else
          clean_name = pathname.basename.to_s.split(".").first
          # adding source maps option. (source maps option requires filename option.)
          options[:sourceMap] = true
          options[:filename]  = "#{clean_name}.coffee"

          ret = Source.context.call("CoffeeScript.compile", script, options)

          rel_path = if pathname.to_s.start_with?(Bundler.bundle_path.to_s)
            Pathname('bundler').join(pathname.relative_path_from(Bundler.bundle_path)).dirname
          else
            pathname.relative_path_from(Rails.root).dirname
          end
{'fraction_non_alphanumeric': 0.11297888975762314, 'fraction_numerical': 0.00547302580140735, 'mean_word_length': 2.697976878612717, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '339791', 'n_tokens_mistral': 774, 'n_tokens_neox': 732, 'n_words': 144}