diff options
| author | mo khan <mo@mokhan.ca> | 2025-03-17 16:48:25 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-03-17 16:48:25 -0600 |
| commit | 338ff46e4ab799a4b159f8c2a79b73751f920727 (patch) | |
| tree | 48924f09c5a65c3e2238882c87e6d195e4ff0adb /bin | |
| parent | 084ec28adef9f16a0f38f0457662e9695dfcff8a (diff) | |
feat: fix the csv data and serve it from the REST API
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/api | 5 | ||||
| -rwxr-xr-x | bin/idp | 4 |
2 files changed, 6 insertions, 3 deletions
@@ -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) @@ -5,8 +5,8 @@ require "bundler/inline" gemfile do source "https://rubygems.org" - gem "bcrypt", "~> 3.1" - gem "csv", "~> 3.1" + gem "bcrypt", "~> 3.0" + gem "csv", "~> 3.0" gem "declarative_policy", "~> 1.0" gem "erb", "~> 4.0" gem "globalid", "~> 1.0" |
