Skip to content

Commit d892af2

Browse files
committed
Modernize code.
1 parent 7610f92 commit d892af2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+907
-811
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Documentation Coverage
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
env:
9+
CONSOLE_OUTPUT: XTerm
10+
COVERAGE: PartialSummary
11+
12+
jobs:
13+
validate:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: "3.4"
21+
bundler-cache: true
22+
23+
- name: Validate coverage
24+
timeout-minutes: 5
25+
run: bundle exec bake decode:index:coverage lib

.github/workflows/documentation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
- uses: ruby/setup-ruby@v1
3131
with:
32-
ruby-version: "3.3"
32+
ruby-version: "3.4"
3333
bundler-cache: true
3434

3535
- name: Installing packages

.github/workflows/rubocop.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: RuboCop
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
env:
9+
CONSOLE_OUTPUT: XTerm
10+
11+
jobs:
12+
check:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: ruby
20+
bundler-cache: true
21+
22+
- name: Run RuboCop
23+
timeout-minutes: 10
24+
run: bundle exec rubocop

.github/workflows/coverage.yaml renamed to .github/workflows/test-coverage.yaml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Coverage
1+
name: Test Coverage
22

33
on: [push, pull_request]
44

@@ -21,7 +21,7 @@ jobs:
2121
- macos
2222

2323
ruby:
24-
- "3.3"
24+
- "3.4"
2525

2626
steps:
2727
- uses: actions/checkout@v4
@@ -30,24 +30,14 @@ jobs:
3030
ruby-version: ${{matrix.ruby}}
3131
bundler-cache: true
3232

33-
- name: Installing packages (ubuntu)
34-
if: matrix.os == 'ubuntu'
35-
run: sudo apt-get install wget
36-
37-
- name: Installing packages (macos)
38-
if: matrix.os == 'macos'
39-
run: brew install wget
40-
4133
- name: Run tests
42-
timeout-minutes: 10
43-
run: |
44-
git config --global user.email "samuel@oriontransfer.net"
45-
git config --global user.name "Samuel Williams"
46-
git config --global init.defaultBranch main
47-
bundle exec bake test
34+
timeout-minutes: 5
35+
run: bundle exec bake test
4836

49-
- uses: actions/upload-artifact@v3
37+
- uses: actions/upload-artifact@v4
5038
with:
39+
include-hidden-files: true
40+
if-no-files-found: error
5141
name: coverage-${{matrix.os}}-${{matrix.ruby}}
5242
path: .covered.db
5343

@@ -59,10 +49,10 @@ jobs:
5949
- uses: actions/checkout@v4
6050
- uses: ruby/setup-ruby@v1
6151
with:
62-
ruby-version: "3.3"
52+
ruby-version: "3.4"
6353
bundler-cache: true
6454

65-
- uses: actions/download-artifact@v3
55+
- uses: actions/download-artifact@v4
6656

6757
- name: Validate coverage
6858
timeout-minutes: 5

.github/workflows/test-external.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- "3.1"
2424
- "3.2"
2525
- "3.3"
26+
- "3.4"
2627

2728
steps:
2829
- uses: actions/checkout@v4

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- "3.1"
2525
- "3.2"
2626
- "3.3"
27+
- "3.4"
2728

2829
experimental: [false]
2930

.rubocop.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
AllCops:
2+
DisabledByDefault: true
3+
4+
Layout/IndentationStyle:
5+
Enabled: true
6+
EnforcedStyle: tabs
7+
8+
Layout/InitialIndentation:
9+
Enabled: true
10+
11+
Layout/IndentationWidth:
12+
Enabled: true
13+
Width: 1
14+
15+
Layout/IndentationConsistency:
16+
Enabled: true
17+
EnforcedStyle: normal
18+
19+
Layout/BlockAlignment:
20+
Enabled: true
21+
22+
Layout/EndAlignment:
23+
Enabled: true
24+
EnforcedStyleAlignWith: start_of_line
25+
26+
Layout/BeginEndAlignment:
27+
Enabled: true
28+
EnforcedStyleAlignWith: start_of_line
29+
30+
Layout/ElseAlignment:
31+
Enabled: true
32+
33+
Layout/DefEndAlignment:
34+
Enabled: true
35+
36+
Layout/CaseIndentation:
37+
Enabled: true
38+
39+
Layout/CommentIndentation:
40+
Enabled: true
41+
42+
Layout/EmptyLinesAroundClassBody:
43+
Enabled: true
44+
45+
Layout/EmptyLinesAroundModuleBody:
46+
Enabled: true
47+
48+
Style/FrozenStringLiteralComment:
49+
Enabled: true
50+
51+
Style/StringLiterals:
52+
Enabled: true
53+
EnforcedStyle: double_quotes

bake/utopia.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2017-2024, by Samuel Williams.
4+
# Copyright, 2017-2025, by Samuel Williams.
55

66
def environment(name: nil)
77
if name
8-
ENV['UTOPIA_ENV'] = name
8+
ENV["UTOPIA_ENV"] = name
99
end
1010

11-
require File.expand_path('config/environment', context.root)
11+
require File.expand_path("config/environment", context.root)
1212
end
1313

1414
# Start the development server.
1515
def development
1616
self.environment
1717

18-
exec('guard', '-g', 'development')
18+
exec("guard", "-g", "development")
1919
end

bake/utopia/environment.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2018-2024, by Samuel Williams.
4+
# Copyright, 2018-2025, by Samuel Williams.
55

66
# Update environment variables in config/environment.yaml
77
def initialize(...)
88
super
99

10-
require 'securerandom'
11-
require 'yaml/store'
12-
require 'console'
10+
require "securerandom"
11+
require "yaml/store"
12+
require "console"
1313
end
1414

1515
# Setup default environemnts "testing" and "development".
@@ -26,7 +26,7 @@ def defaults(name, root: context.root)
2626
update_environment(root, name) do |store|
2727
Console.info(self) {"Setting up defaults for environment #{name}..."}
2828
# Set some useful defaults for the environment.
29-
store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
29+
store["UTOPIA_SESSION_SECRET"] ||= SecureRandom.hex(40)
3030
end
3131
end
3232

bake/utopia/node.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2016-2022, by Samuel Williams.
4+
# Copyright, 2016-2025, by Samuel Williams.
55

66
def update
7-
require 'fileutils'
8-
require 'utopia/path'
7+
require "fileutils"
8+
require "utopia/path"
99

1010
root = Pathname.new(context.root)
1111
package_root = root + "node_modules"
@@ -23,7 +23,7 @@ def update
2323
package_directory = package_path.relative_path_from(package_root)
2424
install_path = install_root + package_directory
2525

26-
dist_path = package_path + 'dist'
26+
dist_path = package_path + "dist"
2727

2828
FileUtils::Verbose.rm_rf(install_path)
2929
FileUtils::Verbose.mkpath(install_path.dirname)
@@ -47,7 +47,7 @@ def expand_package_paths(root, into = [])
4747
paths.each do |path|
4848
basename = path.basename.to_s
4949
# Handle organisation sub-directories which start with an '@' symbol:
50-
if basename.start_with?('@')
50+
if basename.start_with?("@")
5151
expand_package_paths(path, into)
5252
else
5353
into << path

bake/utopia/server.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2017-2023, by Samuel Williams.
4+
# Copyright, 2017-2025, by Samuel Williams.
55

66
def initialize(...)
77
super
88

9-
require 'fileutils'
10-
require 'socket'
9+
require "fileutils"
10+
require "socket"
1111
end
1212

1313
# Create a remote Utopia website suitable for deployment using git.
@@ -25,7 +25,7 @@ def create(root: context.root)
2525
SETUP_ROOT = File.expand_path("../../setup", __dir__)
2626

2727
# The root directory of the template server deployment:
28-
SERVER_ROOT = File.join(SETUP_ROOT, 'server')
28+
SERVER_ROOT = File.join(SETUP_ROOT, "server")
2929

3030
# Update the git hooks in an existing server repository.
3131
def update(root: context.root)
@@ -49,13 +49,13 @@ def update(root: context.root)
4949
# Set some useful defaults for the environment.
5050
recipe = context.lookup("utopia:environment:update")
5151
recipe.instance.update("environment", root: root) do |store|
52-
store['VARIANT'] ||= 'production'
53-
store['UTOPIA_SESSION_SECRET'] ||= SecureRandom.hex(40)
52+
store["VARIANT"] ||= "production"
53+
store["UTOPIA_SESSION_SECRET"] ||= SecureRandom.hex(40)
5454
end
5555

5656
# Copy git hooks:
57-
system("cp", "-r", File.join(SERVER_ROOT, 'git', 'hooks'), File.join(root, '.git')) or fail "could not copy git hooks"
57+
system("cp", "-r", File.join(SERVER_ROOT, "git", "hooks"), File.join(root, ".git")) or fail "could not copy git hooks"
5858
# finally set everything in the .git directory to be group writable
5959
# This failed for me and I had to do sudo chown http:http .git -R first.
60-
system("chmod", "-Rf", "g+w", File.join(root, '.git')) or fail "could not update permissions of .git directory"
60+
system("chmod", "-Rf", "g+w", File.join(root, ".git")) or fail "could not update permissions of .git directory"
6161
end

bake/utopia/shell.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# frozen_string_literal: true
22

33
# Released under the MIT License.
4-
# Copyright, 2020-2022, by Samuel Williams.
4+
# Copyright, 2020-2025, by Samuel Williams.
55

66
def shell
7-
call 'utopia:environment'
7+
call "utopia:environment"
88

9-
require 'utopia/shell'
9+
require "utopia/shell"
1010

1111
binding = Utopia::Shell.new(self.context).binding
1212

0 commit comments

Comments
 (0)