<commit_before>module Harbourmaster
  class InstallGenerator < Rails::Generators::Base
    desc 'Creates a base api controller from which all other controllers will inherit. Also generates the serializer initializer.'

    source_root File.expand_path('../templates', __FILE__)

    def copy_base_api_controller
      copy_file 'base_api_controller.rb', 'app/controllers/base_api_controller.rb'
    end

    def initializer_responder
      template 'json_responder.rb', 'lib/responders/json_responder.rb'
    end

    def initialize_active_model_serializers
      copy_file 'active_model_serializer.rb', 'config/initializers/active_model_serializer.rb'
    end

    def initialize_api_docs
      copy_file 'rspec_api_documentation.rb', 'config/initializers/rspec_api_documentation.rb'
    end

    def initialize_apitome
      generate "apitome:install"
    end
  end
end
<commit_msg>Ensure Factory Girl Syntax is included in rails_helper<commit_after>module Harbourmaster
  class InstallGenerator < Rails::Generators::Base
    desc 'Creates a base api controller from which all other controllers will inherit. Also generates the serializer initializer.'

    source_root File.expand_path('../templates', __FILE__)

    def copy_base_api_controller
      copy_file 'base_api_controller.rb', 'app/controllers/base_api_controller.rb'
    end

    def initializer_responder
      template 'json_responder.rb', 'lib/responders/json_responder.rb'
    end

    def initialize_active_model_serializers
      copy_file 'active_model_serializer.rb', 'config/initializers/active_model_serializer.rb'
    end

    def initialize_api_docs
      copy_file 'rspec_api_documentation.rb', 'config/initializers/rspec_api_documentation.rb'
    end

    def initialize_apitome
      generate "apitome:install"
    end

    def use_factory_girl_syntax
      # Remove these two lines if they're already there
      gsub_file 'spec/rails_helper.rb', /^\s\# Use FactoryGirl shortcuts/, ""
      gsub_file 'spec/rails_helper.rb', /\s*config.include FactoryGirl::Syntax::Methods\s*/, ""
      # Then add them so we know that they are there
      inject_into_file 'spec/rails_helper.rb', after: /RSpec.configure do\s*.*\n/ do
        <<-RUBY
  # Use FactoryGirl shortcuts
  config.include FactoryGirl::Syntax::Methods

        RUBY
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.0766923736075407, 'fraction_numerical': 0.0, 'mean_word_length': 3.8343685300207038, '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': '6886154', 'n_tokens_mistral': 719, 'n_tokens_neox': 681, 'n_words': 166}