rundoc 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rundoc/cli.rb +2 -1
- data/lib/rundoc/code_command/website/visit.rb +3 -1
- data/lib/rundoc/code_section.rb +3 -1
- data/lib/rundoc/version.rb +1 -1
- data/test/fixtures/rails_4/rundoc.md +1 -1
- data/test/fixtures/rails_5/rundoc.md +1 -1
- data/test/fixtures/rails_8/rundoc.md +481 -0
- data/test/integration/website_test.rb +1 -1
- data/test/system/exe_cli_test.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89f953193be8aea0831e65e251a1d0cc8a3796573fe5818a6eb4ae2ed0e489d4
|
4
|
+
data.tar.gz: 9ea2f3a42906fa0c79cbb39862ec5300b4688dcce15df8991cf0a99e2d7c60da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aba6794da79ce27d6a4072e0cda4c7e2525030f0bd7c7925aaca8708a3adbd2632a0bb32c2ea451bc5f58ebc4a674ab4012ec6ddaeae7114ffbcefbafb53b35
|
7
|
+
data.tar.gz: fef87625649965fdd3dd5817e55d73299e1ebf67cfb3f9895c45d2c26b410af566f43540490a7c4ec7198b31f86d9c14079701b25981f7689b99644775f8e55f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
+
## 3.0.1
|
4
|
+
|
5
|
+
- Fix: Save in-progress work in the "failure" directory when the rundoc command is interrupted via a signal such as `SIGTERM` (https://github.com/zombocom/rundoc/pull/67)
|
6
|
+
|
3
7
|
## 3.0.0
|
4
8
|
|
5
9
|
- Change: Default directories are now `rundoc_output` (instead of `project`) and `rundoc_failure` (instead of `tmp`).
|
data/lib/rundoc/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class Rundoc::CodeCommand::Website
|
2
4
|
class Visit < Rundoc::CodeCommand
|
3
5
|
def initialize(name:, url: nil, scroll: nil, height: 720, width: 1024, visible: false)
|
@@ -19,7 +21,7 @@ class Rundoc::CodeCommand::Website
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def call(env = {})
|
22
|
-
message =
|
24
|
+
message = "Visting: #{@url}"
|
23
25
|
message << "and executing:\n#{contents}" unless contents.nil? || contents.empty?
|
24
26
|
|
25
27
|
puts message
|
data/lib/rundoc/code_section.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rundoc
|
2
4
|
# holds code, parses and creates CodeCommand
|
3
5
|
class CodeSection
|
@@ -44,7 +46,7 @@ module Rundoc
|
|
44
46
|
result = []
|
45
47
|
env = {}
|
46
48
|
env[:commands] = []
|
47
|
-
env[:fence_start] =
|
49
|
+
env[:fence_start] = "#{fence}#{lang}"
|
48
50
|
env[:fence_end] = "#{fence}#{AUTOGEN_WARNING}"
|
49
51
|
env[:before] = []
|
50
52
|
env[:after] = []
|
data/lib/rundoc/version.rb
CHANGED
@@ -19,7 +19,7 @@ end
|
|
19
19
|
> If you are starting a new application, we recommend you use the most recently released version of Rails.
|
20
20
|
|
21
21
|
>warning
|
22
|
-
>As of November 28th, 2022, free Heroku dynos, free Heroku Postgres and free Heroku Data for
|
22
|
+
>As of November 28th, 2022, free Heroku dynos, free Heroku Postgres and free Heroku Data for Key-Value Store plans are [no longer available](https://blog.heroku.com/next-chapter).
|
23
23
|
>
|
24
24
|
>We recommend using our [low-cost plans](https://blog.heroku.com/new-low-cost-plans) to complete this tutorial. Eligible students can apply for platform credits through our new [Heroku for GitHub Students program](https://blog.heroku.com/github-student-developer-program).
|
25
25
|
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
> If you are starting a new application, we recommend you use the most recently released version of Rails.
|
23
23
|
|
24
24
|
>warning
|
25
|
-
>As of November 28th, 2022, free Heroku dynos, free Heroku Postgres and free Heroku
|
25
|
+
>As of November 28th, 2022, free Heroku dynos, free Heroku Postgres and free Heroku Key-Value Store plans are [no longer available](https://blog.heroku.com/next-chapter).
|
26
26
|
>
|
27
27
|
>We recommend using our [low-cost plans](https://blog.heroku.com/new-low-cost-plans) to complete this tutorial. Eligible students can apply for platform credits through our new [Heroku for GitHub Students program](https://blog.heroku.com/github-student-developer-program).
|
28
28
|
|
@@ -0,0 +1,481 @@
|
|
1
|
+
```
|
2
|
+
:::-- rundoc
|
3
|
+
email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`
|
4
|
+
|
5
|
+
Rundoc.configure do |config|
|
6
|
+
config.filter_sensitive(email => "developer@example.com")
|
7
|
+
config.filter_sensitive(Dir.pwd => ".")
|
8
|
+
end
|
9
|
+
```
|
10
|
+
|
11
|
+
<!--
|
12
|
+
rundoc src:
|
13
|
+
https://github.com/schneems/rundoc/blob/main/test/fixtures/rails_8/rundoc.md
|
14
|
+
|
15
|
+
Command:
|
16
|
+
$ bin/rundoc test/fixtures/rails_8/rundoc.md
|
17
|
+
-->
|
18
|
+
|
19
|
+
Ruby on Rails is a popular web framework written in [Ruby](http://www.ruby-lang.org/). This guide covers using Rails 8 on Heroku. For information on running previous versions of Rails on Heroku, see the tutorial for [Rails 7.x](getting-started-with-rails7) or [Rails 6.x](getting-started-with-rails6).
|
20
|
+
|
21
|
+
```
|
22
|
+
:::-- $ ruby -e "exit 1 unless RUBY_VERSION == '3.2.6'"
|
23
|
+
```
|
24
|
+
|
25
|
+
The tutorial assumes that you have:
|
26
|
+
|
27
|
+
- Basic familiarity with Ruby, Ruby on Rails, and Git
|
28
|
+
- A locally installed version of Ruby 3.2.0+, Rubygems, Bundler, and Rails 8+
|
29
|
+
- A locally installed version of the [Heroku CLI](heroku-cli#install-the-heroku-cli)
|
30
|
+
- A [verified Heroku Account](https://devcenter.heroku.com/articles/account-verification)
|
31
|
+
- A subscription to the [Eco dynos plan](eco-dyno-hours) (recommended)
|
32
|
+
|
33
|
+
>note
|
34
|
+
>Using dynos and databases to complete this tutorial counts towards your usage. We recommend using our [low-cost plans](https://blog.heroku.com/new-low-cost-plans) to complete this tutorial. Eligible students can apply for platform credits through our new [Heroku for GitHub Students program](https://blog.heroku.com/github-student-developer-program).
|
35
|
+
|
36
|
+
## Local Setup
|
37
|
+
|
38
|
+
After installing the [Heroku CLI](heroku-cli#install-the-heroku-cli), log in through your terminal:
|
39
|
+
|
40
|
+
```term
|
41
|
+
$ heroku login
|
42
|
+
heroku: Press any key to open up the browser to login or q to exit
|
43
|
+
› Warning: If browser does not open, visit
|
44
|
+
› https://cli-auth.heroku.com/auth/browser/***
|
45
|
+
heroku: Waiting for login...
|
46
|
+
Logging in... done
|
47
|
+
Logged in as developer@example.com
|
48
|
+
```
|
49
|
+
|
50
|
+
This command opens your web browser to the Heroku login page. If your browser is already logged in to Heroku, click the **`Log in`** button on the page.
|
51
|
+
|
52
|
+
This authentication is required for the `heroku` and `git` commands to work correctly.
|
53
|
+
|
54
|
+
>note
|
55
|
+
> If you're behind a firewall that uses a proxy to connect with external HTTP/HTTPS services, [set the `HTTP_PROXY` or `HTTPS_PROXY` environment variables](articles/using-the-cli#using-an-http-proxy) in your local development environment before running the `heroku` command.
|
56
|
+
|
57
|
+
## Create a New or Upgrade an Existing Rails App
|
58
|
+
|
59
|
+
Ensure you have Rails 8 installed by running `rails -v` before creating an app. If necessary, install Rails 8 with `gem install`:
|
60
|
+
|
61
|
+
```term
|
62
|
+
:::>> $ gem install rails --no-document
|
63
|
+
```
|
64
|
+
|
65
|
+
Create a Rails app:
|
66
|
+
|
67
|
+
```term
|
68
|
+
:::>- $ rails new myapp --database=postgresql
|
69
|
+
```
|
70
|
+
|
71
|
+
Move into the application directory
|
72
|
+
|
73
|
+
```term
|
74
|
+
:::>- $ cd myapp
|
75
|
+
:::>> $ ls -1
|
76
|
+
```
|
77
|
+
|
78
|
+
<!-- The `bundle install` after `bundle lock` can be removed after https://github.com/rails/rails/issues/48278 is closed -->
|
79
|
+
|
80
|
+
Create a local database:
|
81
|
+
|
82
|
+
```term
|
83
|
+
:::>> $ bin/rails db:create
|
84
|
+
```
|
85
|
+
|
86
|
+
## Add the pg Gem
|
87
|
+
|
88
|
+
For new or existing apps where `--database=postgresql` isn’t defined, confirm the `sqlite3` gem doesn’t exist in the `Gemfile`. Add the `pg` gem in its place.
|
89
|
+
|
90
|
+
Within the `Gemfile` remove:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
gem 'sqlite3'
|
94
|
+
```
|
95
|
+
|
96
|
+
Replace it with:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
gem 'pg'
|
100
|
+
```
|
101
|
+
|
102
|
+
> callout
|
103
|
+
>Heroku highly recommends using PostgreSQL locally during development. Maintaining [parity between development](http://www.12factor.net/dev-prod-parity) and deployment environments prevents introducing subtle bugs due to the differences in environments.
|
104
|
+
>
|
105
|
+
> [Install Postgres locally](heroku-postgresql#local-setup). For more information on why Postgres is recommended instead of Sqlite3, see [why Sqlite3 is not compatible with Heroku](sqlite3).
|
106
|
+
|
107
|
+
With the `Gemfile` updated, reinstall the dependencies:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
$ bundle install
|
111
|
+
```
|
112
|
+
|
113
|
+
The installation also updates `Gemfile.lock` with the changes.
|
114
|
+
|
115
|
+
In addition to the `pg` gem, ensure that `config/database.yml` defines the `postgresql` adapter. The development section of `config/database.yml` file looks something like this:
|
116
|
+
|
117
|
+
```term
|
118
|
+
:::>> $ cat config/database.yml
|
119
|
+
```
|
120
|
+
|
121
|
+
Be careful here. If the value of `adapter` is `postgres` and not `postgresql`, the application won’t work.
|
122
|
+
|
123
|
+
## Create a Welcome Page
|
124
|
+
|
125
|
+
Rails 8 no longer has a static index page in production by default. Apps upgraded to Rails 8 keep their existing page configurations, but new Rails 8 apps don't automatically generate a welcome page. Create a `welcome` controller to hold the homepage:
|
126
|
+
|
127
|
+
```term
|
128
|
+
:::>- $ rails generate controller welcome
|
129
|
+
```
|
130
|
+
|
131
|
+
Create `app/views/welcome/index.html.erb` and add the following code:
|
132
|
+
|
133
|
+
```html
|
134
|
+
:::-> file.write app/views/welcome/index.html.erb
|
135
|
+
<h2>Hello World</h2>
|
136
|
+
<p>
|
137
|
+
The time is now: <%= Time.now %>
|
138
|
+
</p>
|
139
|
+
```
|
140
|
+
|
141
|
+
With a welcome page created, create a route to map to this action.
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
:::>> file.append config/routes.rb#2
|
145
|
+
root 'welcome#index'
|
146
|
+
```
|
147
|
+
|
148
|
+
Verify the page is present by starting the Rails web server:
|
149
|
+
|
150
|
+
```term
|
151
|
+
:::>> background.start("rails server", name: "server")
|
152
|
+
:::-- background.stop(name: "server")
|
153
|
+
```
|
154
|
+
|
155
|
+
Visit [http://localhost:3000](http://localhost:3000) in a browser. If the page doesn’t display, [reference the logs](#view-application-logs) to debug the error. Rails outputs logs in the same terminal where `rails server` was started.
|
156
|
+
|
157
|
+
## Specify the Ruby Version
|
158
|
+
|
159
|
+
Rails 8 requires Ruby 3.2.0 or above. Heroku installs a recent version of Ruby by default. Specify an exact version with the `ruby` DSL in `Gemfile`. For example:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
:::-- $ sed -i'' -e '/^ruby/d' ./Gemfile
|
163
|
+
:::-> file.append Gemfile#4
|
164
|
+
ruby "3.2.6"
|
165
|
+
```
|
166
|
+
|
167
|
+
Update the `RUBY VERSION` in the `Gemfile.lock` by running:
|
168
|
+
|
169
|
+
```term
|
170
|
+
:::>> $ bundle update --ruby
|
171
|
+
```
|
172
|
+
|
173
|
+
Verify the change:
|
174
|
+
|
175
|
+
```term
|
176
|
+
:::>> $ cat Gemfile.lock | grep RUBY -a1
|
177
|
+
```
|
178
|
+
|
179
|
+
Always use the same version of Ruby locally. Confirm the local version of ruby with `ruby -v`. Refer to the [Ruby Versions](ruby-versions) article for more details on defining a specific ruby version.
|
180
|
+
|
181
|
+
## Create a Procfile
|
182
|
+
|
183
|
+
Use a [Procfile](procfile), a text file in the root directory of your application, to explicitly declare what command to execute to start your app.
|
184
|
+
|
185
|
+
This Procfile declares a single process type, `web`, and the command needed to run it. The name `web` is important here. It declares that this process type is attached to Heroku's [HTTP routing](http-routing) stack and receives web traffic when deployed.
|
186
|
+
|
187
|
+
By default, a Rails app’s web process runs `rails server`, which uses Puma in Rails 8. When you deploy a Rails 8 application without a `Procfile`, this command executes. However, we recommend explicitly declaring how to boot your server process via a `Procfile`. For example:
|
188
|
+
|
189
|
+
```
|
190
|
+
:::-> file.write Procfile
|
191
|
+
web: bundle exec puma -C config/puma.rb
|
192
|
+
```
|
193
|
+
|
194
|
+
>note
|
195
|
+
>The `Procfile` filename is case sensitive. There is no file extension.
|
196
|
+
|
197
|
+
If `config/puma.rb` doesn’t exist, create one using [Heroku’s Puma documentation](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server) for maximum performance.
|
198
|
+
|
199
|
+
A Procfile can contain additional process types. For example, you can declare a [background worker process](background-jobs-queueing#process-model) that processes items off a queue.
|
200
|
+
|
201
|
+
## Store The App in Git
|
202
|
+
|
203
|
+
Heroku relies on [Git](http://git-scm.com/), a distributed source control management tool, for deploying applications. If the application is not already in Git, first verify that `git` is on the system with `git --help`:
|
204
|
+
|
205
|
+
```term
|
206
|
+
:::>- $ git --help
|
207
|
+
:::>> | $ head -n 5
|
208
|
+
```
|
209
|
+
|
210
|
+
If the command produces no output or `command not found`, [install Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
|
211
|
+
|
212
|
+
Navigate to the root directory of the Rails app. Use the `ls` command to see its contents:
|
213
|
+
|
214
|
+
```term
|
215
|
+
:::>> $ ls
|
216
|
+
```
|
217
|
+
|
218
|
+
Within the Rails app directly, initialize a local empty Git repository and commit the app’s code:
|
219
|
+
|
220
|
+
```term
|
221
|
+
:::>- $ git init
|
222
|
+
:::>- $ git add .
|
223
|
+
:::>- $ git commit -m "init"
|
224
|
+
```
|
225
|
+
|
226
|
+
Verify everything committed correctly with `git status`:
|
227
|
+
|
228
|
+
```term
|
229
|
+
:::>> $ git status
|
230
|
+
```
|
231
|
+
|
232
|
+
With the application committed to Git, it's ready to deploy to Heroku.
|
233
|
+
|
234
|
+
## Create a Heroku App
|
235
|
+
|
236
|
+
>warning
|
237
|
+
>Using a dyno and a database to complete this tutorial counts towards your usage. [Delete your app](https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-apps-destroy), and [database](https://devcenter.heroku.com/articles/heroku-postgresql#removing-the-add-on) as soon as you're done to control costs.
|
238
|
+
|
239
|
+
To create an app on Heroku, use the Heroku CLI Inside the Rails app’s root directory:
|
240
|
+
|
241
|
+
```term
|
242
|
+
:::>> $ heroku apps:create
|
243
|
+
```
|
244
|
+
|
245
|
+
When you create an app, a git remote called `heroku` is also created and associated with your local git repository. Git remotes are versions of your repository that live on other servers. You deploy your app by pushing its code to that special Heroku-hosted remote associated with your app. Verify the remote is set with `git config`:
|
246
|
+
|
247
|
+
```term
|
248
|
+
:::>> $ git config --list --local | grep heroku
|
249
|
+
```
|
250
|
+
|
251
|
+
If the current directory is incorrect or Git isn't [initialized](#store-the-app-in-git), Git returns `fatal: not in a git directory`. If Git returns a list of remotes, it's ready to deploy.
|
252
|
+
|
253
|
+
>note
|
254
|
+
>Following changes in the industry, Heroku [updated the default branch name](https://devcenter.heroku.com/changelog-items/1829) to `main`. If the project uses `master` as its default branch name, use `git push heroku master`.
|
255
|
+
|
256
|
+
## Provision a Database
|
257
|
+
|
258
|
+
Provision a [Heroku Postgres](https://devcenter.heroku.com/articles/heroku-postgresql) database, one of the add-ons available through the [Elements Marketplace](https://www.heroku.com/elements/addons). Add-ons are cloud services that provide out-of-the-box additional services for your application, such as logging, monitoring, databases, and more.
|
259
|
+
|
260
|
+
>note
|
261
|
+
>A `mini` Postgres size costs [$5 a month, prorated to the minute](https://elements.heroku.com/addons/heroku-postgresql). At the end of this tutorial, we prompt you to [delete your database](https://devcenter.heroku.com/articles/heroku-postgresql#removing-the-add-on) to minimize costs.
|
262
|
+
|
263
|
+
```term
|
264
|
+
:::>> $ heroku addons:create heroku-postgresql:essential-0
|
265
|
+
```
|
266
|
+
|
267
|
+
Your Heroku app can now access this Postgres database. The `DATABASE_URL` environment variable stores your credentials, which Rails connects to by convention.
|
268
|
+
|
269
|
+
## Deploy the App to Heroku
|
270
|
+
|
271
|
+
>warning
|
272
|
+
>Using a dyno to complete this tutorial counts towards your usage. [Delete your app](https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-apps-destroy) as soon as you're done to control costs.
|
273
|
+
|
274
|
+
Deploy your code. This command pushes the `main` branch of the sample repo to your `heroku` remote, which then deploys to Heroku:
|
275
|
+
|
276
|
+
```term
|
277
|
+
:::>> $ git push heroku main
|
278
|
+
```
|
279
|
+
|
280
|
+
If the output displays warnings or error messages, check the output and make adjustments.
|
281
|
+
|
282
|
+
After a successful deployment, complete these tasks as necessary:
|
283
|
+
|
284
|
+
* Database migrations
|
285
|
+
* Scale your dynos
|
286
|
+
* Check the app’s logs if issues arise
|
287
|
+
|
288
|
+
## Migrate The Database
|
289
|
+
|
290
|
+
If you're using a database in your application, trigger a migration by using the Heroku CLI to start a one-off [dyno](dynos). You can run commands, typically scripts and applications that are part of your app, in one-off dynos using the `heroku run` command. You can trigger a database migration with this command:
|
291
|
+
|
292
|
+
```term
|
293
|
+
$ heroku run rake db:migrate
|
294
|
+
```
|
295
|
+
|
296
|
+
To use an interactive shell session instead, you can execute `heroku run bash`.
|
297
|
+
|
298
|
+
## Scale and Access the Application
|
299
|
+
|
300
|
+
Heroku runs application code using defined processes and [process types](procfile). New applications don't have a process type active by default. The following command scales your app up to one dyno, running the `web` process:
|
301
|
+
|
302
|
+
```term
|
303
|
+
:::>- $ heroku ps:scale web=1
|
304
|
+
```
|
305
|
+
|
306
|
+
Use the Heroku CLI’s `ps` command to display the state of all app dynos in the terminal:
|
307
|
+
|
308
|
+
```term
|
309
|
+
:::>> $ heroku ps
|
310
|
+
```
|
311
|
+
|
312
|
+
In this example, a single `web` process is running.
|
313
|
+
|
314
|
+
By default, apps use Eco dynos if you're subscribed to [Eco](eco-dyno-hours). Otherwise, it defaults to Basic dynos. The Eco dynos plan is shared across all Eco dynos in your account and is recommended if you plan on deploying many small apps to Heroku. Eco dynos sleep if they don't receive any traffic for half an hour. This sleep behavior causes a few seconds delay for the first request upon waking. Eco dynos consume from a monthly, account-level quota of [eco dyno hours](eco-dyno-hours). As long as you haven't exhausted the quota, your apps can continue to run.
|
315
|
+
|
316
|
+
To avoid dyno sleeping, upgrade to a Basic or higher dyno type as described in the [Dyno Types](dyno-types) article. Upgrading to at least Standard dynos also allows you to scale up to multiple dynos per process type.
|
317
|
+
|
318
|
+
To launch the app in the browser, run `heroku open`:
|
319
|
+
|
320
|
+
```term
|
321
|
+
:::>> $ heroku open
|
322
|
+
```
|
323
|
+
|
324
|
+
The browser displays the “Hello World” text. If it doesn't, or there's an error, [review and confirm the welcome page contents](#create-a-welcome-page).
|
325
|
+
|
326
|
+
Heroku provides a [default web URL](app-names-and-subdomains) for every application during development. When the application is ready for production, add a [custom domain](https://devcenter.heroku.com/articles/custom-domains).
|
327
|
+
|
328
|
+
## View Application Logs
|
329
|
+
|
330
|
+
The app logs are a valuable tool if the app is not performing correctly or generating errors.
|
331
|
+
|
332
|
+
View information about a running app using the Heroku CLI [logging command](logging), `heroku logs`. Here's example output:
|
333
|
+
|
334
|
+
```term
|
335
|
+
:::>> $ heroku logs
|
336
|
+
```
|
337
|
+
|
338
|
+
Append `-t`/`--tail` to the command to see a full, live stream of the app’s logs:
|
339
|
+
|
340
|
+
```term
|
341
|
+
$ heroku logs --tail
|
342
|
+
```
|
343
|
+
|
344
|
+
By default, Heroku stores 1500 lines of logs from your application, but the full log stream is available as a service. Several [add-on providers](https://elements.heroku.com/addons/#logging) have logging services that provide things such as log persistence, search, and email and SMS alerts.
|
345
|
+
|
346
|
+
## Optional Steps
|
347
|
+
|
348
|
+
### Use The Rails Console
|
349
|
+
|
350
|
+
Use the Heroku CLI `run` command to trigger [one-off dynos](one-off-dynos) to run scripts and applications only when necessary. Use the command to launch a Rails console process attached to the local terminal for experimenting in the app's environment:
|
351
|
+
|
352
|
+
```term
|
353
|
+
$ heroku run rails console
|
354
|
+
irb(main):001:0> puts 1+1
|
355
|
+
2
|
356
|
+
```
|
357
|
+
|
358
|
+
The `run bash` Heroku CLI command is also helpful for debugging. The command starts a new one-off dyno with an interactive bash session.
|
359
|
+
|
360
|
+
### Run Rake Commands
|
361
|
+
|
362
|
+
Run `rake` commands, such as `db:migrate`, using the `run` command exactly like the Rails console:
|
363
|
+
|
364
|
+
```term
|
365
|
+
$ heroku run rake db:migrate
|
366
|
+
```
|
367
|
+
|
368
|
+
### Use a Procfile locally
|
369
|
+
|
370
|
+
To use the `Procfile` locally, use the `heroku local` CLI command.
|
371
|
+
|
372
|
+
In addition to running commands in the `Procfile`, the `heroku local` command can also manage environment variables locally through a `.env` file. Set `RACK_ENV` to `development` for the local environment and the `PORT` for Puma.
|
373
|
+
|
374
|
+
```term
|
375
|
+
:::>> $ echo "RACK_ENV=development" >>.env
|
376
|
+
:::>> $ echo "PORT=3000" >> .env
|
377
|
+
```
|
378
|
+
|
379
|
+
>note
|
380
|
+
> Another alternative to using environment variables locally with a `.env` file is the [dotenv](https://github.com/bkeepers/dotenv) gem.
|
381
|
+
|
382
|
+
Add `.env` to `.gitignore` as these variables are for local environment setup only.
|
383
|
+
|
384
|
+
```term
|
385
|
+
:::>- $ echo ".env" >> .gitignore
|
386
|
+
:::>- $ git add .gitignore
|
387
|
+
:::>- $ git commit -m "add .env to .gitignore"
|
388
|
+
```
|
389
|
+
|
390
|
+
Test the Procfile locally using [Foreman](heroku-local#run-your-app-locally-using-foreman). Start the web server with `local`:
|
391
|
+
|
392
|
+
```term
|
393
|
+
:::>> background.start("heroku local", name: "local", wait: "Ctrl-C to stop", timeout: 15)
|
394
|
+
:::-- background.stop(name: "local")
|
395
|
+
```
|
396
|
+
|
397
|
+
Press `Ctrl+C` or `Cmd+C` to exit.
|
398
|
+
|
399
|
+
## Troubleshooting
|
400
|
+
|
401
|
+
If an app deployed to Heroku crashes, for example, `heroku ps` shows the state `crashed`, review the app’s logs. The following section covers common causes of app crashes.
|
402
|
+
|
403
|
+
### Runtime Dependencies on Development or Test Gems
|
404
|
+
|
405
|
+
If a gem is missing during deployment, check the Bundler groups. Heroku builds apps without the `development` or `test` groups, and if the app depends on a gem from one of these groups to run, move it out of the group.
|
406
|
+
|
407
|
+
A common example is using the RSpec tasks in the `Rakefile`. The error often looks like this:
|
408
|
+
|
409
|
+
```term
|
410
|
+
$ heroku run rake -T
|
411
|
+
Running `bundle exec rake -T` attached to terminal... up, ps.3
|
412
|
+
rake aborted!
|
413
|
+
no such file to load -- rspec/core/rake_task
|
414
|
+
```
|
415
|
+
First, duplicate the problem locally by running `bundle install` without the development or test gem groups:
|
416
|
+
|
417
|
+
```term
|
418
|
+
$ bundle install --without development:test
|
419
|
+
…
|
420
|
+
$ bundle exec rake -T
|
421
|
+
rake aborted!
|
422
|
+
no such file to load -- rspec/core/rake_task
|
423
|
+
```
|
424
|
+
|
425
|
+
>note
|
426
|
+
>The `--without` option on `bundler` is persistent. To remove this option, run `bundle config --delete without`.
|
427
|
+
|
428
|
+
Fix the error by making these Rake tasks conditional during gem load. For example:
|
429
|
+
|
430
|
+
```ruby
|
431
|
+
begin
|
432
|
+
require "rspec/core/rake_task"
|
433
|
+
|
434
|
+
desc "Run all examples"
|
435
|
+
|
436
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
437
|
+
t.rspec_opts = %w[--color]
|
438
|
+
t.pattern = 'spec/**/*_spec.rb'
|
439
|
+
end
|
440
|
+
rescue LoadError
|
441
|
+
end
|
442
|
+
```
|
443
|
+
|
444
|
+
Confirm it works locally, then push it to Heroku.
|
445
|
+
|
446
|
+
## Next Steps
|
447
|
+
|
448
|
+
Congratulations on deploying a Rails 8 application! To continue exploring, review the following articles next:
|
449
|
+
|
450
|
+
* Visit the [Ruby support category](/categories/ruby-support) to learn more about using Ruby and Rails on Heroku.
|
451
|
+
* The [Deployment category](/categories/deployment) provides a variety of powerful integrations and features to help streamline and simplify your deployments.
|
452
|
+
|
453
|
+
>note
|
454
|
+
>Remember to [delete your example app](https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-apps-destroy), and [database](https://devcenter.heroku.com/articles/heroku-postgresql#removing-the-add-on) as soon as you're done with the tutorial, to control costs.
|
455
|
+
|
456
|
+
## Delete Your App and Add-on
|
457
|
+
|
458
|
+
Remove the app and database from your account. You're only charged for the resources you used.
|
459
|
+
|
460
|
+
>warning
|
461
|
+
>This action removes your add-on and any data saved in the database.
|
462
|
+
|
463
|
+
```term
|
464
|
+
$ heroku addons:destroy heroku-postgresql
|
465
|
+
```
|
466
|
+
|
467
|
+
>warning
|
468
|
+
>This action permanently deletes your application
|
469
|
+
|
470
|
+
```term
|
471
|
+
$ heroku apps:destroy
|
472
|
+
```
|
473
|
+
|
474
|
+
You can confirm that your add-on and app are gone with these commands:
|
475
|
+
|
476
|
+
```term
|
477
|
+
$ heroku addons --all
|
478
|
+
$ heroku apps --all
|
479
|
+
```
|
480
|
+
|
481
|
+
You're now ready to <a href= "https://devcenter.heroku.com/articles/preparing-a-codebase-for-heroku-deployment" target= "_blank">deploy your app</a>.
|
@@ -25,7 +25,7 @@ class IntegrationWebsiteTest < Minitest::Test
|
|
25
25
|
)
|
26
26
|
actual = parsed.to_md.gsub(Rundoc::CodeSection::AUTOGEN_WARNING, "")
|
27
27
|
|
28
|
-
expected = "![Screenshot of
|
28
|
+
expected = "![Screenshot of https://example.com/](screenshots/screenshot_1.png)"
|
29
29
|
assert_equal expected, actual.strip
|
30
30
|
|
31
31
|
assert screenshot_1_path.exist?
|
data/test/system/exe_cli_test.rb
CHANGED
@@ -132,7 +132,7 @@ class SystemsCliTest < Minitest::Test
|
|
132
132
|
readme = dir.join(SUCCESS_DIRNAME).join("README.md").read
|
133
133
|
actual = strip_autogen_warning(readme)
|
134
134
|
|
135
|
-
expected = "![Screenshot of
|
135
|
+
expected = "![Screenshot of https://example.com/](#{screenshots_dirname}/screenshot_1.png)"
|
136
136
|
assert_equal expected, actual.strip
|
137
137
|
end
|
138
138
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rundoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- test/fixtures/rails_5/rundoc.md
|
256
256
|
- test/fixtures/rails_6/rundoc.md
|
257
257
|
- test/fixtures/rails_7/rundoc.md
|
258
|
+
- test/fixtures/rails_8/rundoc.md
|
258
259
|
- test/fixtures/require/dependency/rundoc.md
|
259
260
|
- test/fixtures/require/main/rundoc.md
|
260
261
|
- test/fixtures/screenshot/rundoc.md
|
@@ -296,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
296
297
|
- !ruby/object:Gem::Version
|
297
298
|
version: '0'
|
298
299
|
requirements: []
|
299
|
-
rubygems_version: 3.5.
|
300
|
+
rubygems_version: 3.5.23
|
300
301
|
signing_key:
|
301
302
|
specification_version: 4
|
302
303
|
summary: RunDOC generates runable code from docs
|