Alpha Chen 2 years ago
parent 686d41feae
commit a1141f8f97
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -1 +1 @@
3.1
3.2

@ -2,14 +2,9 @@
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "sequel"
gem "sqlite3"
group :development do
gem "minitest"
gem "rake"
gem "steep"
gem "typeprof"
end
gem "minitest"
gem "phlex"
gem "rackup"
gem "rake"
gem "roda"
gem "tilt"

@ -1,71 +1,37 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
concurrent-ruby (1.1.10)
csv (3.2.5)
ffi (1.15.5)
fileutils (1.6.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
language_server-protocol (3.17.0.1)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.5.1)
minitest (5.16.3)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
rainbow (3.1.1)
cgi (0.3.6)
concurrent-ruby (1.2.2)
erb (4.0.2)
cgi (>= 0.3.3)
minitest (5.18.0)
phlex (1.8.1)
concurrent-ruby (~> 1.2)
erb (>= 4)
zeitwerk (~> 2.6)
rack (3.0.8)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rbs (2.7.0)
securerandom (0.2.0)
sequel (5.62.0)
sqlite3 (1.5.3-arm64-darwin)
steep (1.2.1)
activesupport (>= 5.1)
csv (>= 3.0.9)
fileutils (>= 1.1.0)
json (>= 2.1.0)
language_server-protocol (>= 3.15, < 4.0)
listen (~> 3.0)
logger (>= 1.3.0)
parallel (>= 1.0.0)
parser (>= 3.1)
rainbow (>= 2.2.2, < 4.0)
rbs (>= 2.7.0)
securerandom (>= 0.1)
strscan (>= 1.0.0)
terminal-table (>= 2, < 4)
strscan (3.0.4)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
typeprof (0.21.3)
rbs (>= 1.8.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
roda (3.69.0)
rack
tilt (2.2.0)
webrick (1.8.1)
zeitwerk (2.6.8)
PLATFORMS
arm64-darwin-21
arm64-darwin-22
DEPENDENCIES
minitest
phlex
rackup
rake
sequel
sqlite3
steep
typeprof
roda
tilt
BUNDLED WITH
2.3.18

@ -1,27 +1,5 @@
require "minitest/test_task"
require "sequel"
task default: :test
task :default => :test
namespace :db do
desc "Run migrations"
task :migrate, [:version] do |t, args|
require "sequel/core"
Sequel.extension :migration
version = args[:version].to_i if args[:version]
Sequel.connect(ENV.fetch("DATABASE_URL")) do |db|
Sequel::Migrator.run(db, "db/migrations", target: version)
end
end
end
Minitest::TestTask.create(:test) do |t|
t.test_globs = ["test/**/test_*.rb"]
end
namespace :test do
desc "Run tests on Ruby file changes"
task :watch do
sh "fd .*.rb | entr -d rake test"
end
end
Minitest::TestTask.create

@ -1,27 +0,0 @@
# D = Steep::Diagnostic
#
# target :lib do
# signature "sig"
#
# check "lib" # Directory name
# check "Gemfile" # File name
# check "app/models/**/*.rb" # Glob
# # ignore "lib/templates/*.rb"
#
# # library "pathname", "set" # Standard libraries
# # library "strong_json" # Gems
#
# # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
# # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
# # configure_code_diagnostics do |hash| # You can setup everything yourself
# # hash[D::Ruby::NoMethod] = :information
# # end
# end
# target :test do
# signature "sig", "sig-private"
#
# check "test"
#
# # library "pathname", "set" # Standard libraries
# end

@ -0,0 +1,3 @@
require "./lib/app"
App.freeze unless ENV["RACK_ENV"] == "development"
run App.app

@ -1,61 +0,0 @@
Sequel.migration do
change do
create_table(:pools) do
primary_key :id
String :name, null: false
DateTime :created_at, null: false
DateTime :updated_at, null: false
end
create_table(:items) do
primary_key :id
foreign_key :pool_id, :pools
String :title, null: false
String :body, null: false
DateTime :created_at, null: false
DateTime :updated_at, null: false
end
create_table(:axes) do
primary_key :id
foreign_key :pool_id, :pools
String :name, null: false
String :better_legend, null: false
String :worse_legend, null: false
DateTime :created_at, null: false
DateTime :updated_at, null: false
end
create_table(:ratings) do
primary_key :id
foreign_key :axis_id, :axes
foreign_key :winner_id, :items
foreign_key :loser_id, :items
DateTime :created_at, null: false
DateTime :updated_at, null: false
end
create_table(:rankings) do
primary_key :id
foreign_key :axis_id, :axes
foreign_key :item_id, :items
Float :mu, null: false
Float :sigma, null: false
DateTime :created_at, null: false
DateTime :updated_at, null: false
end
end
end

@ -0,0 +1,47 @@
require "roda"
class App < Roda
plugin :render, engine: :phlex
route do |r|
r.root do
render "hello"
end
end
end
require "tilt/template"
require "phlex"
module Tilt
class PhlexTemplate < Template
def prepare
end
# def evaluate(scope, locals)
# klass = Class.new(Phlex::HTML)
# klass.class_eval(data, __FILE__, __LINE__)
# klass.new.()
# end
def precompiled_template(*)
data
end
def precompiled_preamble(*)
<<~RUBY
klass = Class.new(Phlex::HTML) do
RUBY
end
def precompiled_postamble(*)
<<~RUBY
end
klass.new.call
RUBY
end
end
end
Tilt.register(Tilt::PhlexTemplate, "phlex")

@ -1,19 +0,0 @@
require "sequel"
Sequel::Model.plugin :timestamps, update_on_create: true
module RankKing
DB = Sequel.connect(ENV.fetch("DATABASE_URL"))
class Pool < Sequel::Model
end
class Item < Sequel::Model
end
class Axis < Sequel::Model(:axes)
end
def self.rate(axis:, winner:, loser:)
end
end

File diff suppressed because it is too large Load Diff

@ -1,20 +0,0 @@
require "minitest/autorun"
require "rank_king"
module RankKing
class TestRankKing < Minitest::Test
def test_rank_king
pool = Pool.create(name: "Ping Pong")
alice = Item.create(title: "Alice", body: "")
bob = Item.create(title: "Bob", body: "")
eve = Item.create(title: "Eve", body: "")
mallory = Item.create(title: "Mallory", body: "")
axis = Axis.create(name: "Rank", better_legend: "Better", worse_legend: "Worse")
RankKing.rate(axis:, winner: alice, loser: bob)
end
end
end

@ -0,0 +1,3 @@
def template
h1 { "👋 Hello World!" }
end
Loading…
Cancel
Save