Skip to content

Commit

Permalink
Modernize code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 24, 2024
1 parent dfa4bc9 commit a5c4d28
Show file tree
Hide file tree
Showing 29 changed files with 321 additions and 169 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/documentation-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Documentation Coverage

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm
COVERAGE: PartialSummary

jobs:
validate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true

- name: Validate coverage
timeout-minutes: 5
run: bundle exec bake decode:index:coverage lib
24 changes: 24 additions & 0 deletions .github/workflows/rubocop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: RuboCop

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true

- name: Run RuboCop
timeout-minutes: 10
run: bundle exec rubocop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Coverage
name: Test Coverage

on: [push, pull_request]

Expand Down Expand Up @@ -33,9 +33,11 @@ jobs:
- name: Run tests
timeout-minutes: 5
run: bundle exec bake test

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
include-hidden-files: true
if-no-files-found: error
name: coverage-${{matrix.os}}-${{matrix.ruby}}
path: .covered.db

Expand All @@ -50,7 +52,7 @@ jobs:
ruby-version: "3.3"
bundler-cache: true

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4

- name: Validate coverage
timeout-minutes: 5
Expand Down
53 changes: 53 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
AllCops:
DisabledByDefault: true

Layout/IndentationStyle:
Enabled: true
EnforcedStyle: tabs

Layout/InitialIndentation:
Enabled: true

Layout/IndentationWidth:
Enabled: true
Width: 1

Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: normal

Layout/BlockAlignment:
Enabled: true

Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/BeginEndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/ElseAlignment:
Enabled: true

Layout/DefEndAlignment:
Enabled: true

Layout/CaseIndentation:
Enabled: true

Layout/CommentIndentation:
Enabled: true

Layout/EmptyLinesAroundClassBody:
Enabled: true

Layout/EmptyLinesAroundModuleBody:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true

Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
5 changes: 3 additions & 2 deletions bin/lively
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'async/service'
require_relative '../lib/lively/environment/application'
require "async/service"
require_relative "../lib/lively/environment/application"

ARGV.each do |path|
require(path)
Expand Down
16 changes: 8 additions & 8 deletions examples/chatbot/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# Released under the MIT License.
# Copyright, 2024, by Samuel Williams.

require 'async/ollama'
require 'markly'
require 'xrb/reference'
require "async/ollama"
require "markly"
require "xrb/reference"

require_relative 'conversation'
require_relative "conversation"

class ChatbotView < Live::View
def conversation
Expand Down Expand Up @@ -77,7 +77,7 @@ def render_message(builder, message)
def render(builder)
builder.tag(:div, class: "conversation") do
builder.tag(:div, class: "messages") do
conversation.conversation_messages.each do |message|
conversation&.conversation_messages&.each do |message|
render_message(builder, message)
end
end
Expand All @@ -93,7 +93,7 @@ def self.resolver
end

def body(...)
ChatbotView.new(...)
ChatbotView.root(...)
end

def handle(request)
Expand All @@ -106,9 +106,9 @@ def handle(request)
end

unless conversation_id
reference.query[:conversation_id] = Conversation.create!(model: 'llama3').id
reference.query[:conversation_id] = Conversation.create!(model: "llama3").id

return ::Protocol::HTTP::Response[302, {'location' => reference.to_s}]
return ::Protocol::HTTP::Response[302, {"location" => reference.to_s}]
else
return super(request, conversation_id: conversation_id)
end
Expand Down
Loading

0 comments on commit a5c4d28

Please sign in to comment.