<commit_before># encoding: utf-8
require 'spongecms/configuration'
require 'active_support/concern'

module Spongecms
  module Route
    extend ActiveSupport::Concern

    module Helpers
      # root absolute path
      def root_path
        "/#{Spongecms::Configuration.root}"
      end
    end

    module ClassMethods

      # root method just like get, post ...
      #   root do
      #     haml :index
      #   end
      # => equal as
      #   get '/#{Spongecms::Configuration.root}' do
      #     haml :index
      #   end
      # 
      #   root '/example', :via =>:post do
      #     haml :index
      #   end
      # => equal as
      #   post "/#{Spongecms::Configuration.root}/example" do
      #     haml :index
      #   end
      # 
      # via options
      # =>:get, :post, :put, :head, :delete.Default is :get
      def root(path = nil, opts = {}, &block)
        handler = opts.key?(:via) ? opts.delete(:via): :get
        default_path = opts.key?(:default_path) ? opts.delete(:default_path): Spongecms::Configuration.root
        path = path.nil? ? "/#{default_path}" : "/#{default_path}/#{path}" 
        #route handler, path, opts, &block 
        send handler, path, opts, &block
      end

    end

    # register route helper
    def self.registered(app)
      app.set :path, Spongecms::Configuration.root
      app.helpers Spongecms::Route::Helpers<commit_msg>remove comment and via option downcase<commit_after># encoding: utf-8
require 'spongecms/configuration'
require 'active_support/concern'

module Spongecms
  module Route
    extend ActiveSupport::Concern

    module Helpers
      # root absolute path
      def root_path
        "/#{Spongecms::Configuration.root}"
      end
    end

    module ClassMethods

      # root method just like get, post ...
      #   root do
      #     haml :index
      #   end
      # => equal as
      #   get '/#{Spongecms::Configuration.root}' do
      #     haml :index
      #   end
      # 
      #   root '/example', :via =>:post do
      #     haml :index
      #   end
      # => equal as
      #   post "/#{Spongecms::Configuration.root}/example" do
      #     haml :index
      #   end
      # 
      # via options
      # =>:get, :post, :put, :head, :delete.Default is :get
      def root(path = nil, opts = {}, &block)
        handler = opts.key?(:via) ? opts.delete(:via).downcase : :get
        default_path = opts.key?(:default_path) ? opts.delete(:default_path): Spongecms::Configuration.root
        path = path.nil? ? "/#{default_path}" : "/#{default_path}/#{path}" 
        send handler, path, opts, &block
      end

    end

    # register route helper
    def self.registered(app)
      app.set :path, Spongecms::Configuration.root
      app.helpers Spongecms::Route::Helpers
{'fraction_non_alphanumeric': 0.12630819198845183, 'fraction_numerical': 0.0007217610970768675, 'mean_word_length': 2.1357466063348416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6785951', 'n_tokens_mistral': 883, 'n_tokens_neox': 845, 'n_words': 215}