rundoc 0.0.2 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/check_changelog.yml +13 -0
  3. data/.gitignore +7 -0
  4. data/.travis.yml +8 -0
  5. data/CHANGELOG.md +26 -0
  6. data/Dockerfile +24 -0
  7. data/Gemfile +1 -0
  8. data/README.md +261 -92
  9. data/bin/rundoc +4 -60
  10. data/lib/rundoc.rb +15 -1
  11. data/lib/rundoc/cli.rb +84 -0
  12. data/lib/rundoc/code_command.rb +20 -5
  13. data/lib/rundoc/code_command/background.rb +9 -0
  14. data/lib/rundoc/code_command/background/log/clear.rb +17 -0
  15. data/lib/rundoc/code_command/background/log/read.rb +16 -0
  16. data/lib/rundoc/code_command/background/process_spawn.rb +96 -0
  17. data/lib/rundoc/code_command/background/start.rb +38 -0
  18. data/lib/rundoc/code_command/background/stop.rb +17 -0
  19. data/lib/rundoc/code_command/background/wait.rb +19 -0
  20. data/lib/rundoc/code_command/bash.rb +1 -1
  21. data/lib/rundoc/code_command/bash/cd.rb +21 -3
  22. data/lib/rundoc/code_command/file_command/append.rb +2 -0
  23. data/lib/rundoc/code_command/no_such_command.rb +4 -0
  24. data/lib/rundoc/code_command/pipe.rb +17 -4
  25. data/lib/rundoc/code_command/raw.rb +18 -0
  26. data/lib/rundoc/code_command/rundoc/depend_on.rb +37 -0
  27. data/lib/rundoc/code_command/rundoc/require.rb +41 -0
  28. data/lib/rundoc/code_command/rundoc_command.rb +6 -2
  29. data/lib/rundoc/code_command/website.rb +7 -0
  30. data/lib/rundoc/code_command/website/driver.rb +111 -0
  31. data/lib/rundoc/code_command/website/navigate.rb +29 -0
  32. data/lib/rundoc/code_command/website/screenshot.rb +28 -0
  33. data/lib/rundoc/code_command/website/visit.rb +47 -0
  34. data/lib/rundoc/code_section.rb +34 -78
  35. data/lib/rundoc/parser.rb +4 -3
  36. data/lib/rundoc/peg_parser.rb +282 -0
  37. data/lib/rundoc/version.rb +1 -1
  38. data/rundoc.gemspec +9 -3
  39. data/test/fixtures/build_logs/rundoc.md +56 -0
  40. data/test/fixtures/depend_on/dependency/rundoc.md +5 -0
  41. data/test/fixtures/depend_on/main/rundoc.md +10 -0
  42. data/test/fixtures/java/rundoc.md +9 -0
  43. data/test/fixtures/rails_4/rundoc.md +1 -1
  44. data/test/fixtures/rails_5/rundoc.md +76 -74
  45. data/test/fixtures/{rails_5_beta → rails_6}/rundoc.md +93 -87
  46. data/test/fixtures/require/dependency/rundoc.md +5 -0
  47. data/test/fixtures/require/main/rundoc.md +10 -0
  48. data/test/fixtures/screenshot/rundoc.md +10 -0
  49. data/test/rundoc/code_commands/append_file_test.rb +2 -2
  50. data/test/rundoc/code_commands/background_test.rb +69 -0
  51. data/test/rundoc/code_commands/bash_test.rb +1 -1
  52. data/test/rundoc/code_commands/pipe_test.rb +12 -2
  53. data/test/rundoc/code_commands/remove_contents_test.rb +1 -1
  54. data/test/rundoc/code_section_test.rb +6 -5
  55. data/test/rundoc/parser_test.rb +2 -8
  56. data/test/rundoc/peg_parser_test.rb +391 -0
  57. data/test/rundoc/regex_test.rb +1 -1
  58. data/test/rundoc/test_parse_java.rb +1 -1
  59. data/test/test_helper.rb +1 -1
  60. metadata +120 -12
@@ -1,3 +1,3 @@
1
1
  module Rundoc
2
- VERSION = "0.0.2"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Rundoc::VERSION
9
9
  gem.authors = ["Richard Schneeman"]
10
10
  gem.email = ["richard.schneeman+rubygems@gmail.com"]
11
- gem.description = %q{runDOC turns docs to runable code}
12
- gem.summary = %q{runDOC generates runable code from docs}
11
+ gem.description = %q{RunDOC turns docs to runable code}
12
+ gem.summary = %q{RunDOC generates runable code from docs}
13
13
  gem.homepage = "https://github.com/schneems/rundoc"
14
14
  gem.license = "MIT"
15
15
 
@@ -20,9 +20,15 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_dependency "thor"
22
22
  gem.add_dependency "repl_runner"
23
+ gem.add_dependency 'parslet', '~> 1'
24
+ gem.add_dependency 'capybara', '~> 3'
25
+ gem.add_dependency 'selenium-webdriver', '~> 3'
26
+
27
+ gem.add_dependency 'aws-sdk-s3', '~> 1'
28
+ gem.add_dependency 'dotenv'
23
29
 
24
30
  gem.add_development_dependency "rake"
25
31
  gem.add_development_dependency "mocha"
26
- gem.add_development_dependency "test-unit"
32
+ gem.add_development_dependency "minitest"
27
33
  end
28
34
 
@@ -0,0 +1,56 @@
1
+ Logs produced while building your application (deploying) are separated from your [runtime logs](https://devcenter.heroku.com/articles/logging#log-retrieval). The build logs for failed and successful deploys are available via the dashboard of the application.
2
+
3
+ ```
4
+ :::-- $ touch Gemfile
5
+ :::-- $ bundle _1.15.2_ install
6
+ :::-- $ git init && git add . && git commit -m first
7
+ :::-- $ heroku create
8
+ :::-- $ git push heroku master
9
+ ```
10
+
11
+ To view your build logs, first visit the dashboard for the application (`https://dashboard.heroku.com/apps/<app-name>`):
12
+
13
+ ```
14
+ :::>> website.visit(name: "dashboard", url: "https://dashboard.heroku.com", visible: true)
15
+
16
+ while current_url != "https://dashboard.heroku.com/apps"
17
+ puts "waiting for successful login: #{current_url}"
18
+ sleep 1
19
+ end
20
+
21
+ git_url = `git config --get remote.heroku.url`.chomp
22
+ app_name = git_url.split("/").last.gsub(".git", "")
23
+ session.visit "https://dashboard.heroku.com/apps/#{app_name}"
24
+ sleep 2
25
+
26
+ email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`
27
+ session.execute_script %Q{$("span:contains(#{email}").html('developer@example.com')}
28
+
29
+ :::>> website.screenshot(name: "dashboard", upload: "s3")
30
+ ```
31
+
32
+ Next click on the "Activity" tab:
33
+
34
+ ```
35
+ :::>> website.nav(name: "dashboard")
36
+ session.first(:link, "Activity").click
37
+ sleep 2
38
+
39
+ email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`
40
+ session.execute_script %Q{$("span:contains(#{email}").html('developer@example.com')}
41
+
42
+ :::>> website.screenshot(name: "dashboard", upload: "s3")
43
+ ```
44
+
45
+ From here you can click on "View build log" to see your most recent build:
46
+
47
+ ```
48
+ :::>> website.nav(name: "dashboard")
49
+ session.first(:link, "View build log").click
50
+ sleep 2
51
+
52
+ email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`
53
+ session.execute_script %Q{$("span:contains(#{email}").html('developer@example.com')}
54
+
55
+ :::>> website.screenshot(name: "dashboard", upload: "s3")
56
+ ```
@@ -0,0 +1,5 @@
1
+ ```
2
+ :::>> $ mkdir foo
3
+ :::>> $ cd foo
4
+ :::>> $ echo "hello" >> hello.txt
5
+ ```
@@ -0,0 +1,10 @@
1
+ # Hello
2
+
3
+ ```
4
+ :::-- rundoc.depend_on "../dependency/rundoc.md"
5
+ ```
6
+
7
+ ```
8
+ :::>> $ ruby -e "raise 'nope' unless File.read('hello.txt').chomp == 'hello'"
9
+ ```
10
+
@@ -0,0 +1,9 @@
1
+
2
+ Hello
3
+
4
+ ```
5
+ :::>- $ git clone https://github.com/heroku/java-getting-started
6
+ :::>- $ cd java-getting-started
7
+ ```
8
+
9
+ world
@@ -56,7 +56,7 @@ Press enter at the prompt to upload your existing `ssh` key or create a new one,
56
56
  You may be starting from an existing app, if so [upgrade to Rails 4](http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-3-2-to-rails-4-0) before continuing. If not, a vanilla Rails 4 app will serve as a suitable sample app. To build a new app make sure that you're using the Rails 4.x using `$ rails -v`. You can get the new version of rails by running,
57
57
 
58
58
  ```term
59
- :::>> $ gem install rails -v 4.2.9 --no-ri --no-rdoc
59
+ :::>> $ gem install rails -v 4.2.9 --no-document
60
60
  ```
61
61
 
62
62
  Note: There may be a [more recent version of Rails](https://rubygems.org/gems/rails/versions) available, we recommend always running the latest. You may want to [run Rails 5 on Heroku](https://devcenter.heroku.com/articles/getting-started-with-rails5).
@@ -1,5 +1,5 @@
1
1
  ```
2
- :::- rundoc
2
+ :::-- rundoc
3
3
  email = ENV['HEROKU_EMAIL'] || `heroku auth:whoami`
4
4
 
5
5
  Rundoc.configure do |config|
@@ -15,27 +15,27 @@ end
15
15
  $ bin/rundoc build --path test/fixtures/rails_5/rundoc.md
16
16
  -->
17
17
 
18
- Ruby on Rails is a popular web framework written in [Ruby](http://www.ruby-lang.org/). This guide covers using Rails 5 on Heroku. For information about running previous versions of Rails on Heroku, see [Getting Started with Rails 4.x on Heroku](getting-started-with-rails4) or [Getting Started with Rails 3.x on Heroku](getting-started-with-rails3).
18
+ Ruby on Rails is a popular web framework written in [Ruby](http://www.ruby-lang.org/). This guide covers using Rails 5 on Heroku. For information on running previous versions of Rails on Heroku, see the tutorial for [Rails 4.x](getting-started-with-rails4) or [Rails 3.x](getting-started-with-rails3).
19
+
20
+ ```
21
+ :::-- $ ruby -e "exit 1 unless RUBY_VERSION == '2.6.3'"
22
+ ```
19
23
 
20
24
  For this guide you will need:
21
25
 
22
- - Basic Ruby/Rails knowledge.
23
- - A locally installed version of Ruby 2.2.0+, Rubygems, Bundler, and Rails 5+.
24
- - Basic Git knowledge.
26
+ - Basic familiarity with Ruby/Rails and Git
27
+ - A locally installed version of Ruby 2.2.0+, Rubygems, Bundler, and Rails 5+
25
28
  - A Heroku user account: [Signup is free and instant](https://signup.heroku.com/devcenter).
26
29
 
27
- ## Local workstation setup
28
-
29
- Install the [Heroku Toolbelt](https://toolbelt.heroku.com/) on your local workstation. This ensures that you have access to the [Heroku command-line client](/categories/command-line), Heroku Local, and the Git revision control system. You will also need [Ruby and Rails installed](http://guides.railsgirls.com/install).
30
+ ## Local setup
30
31
 
31
- Once installed, you'll have access to the `$ heroku` command from your command shell. Log in using the email address and password you used when creating your Heroku account:
32
+ Install the [Heroku CLI](heroku-cli#download-and-install) on your development machine.
32
33
 
33
-
34
- > callout Note that `$` symbol before commands indicates they should be run on the command line, prompt, or terminal with appropriate permissions. Do not copy the `$` symbol.
34
+ Once installed, the `heroku` command is available from your terminal. Log in using your Heroku account's email address and password:
35
35
 
36
36
  ```term
37
37
  $ heroku login
38
- Enter your Heroku credentials.
38
+ heroku: Enter your Heroku credentials
39
39
  Email: schneems@example.com
40
40
  Password:
41
41
  Could not find an existing public key.
@@ -44,36 +44,39 @@ Generating new SSH public key.
44
44
  Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
45
45
  ```
46
46
 
47
- Press enter at the prompt to upload your existing `ssh` key or create a new one, used for pushing code later on.
48
-
49
- ## Write your app
47
+ Press Enter at the prompt to upload your existing `ssh` key or create a new one, used for pushing code later on.
50
48
 
51
- > callout To run on Heroku, your app must be configured to use the Postgres database, have all dependencies declared in your `Gemfile`.
49
+ ## Create a new Rails app (or upgrade an existing one)
52
50
 
51
+ If you are starting with an existing app that uses a previous version of Rails, [upgrade it to Rails 5](http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-4-2-to-rails-5-0) before continuing. If you're not starting from an existing app at all, a vanilla Rails 5 app works great as a sample app.
53
52
 
54
- If you are starting from an existing app, [upgrade to Rails 5](http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-4-2-to-rails-5-0) before continuing. If not, a vanilla Rails 5 app will serve as a suitable sample app. To build a new app make sure that you're using the Rails 5.x using `$ rails -v`. You can get the new version of rails by running,
53
+ To create a new app, first make sure that you're using Rails 5.x by running `rails -v`. If necessary, you can get the new version of rails by running the following:
55
54
 
56
55
  ```term
57
- :::>> $ gem install rails --no-ri --no-rdoc
56
+ :::>> $ gem install rails --no-document
58
57
  ```
59
58
 
60
- Then create a new app:
59
+ Then create a new app and move into its root directory:
61
60
 
62
61
  ```term
63
- :::> $ rails new myapp --database=postgresql
62
+ :::>- $ rails new myapp --database=postgresql
64
63
  ```
65
64
 
66
65
  Then move into your application directory.
67
66
 
68
67
  ```term
69
- :::> $ cd myapp
68
+ :::>- $ cd myapp
70
69
  ```
71
70
 
72
- > callout If you experience problems or get stuck with this tutorial, your questions may be answered in a later part of this document. If you experience a problem, try reading through the entire document and then go back to your issue. It can also be useful to review your previous steps to ensure they all executed correctly.
71
+ Create a database locally:
73
72
 
74
- ## Database
73
+ ```
74
+ :::>> $ bin/rake db:create
75
+ ```
76
+
77
+ ## Add the pg gem
75
78
 
76
- If you already have an app that was created without specifying `--database=postgresql` you will need to add the `pg` gem to your Rails project. Edit your `Gemfile` and change this line:
79
+ If you're using an existing app that was created without specifying `--database=postgresql`, you need to add the `pg` gem to your Rails project. Edit your `Gemfile` and change this line:
77
80
 
78
81
  ```ruby
79
82
  gem 'sqlite3'
@@ -85,7 +88,7 @@ To this:
85
88
  gem 'pg'
86
89
  ```
87
90
 
88
- > callout We highly recommend using PostgreSQL during development. Maintaining [parity between your development](http://www.12factor.net/dev-prod-parity) and deployment environments prevents subtle bugs from being introduced because of differences between your environments. [Install Postgres locally](https://devcenter.heroku.com/articles/heroku-postgresql#local-setup) now if it is not already on your system.
91
+ > callout We highly recommend using PostgreSQL during development. Maintaining [parity between your development](http://www.12factor.net/dev-prod-parity) and deployment environments prevents subtle bugs from being introduced because of differences between your environments. [Install Postgres locally](heroku-postgresql#local-setup) now if it is not already on your system.
89
92
 
90
93
  Now re-install your dependencies (to generate a new `Gemfile.lock`):
91
94
 
@@ -93,11 +96,9 @@ Now re-install your dependencies (to generate a new `Gemfile.lock`):
93
96
  $ bundle install
94
97
  ```
95
98
 
96
- To get more information on why this change is needed and how to configure your app to run Postgres locally, see [why you cannot use Sqlite3 on Heroku](https://devcenter.heroku.com/articles/sqlite3).
97
-
98
- In addition to using the `pg` gem, you'll also need to ensure the `config/database.yml` is using the `postgresql` adapter.
99
+ For more information on why Postgres is recommended instead of Sqlite3, see [why you cannot use Sqlite3 on Heroku](sqlite3).
99
100
 
100
- The development section of your `config/database.yml` file should look something like this:
101
+ In addition to using the `pg` gem, ensure that your `config/database.yml` file is using the `postgresql` adapter. The development section of your `config/database.yml` file should look something like this:
101
102
 
102
103
  ```term
103
104
  :::>> $ cat config/database.yml
@@ -105,15 +106,15 @@ The development section of your `config/database.yml` file should look something
105
106
 
106
107
  Be careful here. If you omit the `sql` at the end of `postgresql` in the `adapter` section, your application will not work.
107
108
 
108
- ## Welcome page
109
+ ## Create a welcome page
109
110
 
110
- Rails 5 no longer has a static index page in production. When you're using a new app, there will not be a root page in production, so we need to create one. We will first create a controller called `welcome` for our home page to live:
111
+ Rails 5 no longer has a static index page in production by default. When you're using a new app, there will not be a root page in production, so we need to create one. We will first create a controller called `welcome` for our home page to live:
111
112
 
112
113
  ```term
113
- :::> $ rails generate controller welcome
114
+ :::>- $ rails generate controller welcome
114
115
  ```
115
116
 
116
- Next we'll add an index page.
117
+ Next we'll add an index page:
117
118
 
118
119
  ```html
119
120
  :::>> file.write app/views/welcome/index.html.erb
@@ -133,14 +134,16 @@ Now we need to make Rails route to this action. We'll edit `config/routes.rb` to
133
134
  You can verify that the page is there by running your server:
134
135
 
135
136
  ```term
136
- $ rails server
137
+ :::>> background.start("rails server", name: "server")
138
+ :::-- background.stop(name: "server")
137
139
  ```
138
140
 
139
141
  And visiting [http://localhost:3000](http://localhost:3000) in your browser. If you do not see the page, [use the logs](#view-the-logs) that are output to your server to debug.
140
142
 
141
143
  ## Heroku gems
142
144
 
143
- Previous versions of Rails required you to add a gem to your project [rails_12factor](https://github.com/heroku/rails_12factor) to enable static asset serving and logging on Heroku. If you are deploying a new application this gem is not needed. If you are upgrading an existing application you can remove this gem provided you have the apprpriate configuration in your `config/environments/production.rb` file:
145
+ Previous versions of Rails required you to add a gem to your project [rails_12factor](https://github.com/heroku/rails_12factor) to enable static asset serving and logging on Heroku. If you are deploying a new application, this gem is not needed. If you are upgrading an existing application, you can remove this gem provided you have the apprpriate configuration in your `config/environments/production.rb` file:
146
+
144
147
 
145
148
  ```ruby
146
149
  # config/environments/production.rb
@@ -153,13 +156,15 @@ if ENV["RAILS_LOG_TO_STDOUT"].present?
153
156
  end
154
157
  ```
155
158
 
156
- ## Specify Ruby version in app
159
+ ## Specify your Ruby version
160
+
161
+ Rails 5 requires Ruby 2.2.0 or above. Heroku has a recent version of Ruby installed by default, however you can specify an exact version by using the `ruby` DSL in your `Gemfile`. Depending on your version of Ruby that you are currently running it might look like this:
157
162
 
158
- Rails 5 requires Ruby 2.2.0 or above. Heroku has a recent version of Ruby installed by default, however you can specify an exact version by using the `ruby` DSL in your `Gemfile`.
159
163
 
160
164
  ```ruby
161
- :::>> file.append Gemfile
162
- ruby "2.4.1"
165
+ :::-- $ sed -i'' -e '/^ruby/d' ./Gemfile
166
+ :::-> file.append Gemfile#4
167
+ ruby "2.6.3"
163
168
  ```
164
169
 
165
170
  You should also be running the same version of Ruby locally. You can check this by running `$ ruby -v`. You can get more information on [specifying your Ruby version on Heroku here](https://devcenter.heroku.com/articles/ruby-versions).
@@ -169,11 +174,11 @@ You should also be running the same version of Ruby locally. You can check this
169
174
  Heroku relies on [Git](http://git-scm.com/), a distributed source control management tool, for deploying your project. If your project is not already in Git, first verify that `git` is on your system:
170
175
 
171
176
  ```term
172
- :::> $ git --help
177
+ :::>- $ git --help
173
178
  :::>> | $ head -n 5
174
179
  ```
175
180
 
176
- If you don't see any output or get `command not found` you will need to install it on your system. Verify that the [Heroku toolbelt](https://toolbelt.heroku.com/) is installed.
181
+ If you don't see any output or get `command not found` you need to install Git on your system.
177
182
 
178
183
  Once you've verified that Git works, first make sure you are in your Rails app directory by running `$ ls`:
179
184
 
@@ -186,9 +191,9 @@ The output should look like this:
186
191
  Now run these commands in your Rails app directory to initialize and commit your code to Git:
187
192
 
188
193
  ```term
189
- :::> $ git init
190
- :::> $ git add .
191
- :::> $ git commit -m "init"
194
+ :::>- $ git init
195
+ :::>- $ git add .
196
+ :::>- $ git commit -m "init"
192
197
  ```
193
198
 
194
199
  You can verify everything was committed correctly by running:
@@ -213,7 +218,7 @@ You can verify that the remote was added to your project by running:
213
218
  :::>> $ git config --list | grep heroku
214
219
  ```
215
220
 
216
- If you see `fatal: not in a git directory` then you are likely not in the correct directory. Otherwise you may deploy your code. After you deploy your code, you will need to migrate your database, make sure it is properly scaled, and use logs to debug any issues that come up.
221
+ If you see `fatal: not in a git directory` then you are likely not in the correct directory. Otherwise you can deploy your code. After you deploy your code, you need to migrate your database, make sure it is properly scaled, and use logs to debug any issues that come up.
217
222
 
218
223
  Deploy your code:
219
224
 
@@ -225,13 +230,13 @@ It is always a good idea to check to see if there are any warnings or errors in
225
230
 
226
231
  ## Migrate your database
227
232
 
228
- If you are using the database in your application you need to manually migrate the database by running:
233
+ If you are using the database in your application, you need to manually migrate the database by running:
229
234
 
230
235
  ```term
231
236
  $ heroku run rake db:migrate
232
237
  ```
233
238
 
234
- Any commands after the `heroku run` will be executed on a Heroku [dyno](dynos). You can obtain an interactive shell session by running `$ heroku run bash`.
239
+ Any commands after the `heroku run` are executed on a Heroku [dyno](dynos). You can obtain an interactive shell session by running `$ heroku run bash`.
235
240
 
236
241
  ## Visit your application
237
242
 
@@ -240,7 +245,7 @@ You've deployed your code to Heroku. You can now instruct Heroku to execute a pr
240
245
  Let's ensure we have one dyno running the `web` process type:
241
246
 
242
247
  ```term
243
- :::> $ heroku ps:scale web=1
248
+ :::>- $ heroku ps:scale web=1
244
249
  ```
245
250
 
246
251
  You can check the state of the app's dynos. The `heroku ps` command lists the running dynos of your application:
@@ -261,7 +266,7 @@ You should now see the "Hello World" text we inserted above.
261
266
 
262
267
  Heroku gives you a default web URL for simplicity while you are developing. When you are ready to scale up and use Heroku for production you can add your own [custom domain](https://devcenter.heroku.com/articles/custom-domains).
263
268
 
264
- ## View the logs
269
+ ## View logs
265
270
 
266
271
  If you run into any problems getting your app to perform properly, you will need to check the logs.
267
272
 
@@ -279,11 +284,11 @@ $ heroku logs --tail
279
284
 
280
285
  ## Dyno sleeping and scaling
281
286
 
282
- By default, new applications are deployed to a free dyno. Free apps will "sleep" to conserve resources. You can find more information about this behavior by reading about [free dyno behavior](https://devcenter.heroku.com/articles/free-dyno-hours).
287
+ By default, new applications are deployed to a free dyno. Free apps will "sleep" to conserve resources. You can find more information about this behavior by reading about [free dyno behavior](free-dyno-hours).
283
288
 
284
289
  To avoid dyno sleeping, you can upgrade to a hobby or professional dyno type as described in the [Dyno Types](dyno-types) article. For example, if you migrate your app to a professional dyno, you can easily scale it by running a command telling Heroku to execute a specific number of dynos, each running your web process type.
285
290
 
286
- ## Rails console
291
+ ## Run the Rails console
287
292
 
288
293
  Heroku allows you to run commands in a [one-off dyno](one-off-dynos) - scripts and applications that only need to be executed when needed - using the `heroku run` command. Use this to launch a Rails console process attached to your local terminal for experimenting in your app's environment:
289
294
 
@@ -295,7 +300,7 @@ irb(main):001:0> puts 1+1
295
300
 
296
301
  Another useful command for debugging is `$ heroku run bash` which will spin up a new dyno and give you access to a bash session.
297
302
 
298
- ## Rake
303
+ ## Run Rake commands
299
304
 
300
305
  Rake can be run as an attached process exactly like the console:
301
306
 
@@ -303,7 +308,7 @@ Rake can be run as an attached process exactly like the console:
303
308
  $ heroku run rake db:migrate
304
309
  ```
305
310
 
306
- ## Webserver
311
+ ## Configure your webserver
307
312
 
308
313
  By default, your app's web process runs `rails server`, which uses Puma in Rails 5. If you are upgrading an app you'll need to add `puma` to your application `Gemfile`:
309
314
 
@@ -314,14 +319,14 @@ gem 'puma'
314
319
  Then run
315
320
 
316
321
  ```term
317
- :::> $ bundle install
322
+ :::>- $ bundle install
318
323
  ```
319
324
 
320
325
  Now you are ready to configure your app to use Puma. For this tutorial we will use the default `config/puma.rb` of that ships with Rails 5, but we recommend reading more about configuring your application for maximum performance by [reading the Puma documentation](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server).
321
326
 
322
327
  Finally you will need to tell Heroku how to run your Rails app by creating a `Procfile` in the root of your application directory.
323
328
 
324
- ### Procfile
329
+ ### Create a Procfile
325
330
 
326
331
  Change the command used to launch your web process by creating a file called [Procfile](procfile) and entering this:
327
332
 
@@ -330,11 +335,11 @@ Change the command used to launch your web process by creating a file called [Pr
330
335
  web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
331
336
  ```
332
337
 
333
- > Note: The case of `Procfile` matters, the first letter must be uppercase.
338
+ > Note: This file must be named `Procfile` exactly.
334
339
 
335
340
  We recommend generating a Puma config file based on [our Puma documentation](https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server) for maximum performance.
336
341
 
337
- To use the Procfile locally you can use `heroku local`.
342
+ To use the Procfile locally, you can use `heroku local`.
338
343
 
339
344
  In addition to running commands in your `Procfile` `heroku local` can also help you manage environment variables locally through a `.env` file. Set the local `RACK_ENV` to development in your environment and a `PORT` to connect to. Before pushing to Heroku you'll want to test with the `RACK_ENV` set to production since this is the environment your Heroku app will run in.
340
345
 
@@ -348,30 +353,24 @@ In addition to running commands in your `Procfile` `heroku local` can also help
348
353
  You'll also want to add `.env` to your `.gitignore` since this is for local environment setup.
349
354
 
350
355
  ```term
351
- :::> $ echo ".env" >> .gitignore
352
- :::> $ git add .gitignore
353
- :::> $ git commit -m "add .env to .gitignore"
356
+ :::>- $ echo ".env" >> .gitignore
357
+ :::>- $ git add .gitignore
358
+ :::>- $ git commit -m "add .env to .gitignore"
354
359
  ```
355
360
 
356
361
  Test your Procfile locally using Foreman. You can now start your web server by running:
357
362
 
358
363
  ```term
359
- $ heroku local
360
- [OKAY] Loaded ENV .env File as KEY=VALUE Format
361
- 11:06:35 AM web.1 | [18878] Puma starting in cluster mode...
362
- 11:06:35 AM web.1 | [18878] * Version 3.8.2 (ruby 2.4.1-p111), codename: Sassy Salamander
363
- 11:06:35 AM web.1 | [18878] * Min threads: 5, max threads: 5
364
- 11:06:35 AM web.1 | [18878] * Environment: development
365
- 11:06:35 AM web.1 | [18878] * Process workers: 2
366
- 11:06:35 AM web.1 | [18878] * Preloading application
364
+ :::>> background.start("heroku local", name: "local", wait: "Ctrl-C to stop")
365
+ :::-- background.stop(name: "local")
367
366
  ```
368
367
 
369
368
  Looks good, so press `Ctrl+C` to exit and you can deploy your changes to Heroku:
370
369
 
371
370
  ```term
372
- :::> $ git add .
373
- :::> $ git commit -m "use puma via procfile"
374
- :::> $ git push heroku master
371
+ :::>- $ git add .
372
+ :::>- $ git commit -m "use puma via procfile"
373
+ :::>- $ git push heroku master
375
374
  ```
376
375
 
377
376
  Check `ps`. You'll see that the web process uses your new command specifying Puma as the web server.
@@ -390,7 +389,7 @@ $ heroku logs
390
389
 
391
390
  There are several options for invoking the [Rails asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) when deploying to Heroku. For general information on the asset pipeline please see the [Rails 3.1+ Asset Pipeline on Heroku Cedar](rails-asset-pipeline) article.
392
391
 
393
- The `config.assets.initialize_on_precompile` option has been removed is and not needed for Rails 5. Also, any failure in asset compilation will now cause the push to fail. For Rails 5 asset pipeline support see the [Ruby Support](https://devcenter.heroku.com/articles/ruby-support#rails-5-x-applications) page.
392
+ The `config.assets.initialize_on_precompile` option has been removed is and not needed for Rails 5. Also, any failure in asset compilation will now cause the push to fail. For Rails 5 asset pipeline support see the [Ruby Support](ruby-support#rails-5-x-applications) page.
394
393
 
395
394
  ## Troubleshooting
396
395
 
@@ -438,6 +437,9 @@ end
438
437
 
439
438
  Confirm it works locally, then push to Heroku.
440
439
 
441
- ## Done
440
+ ## Next steps
441
+
442
+ Congratulations! You have deployed your first Rails 5 application to Heroku. Here's some recommended reading:
442
443
 
443
- You have deployed your first application to Heroku. The next step is to deploy your own application. You can read more about Ruby on Heroku at the [Dev Center](https://devcenter.heroku.com/categories/ruby).
444
+ * Visit the [Ruby support category](/categories/ruby-support) to learn more about using Ruby and Rails on Heroku.
445
+ * The [Deployment category](/categories/deployment) provides a variety of powerful integrations and features to help streamline and simplify your deployments.