<commit_before>module Jasmine
  class AssetExpander
    def expand(src_dir, src_path)
      pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')

      asset_bundle.assets(pathname).flat_map { |asset|
        "/#{asset.gsub(/^\//, '')}?body=true"
      }
    end

    private

    UnsupportedRailsVersion = Class.new(StandardError)

    def asset_bundle
      return Rails3AssetBundle.new if Jasmine::Dependencies.rails3?
      return Rails4Or5AssetBundle.new if Jasmine::Dependencies.rails4? || Jasmine::Dependencies.rails5?
      raise UnsupportedRailsVersion, "Jasmine only supports the asset pipeline for Rails 3 - 5"
    end

    class Rails3AssetBundle
      def assets(pathname)
        context.asset_paths.asset_for(pathname, nil).to_a.map do |path|
          context.asset_path(path)
        end
      end

      private

      def context
        @context ||= get_asset_context
      end

      def get_asset_context
        context = ::Rails.application.assets.context_class
        context.extend(::Sprockets::Helpers::IsolatedHelper)
        context.extend(::Sprockets::Helpers::RailsHelper)
      end
    end

    class Rails4Or5AssetBundle
      def assets(pathname)
        context.get_original_assets(pathname)
      end

      private

      def context
        @context ||= ActionView::Base.new.extend(GetOriginalAssetsHelper)
      end

      module GetOriginalAssetsHelper
        def get_original_assets(pathname)
          Array(assets_environment.find_asset(pathname)).map do |processed_asset|
            case processed_asset.content_type
            when "text/css"
              path_to_stylesheet(processed_asset.logical_path, debug: true)
            when "application/javascript"
              path_to_javascript(processed_asset.logical_path, debug: true).gsub(/^\//,"")
            end
          end
        end
      end
    end
  end
end<commit_msg>remove unnecessary parsing of js asset paths<commit_after>module Jasmine
  class AssetExpander
    def expand(src_dir, src_path)
      pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')

      asset_bundle.assets(pathname).flat_map { |asset|
        "/#{asset.gsub(/^\//, '')}?body=true"
      }
    end

    private

    UnsupportedRailsVersion = Class.new(StandardError)

    def asset_bundle
      return Rails3AssetBundle.new if Jasmine::Dependencies.rails3?
      return Rails4Or5AssetBundle.new if Jasmine::Dependencies.rails4? || Jasmine::Dependencies.rails5?
      raise UnsupportedRailsVersion, "Jasmine only supports the asset pipeline for Rails 3 - 5"
    end

    class Rails3AssetBundle
      def assets(pathname)
        context.asset_paths.asset_for(pathname, nil).to_a.map do |path|
          context.asset_path(path)
        end
      end

      private

      def context
        @context ||= get_asset_context
      end

      def get_asset_context
        context = ::Rails.application.assets.context_class
        context.extend(::Sprockets::Helpers::IsolatedHelper)
        context.extend(::Sprockets::Helpers::RailsHelper)
      end
    end

    class Rails4Or5AssetBundle
      def assets(pathname)
        context.get_original_assets(pathname)
      end

      private

      def context
        @context ||= ActionView::Base.new.extend(GetOriginalAssetsHelper)
      end

      module GetOriginalAssetsHelper
        def get_original_assets(pathname)
          Array(assets_environment.find_asset(pathname)).map do |processed_asset|
            case processed_asset.content_type
            when "text/css"
              path_to_stylesheet(processed_asset.logical_path, debug: true)
            when "application/javascript"
              path_to_javascript(processed_asset.logical_path, debug: true)
            end
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09078947368421053, 'fraction_numerical': 0.005789473684210527, 'mean_word_length': 2.5391061452513966, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7531484', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1093, 'n_words': 215}