<commit_before>module MagicLamp
  class FixturesController < MagicLamp::ApplicationController
    ERRORS = [
      "MagicLamp::ArgumentError",
      "MagicLamp::AlreadyRegisteredFixtureError",
      "MagicLamp::AmbiguousFixtureNameError",
      "MagicLamp::UnregisteredFixtureError"
    ]

    rescue_from(*ERRORS) do |exception, message = exception.message|
      error_message_with_bactrace = parse_error(exception, message)
      logger.error(error_message_with_bactrace)
      render text: message, status: 400
    end

    def show
      namespace.load_lamp_files
      render text: namespace.generate_fixture(params[:name])
    end

    def index
      render json: namespace.generate_all_fixtures
    end

    private

    def parse_error(exception, message)
      ([message] + exception.backtrace).join("\n\s\s\s\s")
    end

    def namespace
      MagicLamp
    end
  end
end<commit_msg>style refactor of fixtures controller<commit_after>module MagicLamp
  class FixturesController < MagicLamp::ApplicationController
    ERRORS = [
      MagicLamp::ArgumentError,
      MagicLamp::AlreadyRegisteredFixtureError,
      MagicLamp::AmbiguousFixtureNameError,
      MagicLamp::UnregisteredFixtureError
    ].map(&:name)

    rescue_from(*ERRORS) do |exception, message = exception.message|
      error_message_with_bactrace = parse_error(exception, message)
      logger.error(error_message_with_bactrace)
      render text: message, status: 400
    end

    def show
      MagicLamp.load_lamp_files
      render text: MagicLamp.generate_fixture(params[:name])
    end

    def index
      render json: MagicLamp.generate_all_fixtures
    end

    private

    def parse_error(exception, message)
      ([message] + exception.backtrace).join("\n\s\s\s\s")
    end
  end
end
{'fraction_non_alphanumeric': 0.08263069139966273, 'fraction_numerical': 0.003372681281618887, 'mean_word_length': 3.5292620865139948, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7242645', 'n_tokens_mistral': 562, 'n_tokens_neox': 529, 'n_words': 102}