Skip to content

Commit f792aed

Browse files
committed
Fix "byexample" doc tests
1 parent 1d9c8c9 commit f792aed

File tree

15 files changed

+200
-38
lines changed

15 files changed

+200
-38
lines changed

.devcontainer/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ruby:3.4
2+
3+
ARG USERNAME=vscode
4+
ARG USER_UID=1000
5+
ARG USER_GID=$USER_UID
6+
7+
RUN apt-get update && apt-get upgrade -y && \
8+
apt-get install -y curl wget git procps && \
9+
gem update --system && \
10+
gem update bundler && \
11+
# Add unprivileged user
12+
groupadd --gid $USER_GID $USERNAME && \
13+
useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME && \
14+
# Cleaning up
15+
apt-get autoremove -y && \
16+
apt-get clean -y && \
17+
rm -rf /var/lib/apt/lists/*
18+
19+
COPY ./docker-entrypoint.sh /
20+
21+
USER $USERNAME
22+
ENV GEM_HOME="/home/$USERNAME/.gem/ruby/$RUBY_VERSION"
23+
ENV PATH=$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
24+
RUN mkdir -p $GEM_HOME
25+
26+
ENTRYPOINT ["/docker-entrypoint.sh"]

.devcontainer/Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
5+
6+
gem "ruby-lsp"
7+
gem "standard"

.devcontainer/Gemfile.lock

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
ast (2.4.3)
5+
json (2.13.2)
6+
language_server-protocol (3.17.0.5)
7+
lint_roller (1.1.0)
8+
logger (1.7.0)
9+
parallel (1.27.0)
10+
parser (3.3.9.0)
11+
ast (~> 2.4.1)
12+
racc
13+
prism (1.4.0)
14+
racc (1.8.1)
15+
rainbow (3.1.1)
16+
rbs (3.9.4)
17+
logger
18+
regexp_parser (2.11.2)
19+
rubocop (1.75.8)
20+
json (~> 2.3)
21+
language_server-protocol (~> 3.17.0.2)
22+
lint_roller (~> 1.1.0)
23+
parallel (~> 1.10)
24+
parser (>= 3.3.0.2)
25+
rainbow (>= 2.2.2, < 4.0)
26+
regexp_parser (>= 2.9.3, < 3.0)
27+
rubocop-ast (>= 1.44.0, < 2.0)
28+
ruby-progressbar (~> 1.7)
29+
unicode-display_width (>= 2.4.0, < 4.0)
30+
rubocop-ast (1.46.0)
31+
parser (>= 3.3.7.2)
32+
prism (~> 1.4)
33+
rubocop-performance (1.25.0)
34+
lint_roller (~> 1.1)
35+
rubocop (>= 1.75.0, < 2.0)
36+
rubocop-ast (>= 1.38.0, < 2.0)
37+
ruby-lsp (0.26.1)
38+
language_server-protocol (~> 3.17.0)
39+
prism (>= 1.2, < 2.0)
40+
rbs (>= 3, < 5)
41+
ruby-progressbar (1.13.0)
42+
standard (1.50.0)
43+
language_server-protocol (~> 3.17.0.2)
44+
lint_roller (~> 1.0)
45+
rubocop (~> 1.75.5)
46+
standard-custom (~> 1.0.0)
47+
standard-performance (~> 1.8)
48+
standard-custom (1.0.2)
49+
lint_roller (~> 1.0)
50+
rubocop (~> 1.50)
51+
standard-performance (1.8.0)
52+
lint_roller (~> 1.1)
53+
rubocop-performance (~> 1.25.0)
54+
unicode-display_width (3.1.5)
55+
unicode-emoji (~> 4.0, >= 4.0.4)
56+
unicode-emoji (4.0.4)
57+
58+
PLATFORMS
59+
aarch64-linux
60+
ruby
61+
62+
DEPENDENCIES
63+
ruby-lsp
64+
standard
65+
66+
BUNDLED WITH
67+
2.7.1

.devcontainer/devcontainer.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3+
{
4+
"name": "Teckel",
5+
"dockerFile": "Dockerfile",
6+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
7+
// "image": "mcr.microsoft.com/devcontainers/ruby:1-3.3-bullseye"
8+
9+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
10+
11+
// Features to add to the dev container. More info: https://containers.dev/features.
12+
// "features": {},
13+
14+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
15+
// "forwardPorts": [],
16+
17+
// Use 'postCreateCommand' to run commands after the container is created.
18+
"postCreateCommand": "bundle install",
19+
20+
"shutdownAction": "stopContainer",
21+
22+
// Configure tool-specific properties.
23+
"customizations": {
24+
"vscode": {
25+
"extensions": [
26+
"shopify.ruby-extensions-pack"
27+
],
28+
"settings": {
29+
"[ruby]": {
30+
"editor.defaultFormatter": "Shopify.ruby-lsp", // Use the Ruby LSP as the default formatter
31+
"editor.formatOnSave": true, // Format files automatically when saving
32+
"editor.tabSize": 2, // Use 2 spaces for indentation
33+
"editor.insertSpaces": true, // Use spaces and not tabs for indentation
34+
"editor.semanticHighlighting.enabled": true, // Enable semantic highlighting
35+
"editor.formatOnType": true // Enable formatting while typing
36+
},
37+
"rubyLsp.addonSettings": {},
38+
"rubyLsp.bundleGemfile": ".devcontainer/Gemfile",
39+
// "rubyLsp.rubyExecutablePath": "chruby-exec ruby",
40+
"rubyLsp.enabledFeatures": {
41+
"codeActions": true,
42+
"codeLens": true,
43+
"completion": true,
44+
"definition": true,
45+
"diagnostics": true,
46+
"documentHighlights": true,
47+
"documentLink": true,
48+
"documentSymbols": true,
49+
"foldingRanges": true,
50+
"formatting": true,
51+
"hover": true,
52+
"inlayHint": true,
53+
"onTypeFormatting": true,
54+
"selectionRanges": true,
55+
"semanticHighlighting": true,
56+
"signatureHelp": true,
57+
"typeHierarchy": true,
58+
"workspaceSymbol": true
59+
},
60+
"rubyLsp.formatter": "standard",
61+
"rubyLsp.linters": [
62+
"standard"
63+
],
64+
"rubyLsp.featureFlags": {
65+
"all": true
66+
}
67+
}
68+
}
69+
},
70+
71+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
72+
// "remoteUser": "root"
73+
"remoteUser": "vscode"
74+
}

.devcontainer/docker-entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
4+
unset BUNDLE_PATH
5+
unset BUNDLE_BIN
6+
7+
exec "$@"

.github/workflows/pages_specs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Ruby
2323
uses: ruby/setup-ruby@v1
2424
with:
25-
ruby-version: '2.7'
25+
ruby-version: '3.4'
2626
bundler-cache: true
2727
- name: Setup python
2828
uses: actions/setup-python@v1

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
88
gemspec
99

1010
group :development, :test do
11-
gem "irb", ">= 1.2.7", "< 2" if RUBY_VERSION >= "2.5"
11+
gem "irb", "~> 1.4.1" if RUBY_VERSION >= "2.6" # byexample needs a specific irb version
1212
gem "dry-struct", ">= 1.1.1", "< 2"
1313
gem "dry-monads", ">= 1.3", "< 2"
1414
gem "dry-validation", ">= 1.5.6", "< 2"

_pages/docs/chains/around.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ Their hooks gets total control over the execution, so it needs to take care of c
8989
=> true
9090

9191
>> failure_result.failure
92-
=> {:message=>"Did not find a friend."}
92+
=> {message: "Did not find a friend."}
9393
```
9494
{% endfilter %}

_pages/docs/chains/basics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Defining a simple Chain with three steps.
102102
=> true
103103

104104
>> failure_result.failure
105-
=> {:message=>"Did not find a friend."}
105+
=> {message: "Did not find a friend."}
106106
```
107107
{% endfilter %}
108108

@@ -121,8 +121,8 @@ Hash style:
121121

122122
>> result
123123
=> ["Success result",
124-
{:friend=>#<User:<...> @age=42, @name="A friend">,
125-
:user=>#<User:<...> @age=23, @name="Bob">}]
124+
{friend: #<User:<...> @age=42, @name="A friend">,
125+
user: #<User:<...> @age=23, @name="Bob">}]
126126
```
127127
{% endfilter %}
128128

@@ -138,6 +138,6 @@ Array style:
138138
.. end
139139

140140
>> result
141-
=> ["Failed", {:message=>"Did not find a friend."}]
141+
=> ["Failed", {message: "Did not find a friend."}]
142142
```
143143
{% endfilter %}

_pages/docs/operations/basics.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ A failure call:
5454
```ruby
5555
>> CreateUserInline.call(name: "Bob", age: 10)
5656
=> #<CreateUserInline::Error:<...>
57-
@errors=[{:age=>"underage"}],
57+
@errors=[{age: "underage"}],
5858
@message="Could not save User">
5959
```
6060
{% endfilter %}
@@ -110,7 +110,7 @@ A failure call:
110110
{% filter remove_code_promt %}
111111
```ruby
112112
>> CreateUserDry.call(name: "Bob", age: 10)
113-
=> {:errors=>[{:age=>"underage"}], :message=>"Could not save User"}
113+
=> {errors: [{age: "underage"}], message: "Could not save User"}
114114
```
115115
{% endfilter %}
116116

@@ -272,6 +272,6 @@ Array style:
272272
.. end
273273

274274
>> result
275-
=> ["Failed", {:errors=>[{:age=>"underage"}], :message=>"Could not save User"}]
275+
=> ["Failed", {errors: [{age: "underage"}], message: "Could not save User"}]
276276
```
277277
{% endfilter %}

0 commit comments

Comments
 (0)