diff options
| author | mo khan <mo@mokhan.ca> | 2025-03-17 16:32:11 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-03-17 16:32:11 -0600 |
| commit | 084ec28adef9f16a0f38f0457662e9695dfcff8a (patch) | |
| tree | b2f4abd372d26d13331a9c9ee69d75249bcc50a3 /bin | |
| parent | 94d084a51172b7e3851779e9e052435084d4abfe (diff) | |
feat: use csv files to simulate database tables
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/api | 2 | ||||
| -rwxr-xr-x | bin/idp | 10 |
2 files changed, 4 insertions, 8 deletions
@@ -49,7 +49,7 @@ class Entity end def [](attribute) - @attributes.fetch(attribute) + @attributes.fetch(attribute.to_sym) end def to_h @@ -6,6 +6,7 @@ gemfile do source "https://rubygems.org" gem "bcrypt", "~> 3.1" + gem "csv", "~> 3.1" gem "declarative_policy", "~> 1.0" gem "erb", "~> 4.0" gem "globalid", "~> 1.0" @@ -61,13 +62,8 @@ module Authn class << self def all - @all ||= 10.times.map do |n| - new( - id: SecureRandom.uuid, - username: "username#{n}", - email: "username#{n}@example.org", - password_digest: password_digest = ::BCrypt::Password.create("password#{n}") - ) + @all ||= ::CSV.read(File.join(__dir__, "../db/users.csv"), headers: true).map do |row| + new(row.to_h.transform_keys(&:to_sym)) end end |
