Skip to content

Commit 9b325b7

Browse files
committed
Modernize code & update dependencies.
1 parent 78852bc commit 9b325b7

59 files changed

Lines changed: 509 additions & 299 deletions

Some content is hidden

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

.github/workflows/documentation-coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1717
- uses: ruby/setup-ruby@v1
1818
with:
1919
ruby-version: ruby

.github/workflows/documentation.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ubuntu-latest
2525

2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v6
2828

2929
- uses: ruby/setup-ruby@v1
3030
with:
@@ -39,7 +39,7 @@ jobs:
3939
run: bundle exec bake utopia:project:static --force no
4040

4141
- name: Upload documentation artifact
42-
uses: actions/upload-pages-artifact@v3
42+
uses: actions/upload-pages-artifact@v4
4343
with:
4444
path: docs
4545

.github/workflows/rubocop.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1414
- uses: ruby/setup-ruby@v1
1515
with:
1616
ruby-version: ruby

.github/workflows/test-coverage.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- ruby
2424

2525
steps:
26-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@v6
2727
- uses: ruby/setup-ruby@v1
2828
with:
2929
ruby-version: ${{matrix.ruby}}
@@ -33,7 +33,7 @@ jobs:
3333
timeout-minutes: 5
3434
run: bundle exec bake test
3535

36-
- uses: actions/upload-artifact@v4
36+
- uses: actions/upload-artifact@v5
3737
with:
3838
include-hidden-files: true
3939
if-no-files-found: error
@@ -45,13 +45,13 @@ jobs:
4545
runs-on: ubuntu-latest
4646

4747
steps:
48-
- uses: actions/checkout@v4
48+
- uses: actions/checkout@v6
4949
- uses: ruby/setup-ruby@v1
5050
with:
5151
ruby-version: ruby
5252
bundler-cache: true
5353

54-
- uses: actions/download-artifact@v4
54+
- uses: actions/download-artifact@v6
5555

5656
- name: Validate coverage
5757
timeout-minutes: 5

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
- macos
1919

2020
ruby:
21-
- "3.2"
2221
- "3.3"
2322
- "3.4"
23+
- "4.0"
2424

2525
experimental: [false]
2626

@@ -36,7 +36,7 @@ jobs:
3636
experimental: true
3737

3838
steps:
39-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@v6
4040
- uses: ruby/setup-ruby@v1
4141
with:
4242
ruby-version: ${{matrix.ruby}}

.rubocop.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
plugins:
2+
- rubocop-md
23
- rubocop-socketry
34

45
AllCops:
56
DisabledByDefault: true
67

8+
# Socketry specific rules:
9+
710
Layout/ConsistentBlankLineIndentation:
811
Enabled: true
912

13+
Layout/BlockDelimiterSpacing:
14+
Enabled: true
15+
16+
Style/GlobalExceptionVariables:
17+
Enabled: true
18+
19+
# General Layout rules:
20+
1021
Layout/IndentationStyle:
1122
Enabled: true
1223
EnforcedStyle: tabs
@@ -33,6 +44,9 @@ Layout/BeginEndAlignment:
3344
Enabled: true
3445
EnforcedStyleAlignWith: start_of_line
3546

47+
Layout/RescueEnsureAlignment:
48+
Enabled: true
49+
3650
Layout/ElseAlignment:
3751
Enabled: true
3852

@@ -41,10 +55,15 @@ Layout/DefEndAlignment:
4155

4256
Layout/CaseIndentation:
4357
Enabled: true
58+
EnforcedStyle: end
4459

4560
Layout/CommentIndentation:
4661
Enabled: true
4762

63+
Layout/FirstHashElementIndentation:
64+
Enabled: true
65+
EnforcedStyle: consistent
66+
4867
Layout/EmptyLinesAroundClassBody:
4968
Enabled: true
5069

@@ -63,6 +82,25 @@ Layout/SpaceAroundBlockParameters:
6382
Enabled: true
6483
EnforcedStyleInsidePipes: no_space
6584

85+
Layout/FirstArrayElementIndentation:
86+
Enabled: true
87+
EnforcedStyle: consistent
88+
89+
Layout/ArrayAlignment:
90+
Enabled: true
91+
EnforcedStyle: with_fixed_indentation
92+
93+
Layout/FirstArgumentIndentation:
94+
Enabled: true
95+
EnforcedStyle: consistent
96+
97+
Layout/ArgumentAlignment:
98+
Enabled: true
99+
EnforcedStyle: with_fixed_indentation
100+
101+
Layout/ClosingParenthesisIndentation:
102+
Enabled: true
103+
66104
Style/FrozenStringLiteralComment:
67105
Enabled: true
68106

bake.rb

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

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

66
# Update the project documentation with the new version number.
77
#
@@ -10,3 +10,10 @@ def after_gem_release_version_increment(version)
1010
context["releases:update"].call(version)
1111
context["utopia:project:update"].call
1212
end
13+
14+
# Create a GitHub release for the given tag.
15+
#
16+
# @parameter tag [String] The tag to create a release for.
17+
def after_gem_release(tag:, **options)
18+
context["releases:github:release"].call(tag)
19+
end

config/sus.rb

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

3+
# Released under the MIT License.
4+
# Copyright, 2025-2026, by Samuel Williams.
5+
36
require "covered/sus"
47
include Covered::Sus
58

context/flappy-bird-tutorial.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ First, let's create the basic structure for our game. We'll start with a simple
4848
Create a new file called `flappy_basic.rb`:
4949

5050
```ruby
51-
require 'live'
51+
require "live"
5252

5353
class FlappyBasicView < Live::View
5454
WIDTH = 420
@@ -172,7 +172,7 @@ class Bird < BoundingBox
172172

173173
def initialize(x = 30, y = HEIGHT / 2, width: 34, height: 24, skin: nil)
174174
super(x, y, width, height)
175-
@skin = skin || 'bird'
175+
@skin = skin || "bird"
176176
@velocity = 0.0
177177
@jumping = false
178178
@dying = false
@@ -253,7 +253,7 @@ class Bird < BoundingBox
253253

254254
builder.inline_tag(:div,
255255
id: id,
256-
class: 'particle jump',
256+
class: "particle jump",
257257
style: "left: #{center[0]}px; bottom: #{center[1]}px; --rotation-angle: #{angle}deg;"
258258
)
259259
end
@@ -387,12 +387,12 @@ class Pipe
387387

388388
# Render lower pipe
389389
builder.inline_tag(:div,
390-
class: 'pipe',
390+
class: "pipe",
391391
style: "left: #{@x}px; bottom: #{self.bottom}px; width: #{@width}px; height: #{@height}px; #{display}"
392392
)
393393
# Render upper pipe
394394
builder.inline_tag(:div,
395-
class: 'pipe',
395+
class: "pipe",
396396
style: "left: #{@x}px; bottom: #{self.top}px; width: #{@width}px; height: #{@height}px; #{display}"
397397
)
398398
end
@@ -461,7 +461,7 @@ class Gemstone < BoundingBox
461461
end
462462

463463
builder.inline_tag(:div,
464-
class: 'gemstone',
464+
class: "gemstone",
465465
style: "left: #{@x}px; bottom: #{@y}px; width: #{@width}px; height: #{@height}px; opacity: #{opacity};"
466466
)
467467

@@ -475,7 +475,7 @@ class Gemstone < BoundingBox
475475

476476
builder.inline_tag(:div,
477477
id: id,
478-
class: 'particle bonus',
478+
class: "particle bonus",
479479
style: "left: #{center[0]}px; bottom: #{center[1]}px; --rotation-angle: #{angle}deg;"
480480
)
481481
end
@@ -540,7 +540,7 @@ Let's add a way for players to choose different bird skins:
540540

541541
```ruby
542542
class SkinSelectionView < Live::View
543-
SKINS = ['bird', 'gull', 'kiwi', 'owl']
543+
SKINS = ["bird", "gull", "kiwi", "owl"]
544544

545545
def handle(event)
546546
skin = event.dig(:detail, :skin) or return
@@ -627,7 +627,7 @@ class FlappyView < Live::View
627627
@pipes = nil
628628
@bonus = nil
629629

630-
@skin_selection = SkinSelectionView.mount(self, 'skin-selection')
630+
@skin_selection = SkinSelectionView.mount(self, "skin-selection")
631631

632632
# Game state
633633
@score = 0
@@ -784,7 +784,7 @@ def step(dt)
784784
play_music
785785
end
786786
end
787-
787+
788788
# Check for collision
789789
if pipe.intersect?(@bird)
790790
Console.info(self, "Player has died.")
@@ -943,7 +943,7 @@ Here's how all the pieces fit together in a complete game file:
943943
#!/usr/bin/env lively
944944
# frozen_string_literal: true
945945

946-
require 'live'
946+
require "live"
947947

948948
# [All the classes we've built: BoundingBox, Bird, Pipe, Gemstone, SkinSelectionView, FlappyView]
949949
# Put them all together in a single file for easy execution

context/game-audio-tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ To play sounds from your Ruby application, you need to connect your custom eleme
116116
**Ruby Application (`application.rb`):**
117117

118118
```ruby
119-
require 'lively'
119+
require "lively"
120120

121121
class GameView < Live::View
122122
def tag_name
@@ -131,17 +131,17 @@ class GameView < Live::View
131131

132132
def player_jump
133133
@player.jump
134-
play_sound('jump') # Play jump sound
134+
play_sound("jump") # Play jump sound
135135
end
136136

137137
def collect_coin
138138
@score += 10
139-
play_sound('coin') # Play coin sound
139+
play_sound("coin") # Play coin sound
140140
end
141141

142142
def player_dies
143143
@lives -= 1
144-
play_sound('death') # Play death sound
144+
play_sound("death") # Play death sound
145145
end
146146
end
147147
```

0 commit comments

Comments
 (0)