<commit_before>require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'

module UserDefinedAttributes
  class InstallGenerator < ::Rails::Generators::Base
    include ::Rails::Generators::Migration

    source_root File.expand_path('../templates', __FILE__)
    
    class_option :skip_migrations, :optional => true, :type => :boolean,
                 :desc => 'Skip copying of the migration files'
    class_option :skip_initializer, :optional => true, :type => :boolean,
                 :desc => 'Skip copying of the initializer'
    class_option :skip_controller, :optional => true, :type => :boolean,
                 :desc => 'Skip generating the controller'

    def create_migration_file
      return if options[:skip_migrations]
      
      migration_template 'create_user_defined_attributes_fields.rb', 'db/migrate/create_user_defined_attributes_fields.rb'
      migration_template 'create_user_defined_attributes_field_types.rb', 'db/migrate/create_user_defined_attributes_field_types.rb'
    end
    
    def create_initializer
      return if options[:skip_initializer]
      
      template 'initializer.rb', 'config/initializers/user_defined_attributes.rb'
    end
    
    def create_controller
      return if options[:skip_controller]
      
      generate 'scaffold_controller', 'UserDefinedAttributes::FieldType'
      copy_file 'field_types_controller.rb', 'app/controllers/user_defined_attributes/field_types_controller.rb', force: true
      copy_file 'field_types_form.erb', 'app/views/user_defined_attributes/field_types/_form.html.erb', force: true
      inject_into_file 'config/routes.rb', """
  namespace :user_defined_attributes do
    resources :field_types, except: :show
  end
""", :after => 'routes.draw do'
    end
    
    private

    def self.next_migration_number(dirname)
      ::ActiveRecord::Generators::Base.next_migration_number(dirname)
    end
  end
end<commit_msg>Moving EOF to a variable<commit_after>require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'

module UserDefinedAttributes
  class InstallGenerator < ::Rails::Generators::Base
    include ::Rails::Generators::Migration

    source_root File.expand_path('../templates', __FILE__)
    
    class_option :skip_migrations, :optional => true, :type => :boolean,
                 :desc => 'Skip copying of the migration files'
    class_option :skip_initializer, :optional => true, :type => :boolean,
                 :desc => 'Skip copying of the initializer'
    class_option :skip_controller, :optional => true, :type => :boolean,
                 :desc => 'Skip generating the controller'

    def create_migration_file
      return if options[:skip_migrations]
      
      migration_template 'create_user_defined_attributes_fields.rb', 'db/migrate/create_user_defined_attributes_fields.rb'
      migration_template 'create_user_defined_attributes_field_types.rb', 'db/migrate/create_user_defined_attributes_field_types.rb'
    end
    
    def create_initializer
      return if options[:skip_initializer]
      
      template 'initializer.rb', 'config/initializers/user_defined_attributes.rb'
    end
    
    def create_controller
      return if options[:skip_controller]
      
      route = <<EOF
  namespace :user_defined_attributes do
    resources :field_types, except: :show
  end
EOF
      
      generate 'scaffold_controller', 'UserDefinedAttributes::FieldType'
      copy_file 'field_types_controller.rb', 'app/controllers/user_defined_attributes/field_types_controller.rb', force: true
      copy_file 'field_types_form.erb', 'app/views/user_defined_attributes/field_types/_form.html.erb', force: true
      inject_into_file 'config/routes.rb', route, :after => 'routes.draw do'
    end
    
    private

    def self.next_migration_number(dirname)
      ::ActiveRecord::Generators::Base.next_migration_number(dirname)
    end
  end
end
{'fraction_non_alphanumeric': 0.09414437152953054, 'fraction_numerical': 0.0, 'mean_word_length': 3.922981366459627, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '2558440', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1147, 'n_words': 231}