<commit_before>require 'native'
module Ruta

  class History
    class << self

      # push new url to history
      #
      # @param [String] url to be added to history
      # @param [Hash] data to be added to history
      # @param [String] title to be added to history, defaults to ""
      def push(url,data,title="")
        `history.pushState(#{data.to_n}, #{title}, #{url})`
      end

      # replace current url in history
      #
      # @param [String] url to replace current item in history
      # @param [Hash] data to replace current item in history
      # @param [String] title to replace current item in history, defaults to ""
      def replace(url,data,title=nil)
        `history.replaceState(#{data.to_n}, #{title}, #{url})`
      end

      # move browser forward
      #
      # @param [Integer] by the amount to go forwards by, defaults to 1
      def forward(by=1)
        `history.go(#{by.to_i})`
      end

      # move browser backwards
      #
      # @param [Integer] by the amount to go backwards by, defaults to 1
      def back(by=1)
        `history.go(#{-by.to_i})`
      end<commit_msg> adds context prefix check before pushing to history<commit_after>require 'native'
module Ruta

  class History
    class << self

      # push new url to history
      #
      # @param [String] url to be added to history
      # @param [Hash] data to be added to history
      # @param [String] title to be added to history, defaults to ""
      def push(context,url,data,title="")
        if Ruta.config.context_prefix
          u = "/#{context}#{url}"
        else
          u = url
        end
        `history.pushState(#{data.to_n}, #{title}, #{u})`
      end

      # replace current url in history
      #
      # @param [String] url to replace current item in history
      # @param [Hash] data to replace current item in history
      # @param [String] title to replace current item in history, defaults to ""
      def replace(url,data,title=nil)
        `history.replaceState(#{data.to_n}, #{title}, #{url})`
      end

      # move browser forward
      #
      # @param [Integer] by the amount to go forwards by, defaults to 1
      def forward(by=1)
        `history.go(#{by.to_i})`
      end

      # move browser backwards
      #
      # @param [Integer] by the amount to go backwards by, defaults to 1
      def back(by=1)
        `history.go(#{-by.to_i})`
      end
{'fraction_non_alphanumeric': 0.11037344398340249, 'fraction_numerical': 0.0033195020746887966, 'mean_word_length': 2.2581081081081082, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4968459', 'n_tokens_mistral': 715, 'n_tokens_neox': 698, 'n_words': 261}