<commit_before>require 'goliath/api'
require 'goliath/connection'
require 'faye/websocket'
require 'garufa/config'
require 'garufa/websocket'
require 'garufa/api'

module Garufa

  # Default port for api and websocket servers
  DEFAULT_PORT = 8080

  Faye::WebSocket.load_adapter('goliath')

  class GarufaApp < Goliath::API

    # Extend goliath options with our own options.
    def options_parser(opts, options)

      options[:port] = DEFAULT_PORT

      opts.separator ""
      opts.separator "Pusher options:"

      new_options = {
        app_id:  ['--app_id APP_ID',   'Pusher application ID (required)'],
        app_key: ['--app_key APP_KEY', 'Pusher application key (required)'],
        secret:  ['--secret SECRET',   'Pusher application secret (required)']
      }
      new_options.each do |k, v|
        opts.on(v.first, v.last) { |value| Garufa::Config[k] = value }
      end
    end

    def response(env)
      if Faye::WebSocket.websocket?(env)
        WebSocket::Server.call(env)
      else
        API::Server.call(env)
      end
    end
  end
end<commit_msg>Display Garufa version with --version.<commit_after>require 'goliath/api'
require 'goliath/connection'
require 'faye/websocket'
require 'garufa/config'
require 'garufa/websocket'
require 'garufa/api'
require 'garufa/version'

module Garufa

  # Default port for api and websocket servers
  DEFAULT_PORT = 8080

  Faye::WebSocket.load_adapter('goliath')

  class GarufaApp < Goliath::API

    # Extend goliath options with our own options.
    def options_parser(opts, options)

      options[:port] = DEFAULT_PORT

      opts.separator ""
      opts.separator "Pusher options:"

      new_options = {
        app_id:  ['--app_id APP_ID',   'Pusher application ID (required)'],
        app_key: ['--app_key APP_KEY', 'Pusher application key (required)'],
        secret:  ['--secret SECRET',   'Pusher application secret (required)']
      }
      new_options.each do |k, v|
        opts.on(v.first, v.last) { |value| Garufa::Config[k] = value }
      end

      opts.separator ""
      opts.on('-V', '--version', 'Display version and exit') { puts "Garufa version #{Garufa::VERSION}"; exit }
    end

    def response(env)
      if Faye::WebSocket.websocket?(env)
        WebSocket::Server.call(env)
      else
        API::Server.call(env)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.1221796509152831, 'fraction_numerical': 0.0034057045551298426, 'mean_word_length': 2.9695945945945947, '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': '6925802', 'n_tokens_mistral': 805, 'n_tokens_neox': 774, 'n_words': 191}