gemini-suggestions, tests-fail

This commit is contained in:
Ole-Morten Duesund 2025-06-06 21:12:46 +02:00
commit 314bffc4f8
8 changed files with 429 additions and 15 deletions

26
app.rb
View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'sinatra'
require 'json'
require 'yaml'
@ -37,16 +39,14 @@ def determine_language(params, headers)
# Parse Accept-Language header
if headers['HTTP_ACCEPT_LANGUAGE']
accepted_langs = headers['HTTP_ACCEPT_LANGUAGE']
.split(',')
.map { |lang| lang.split(';').first.downcase.strip }
.split(',')
.map { |lang| lang.split(';').first.downcase.strip }
# Check for exact matches first
accepted_langs.each do |lang|
return lang if RESPONSES[lang]
end
# Check for language family matches (e.g., 'nb' or 'nn' -> 'no')
accepted_langs.each do |lang|
# Check for language family matches (e.g., 'nb' or 'nn' -> 'no')
case lang
when /^zh/ # Chinese variants
return 'zh'
@ -113,7 +113,7 @@ get '/' do
no_response = get_no_response(lang)
case request.accept.first&.to_s
when /application\/json/
when %r{application/json}
content_type :json
{
answer: no_response,
@ -152,8 +152,8 @@ get '/api/no' do
language: lang,
language_name: get_language_name(lang),
timestamp: Time.now.iso8601,
service: "No as a Service",
version: "2.0.0"
service: 'No as a Service',
version: '2.0.0'
}.to_json
end
@ -165,7 +165,7 @@ get '/api/no/:lang' do
content_type :json
status 404
return {
error: "Language not supported",
error: 'Language not supported',
requested: lang,
available: get_available_languages.map { |l| l[:code] },
timestamp: Time.now.iso8601
@ -178,8 +178,8 @@ get '/api/no/:lang' do
language: lang,
language_name: get_language_name(lang),
timestamp: Time.now.iso8601,
service: "No as a Service",
version: "2.0.0"
service: 'No as a Service',
version: '2.0.0'
}.to_json
end
@ -187,7 +187,7 @@ end
get '/health' do
content_type :json
{
status: "healthy",
status: 'healthy',
languages_loaded: RESPONSES.keys.size,
timestamp: Time.now.iso8601
}.to_json
@ -199,7 +199,7 @@ get '/*' do
no_response = get_no_response(lang)
case request.accept.first&.to_s
when /application\/json/
when %r{application/json}
content_type :json
{
answer: no_response,