<commit_before>
# Wraps a JSON Response
#
# @attr [String] status  Status of operaiton ("success" or "fail")
# @attr [String] message  Response message
# @attr [Hash] data  Response data as key/value pairs
# @attr [FixNum] code  Response code
class JsonResponse

  include Jsonify

  attr_accessor :status, :message, :data, :code

  # Create a new JsonResponse
  #
  # @param [String] status  Status of operaiton ("success" or "fail")
  # @param [String] message  Response message
  # @param [Hash] data  Response data as key/value pairs
  # @param [FixNum] code  Response code
  def initialize(status = nil, message = nil, data = nil, code = nil)
    @status = status
    @message = message
    @data = data
    @code = code
  end

  # Was operation successful?
  #
  # @return [Boolean] True if @status == "success"
  def success?
    @status && @status == "success"
  end

  # Was operation unsuccessful?
  #
  # @return [Boolean] True if @status != "success"
  def fail?
    @status && @status == "fail"
  end

  # Create a JsonResponse representing an invalid request
  #
  # @param [String] msg Optional message (default: "invalid request")
  def self.invalid_request(msg = nil)
    new("fail", (msg || "invalid request"), nil, 400)<commit_msg>use constants for success/fail<commit_after>
# Wraps a JSON Response
#
# @attr [String] status  Status of operaiton ("success" or "fail")
# @attr [String] message  Response message
# @attr [Hash] data  Response data as key/value pairs
# @attr [FixNum] code  Response code
class JsonResponse

  include Jsonify

  attr_accessor :status, :message, :data, :code

  SUCCESS = "success"
  FAIL    = "fail"

  # Create a new JsonResponse
  #
  # @param [String] status  Status of operaiton ("success" or "fail")
  # @param [String] message  Response message
  # @param [Hash] data  Response data as key/value pairs
  # @param [FixNum] code  Response code
  def initialize(status = nil, message = nil, data = nil, code = nil)
    @status = status
    @message = message
    @data = data
    @code = code
  end

  # Was operation successful?
  #
  # @return [Boolean] True if @status == "success"
  def success?
    @status && @status == SUCCESS
  end

  # Was operation unsuccessful?
  #
  # @return [Boolean] True if @status != "success"
  def fail?
    @status && @status == FAIL
  end

  # Create a JsonResponse representing an invalid request
  #
  # @param [String] msg Optional message (default: "invalid request")
  def self.invalid_request(msg = nil)
    new("fail", (msg || "invalid request"), nil, 400)
{'fraction_non_alphanumeric': 0.1162426614481409, 'fraction_numerical': 0.0023483365949119373, 'mean_word_length': 3.5238938053097346, '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': '5548906', 'n_tokens_mistral': 800, 'n_tokens_neox': 774, 'n_words': 294}