<commit_before>module Devise
  module I18n
    module ViewPathTemplates #:nodoc:
      extend ActiveSupport::Concern

      included do
        argument :scope, required: false, default: nil, desc: "The scope to copy views to"

        class_option :form_builder, aliases: "-b"
        class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (confirmations, passwords, registrations, sessions, unlocks, mailer)"

        public_task :copy_views
      end

      def copy_views
        if options[:views]
          options[:views].each { |directory| view_directory(directory.to_sym) }
        else
          view_directory :confirmations
          view_directory :passwords
          view_directory :registrations
          view_directory :sessions
          view_directory :unlocks
        end
      end

      protected

      def view_directory(name, target_path = nil)
        directory name.to_s, target_path || "#{default_target_path}/#{name}" do |content|
          if scope
            content.gsub "devise/shared/links", "#{plural_scope}/shared/links"
          else
            content
          end
        end
      end

      def default_target_path
        @default_target_path ||= "app/views/#{plural_scope || :devise}"
      end

      def plural_scope<commit_msg>Fix relative path for error_messages when creating scoped view<commit_after>module Devise
  module I18n
    module ViewPathTemplates #:nodoc:
      extend ActiveSupport::Concern

      included do
        argument :scope, required: false, default: nil, desc: "The scope to copy views to"

        class_option :form_builder, aliases: "-b"
        class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (confirmations, passwords, registrations, sessions, unlocks, mailer)"

        public_task :copy_views
      end

      def copy_views
        if options[:views]
          options[:views].each { |directory| view_directory(directory.to_sym) }
        else
          view_directory :confirmations
          view_directory :passwords
          view_directory :registrations
          view_directory :sessions
          view_directory :unlocks
        end
      end

      protected

      def view_directory(name, target_path = nil)
        directory name.to_s, target_path || "#{default_target_path}/#{name}" do |content|
          if scope
            content.gsub "devise/shared", "#{plural_scope}/shared"
          else
            content
          end
        end
      end

      def default_target_path
        @default_target_path ||= "app/views/#{plural_scope || :devise}"
      end

      def plural_scope
{'fraction_non_alphanumeric': 0.08038704875325642, 'fraction_numerical': 0.00148864905098623, 'mean_word_length': 2.406844106463878, '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': '3424910', 'n_tokens_mistral': 742, 'n_tokens_neox': 719, 'n_words': 205}