Module: Anthropic::Bootstrapper

Defined in:
lib/anthropic/bootstrapper.rb

Overview

Provides methods for bootstrapping the Anthropic gem

Class Method Summary collapse

Class Method Details

.load_betasObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/anthropic/bootstrapper.rb', line 9

def self.load_betas
  directory_path = File.expand_path('../../schemas/betas', __dir__)
  raise "Directory not found: #{directory_path}" unless Dir.exist?(directory_path)

  file_paths = Dir.glob(File.join(directory_path, '*.json'))

  file_paths.map do |file_path|
    JSON.parse(File.read(file_path))
  end
end

.load_versionsObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/anthropic/bootstrapper.rb', line 21

def self.load_versions
  directory_path = File.expand_path('../../schemas/versions', __dir__)
  raise "Directory not found: #{directory_path}" unless Dir.exist?(directory_path)

  versions = {}

  Dir.glob(File.join(directory_path, '*')).each do |subdirectory_path|
    next unless File.directory?(subdirectory_path)

    subdirectory_name = File.basename(subdirectory_path)
    file_paths = Dir.glob(File.join(subdirectory_path, '*.json'))

    versions[subdirectory_name.to_sym] = file_paths.map do |file_path|
      JSON.parse(File.read(file_path))
    end
  end

  versions
end