<commit_before>require 'gds_api/publishing_api_v2'
require 'gds_api/rummager'

module SpecialistPublisher

  def self.register_service(name, service)
    @services ||= {}

    @services[name] = service
  end

  def self.services(name)
    @services[name] or raise ServiceNotRegisteredException.new(name)
  end

  class ServiceNotRegisteredException < Exception; end

end

SpecialistPublisher.register_service(:publishing_api, GdsApi::PublishingApiV2.new(Plek.new.find('publishing-api')))
SpecialistPublisher.register_service(:rummager, GdsApi::Rummager.new(Plek.new.find('search')))<commit_msg>Use bearer token for publishing API authentication<commit_after>require 'gds_api/publishing_api_v2'
require 'gds_api/rummager'

module SpecialistPublisher

  def self.register_service(name, service)
    @services ||= {}

    @services[name] = service
  end

  def self.services(name)
    @services[name] or raise ServiceNotRegisteredException.new(name)
  end

  class ServiceNotRegisteredException < Exception; end

end

SpecialistPublisher.register_service(:publishing_api, GdsApi::PublishingApiV2.new(
  Plek.new.find('publishing-api'),
  bearer_token: ENV['PUBLISHING_API_BEARER_TOKEN'] || 'example'
))
SpecialistPublisher.register_service(:rummager, GdsApi::Rummager.new(Plek.new.find('search')))
{'fraction_non_alphanumeric': 0.11128284389489954, 'fraction_numerical': 0.0030911901081916537, 'mean_word_length': 6.754491017964072, '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': '6062750', 'n_tokens_mistral': 448, 'n_tokens_neox': 425, 'n_words': 67}