<commit_before>module ActionDispatch # :nodoc:
  module Routing # :nodoc:
    class Mapper
      # Creates the routes for a Janus capable resource.
      #
      # Example:
      #
      #   MyApp::Application.routes.draw do
      #     janus :users, :session => true, :registration => false
      #   end
      #
      # Options:
      #
      # - +session+      - true to generate session routes
      # - +registration+ - true to generate registration routes
      # - +confirmation+ - true to generate confirmation routes
      # - +password+     - true to generate password reset routes
      #
      # Generated session routes:
      #
      #       new_user_session GET    /users/sign_in(.:format)  {:controller=>"users/sessions", :action=>"new"}
      #           user_session POST   /users/sign_in(.:format)  {:controller=>"users/sessions", :action=>"create"}
      #   destroy_user_session DELETE /users/sign_out(.:format) {:controller=>"users/sessions", :action=>"destroy"}
      #
      # Generated registration routes:
      #
      #    new_user_registration GET    /users/sign_up(.:format)  {:controller=>"users/registrations", :action=>"new"}
      #        user_registration POST   /users(.:format)          {:controller=>"users/registrations", :action=>"create"}
      #   edit_user_registration GET    /users/edit(.:format)     {:controller=>"users/registrations", :action=>"edit"}
      #                          PUT    /users(.:format)          {:controller=>"users/registrations", :action=>"update"}
      #                          DELETE /users(.:format)          {:controller=>"users/registrations", :action=>"destroy"}
      #
      # Generated confirmation routes:
      #
      #       user_confirmation POST   /users/confirmation(.:format)     {:controller=>"users/confirmations", :action=>"create"}
      #   new_user_confirmation GET    /users/confirmation/new(.:format) {:controller=>"users/confirmations", :action=>"new"}
      #                         GET    /users/confirmation(.:format)     {:controller=>"users/confirmations", :action=>"show"}
      #
      # Generated password reset routes:
      #
      #        user_password POST   /users/password(.:format)      {:controller=>"users/passwords", :action=>"create"}
      #    new_user_password GET    /users/password/new(.:format)  {:controller=>"users/passwords", :action=>"new"}
      #   edit_user_password GET    /users/password/edit(.:format) {:controller=>"users/passwords", :action=>"edit"}
      #                      PUT    /users/password(.:format)      {:controller=>"users/passwords", :action=>"update"}
      #
      def janus(*resources)
        ActionController::Base.send(:include, Janus::Helpers)    unless ActionController::Base.include?(Janus::Helpers)
        ActionController::Base.send(:include, Janus::UrlHelpers) unless ActionController::Base.include?(Janus::UrlHelpers)
        options = resources.extract_options!

        resources.each do |plural|
          singular = plural.to_s.singularize

          if options[:session]
            scope :path => plural, :controller => "#{plural}/sessions" do
              get    "/sign_in(.:format)",  :action => "new",     :as => "new_#{singular}_session"
              post   "/sign_in(.:format)",  :action => "create",  :as => "#{singular}_session"
              delete "/sign_out(.:format)", :action => "destroy", :as => "destroy_#{singular}_session"
            end
          end

          namespace plural, :as => singular do
            if options[:registration]
              resource :registration, :except => [:index, :show], :path => "",
                :path_names => { :new => 'sign_up' }
            end

            resource :confirmation, :only => [:show, :new, :create] if options[:confirmation]
            resource :password, :except => [:index, :show, :destroy] if options[:password]
          end

          ActionController::Base.janus(singular)<commit_msg>Support custom routes<commit_after>module ActionDispatch # :nodoc:
  module Routing # :nodoc:
    class Mapper
      # Creates the routes for a Janus capable resource.
      #
      # Example:
      #
      #   MyApp::Application.routes.draw do
      #     janus :users, :session => true, :registration => false
      #   end
      #
      # Options:
      #
      # - +session+      - true to generate session routes
      # - +registration+ - true to generate registration routes
      # - +confirmation+ - true to generate confirmation routes
      # - +password+     - true to generate password reset routes
      #
      # Generated session routes:
      #
      #       new_user_session GET    /users/sign_in(.:format)  {:controller=>"users/sessions", :action=>"new"}
      #           user_session POST   /users/sign_in(.:format)  {:controller=>"users/sessions", :action=>"create"}
      #   destroy_user_session DELETE /users/sign_out(.:format) {:controller=>"users/sessions", :action=>"destroy"}
      #
      # Generated registration routes:
      #
      #    new_user_registration GET    /users/sign_up(.:format)  {:controller=>"users/registrations", :action=>"new"}
      #        user_registration POST   /users(.:format)          {:controller=>"users/registrations", :action=>"create"}
      #   edit_user_registration GET    /users/edit(.:format)     {:controller=>"users/registrations", :action=>"edit"}
      #                          PUT    /users(.:format)          {:controller=>"users/registrations", :action=>"update"}
      #                          DELETE /users(.:format)          {:controller=>"users/registrations", :action=>"destroy"}
      #
      # Generated confirmation routes:
      #
      #       user_confirmation POST   /users/confirmation(.:format)     {:controller=>"users/confirmations", :action=>"create"}
      #   new_user_confirmation GET    /users/confirmation/new(.:format) {:controller=>"users/confirmations", :action=>"new"}
      #                         GET    /users/confirmation(.:format)     {:controller=>"users/confirmations", :action=>"show"}
      #
      # Generated password reset routes:
      #
      #        user_password POST   /users/password(.:format)      {:controller=>"users/passwords", :action=>"create"}
      #    new_user_password GET    /users/password/new(.:format)  {:controller=>"users/passwords", :action=>"new"}
      #   edit_user_password GET    /users/password/edit(.:format) {:controller=>"users/passwords", :action=>"edit"}
      #                      PUT    /users/password(.:format)      {:controller=>"users/passwords", :action=>"update"}
      #
      def janus(*resources)
        ActionController::Base.send(:include, Janus::Helpers)    unless ActionController::Base.include?(Janus::Helpers)
        ActionController::Base.send(:include, Janus::UrlHelpers) unless ActionController::Base.include?(Janus::UrlHelpers)
        options = resources.extract_options!

        resources.each do |plural|
          singular = plural.to_s.singularize

          if options[:session]
            scope :path => plural, :controller => "#{plural}/sessions" do
              get    "/sign_in(.:format)",  :action => "new",     :as => "new_#{singular}_session"
              post   "/sign_in(.:format)",  :action => "create",  :as => "#{singular}_session"
              delete "/sign_out(.:format)", :action => "destroy", :as => "destroy_#{singular}_session"
            end
          end

          namespace plural, :as => singular do
            if options[:registration]
              resource :registration, :except => [:index, :show], :path => "",
                :path_names => { :new => 'sign_up' }
            end

            resource :confirmation, :only => [:show, :new, :create] if options[:confirmation]
            resource :password, :except => [:index, :show, :destroy] if options[:password]
            yield if block_given?
          end

          ActionController::Base.janus(singular)
{'fraction_non_alphanumeric': 0.14741488020176544, 'fraction_numerical': 0.0, 'mean_word_length': 2.433333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2086992', 'n_tokens_mistral': 2246, 'n_tokens_neox': 2193, 'n_words': 436}