From 338ff46e4ab799a4b159f8c2a79b73751f920727 Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 17 Mar 2025 16:48:25 -0600 Subject: feat: fix the csv data and serve it from the REST API --- bin/api | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bin/api') diff --git a/bin/api b/bin/api index e63c713..83c2726 100755 --- a/bin/api +++ b/bin/api @@ -5,6 +5,7 @@ require 'bundler/inline' gemfile do source 'https://rubygems.org' + gem "csv", "~> 3.0" gem "declarative_policy", "~> 1.0" gem "erb", "~> 4.0" gem "globalid", "~> 1.0" @@ -30,7 +31,9 @@ $host = ENV.fetch("HOST", "localhost:#{$port}") class Entity class << self def all - @items ||= [] + @items ||= ::CSV.read(File.join(__dir__, "../db/#{self.name.downcase}s.csv"), headers: true).map do |row| + new(row.to_h.transform_keys(&:to_sym)) + end end def create!(attributes) -- cgit v1.2.3