rundoc 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +8 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -0
- data/README.md +63 -15
- data/bin/rundoc +8 -0
- data/lib/rundoc.rb +14 -1
- data/lib/rundoc/code_command.rb +18 -4
- data/lib/rundoc/code_command/background.rb +9 -0
- data/lib/rundoc/code_command/background/log/clear.rb +17 -0
- data/lib/rundoc/code_command/background/log/read.rb +16 -0
- data/lib/rundoc/code_command/background/process_spawn.rb +70 -0
- data/lib/rundoc/code_command/background/start.rb +36 -0
- data/lib/rundoc/code_command/background/stop.rb +17 -0
- data/lib/rundoc/code_command/background/wait.rb +19 -0
- data/lib/rundoc/code_command/bash.rb +1 -1
- data/lib/rundoc/code_command/bash/cd.rb +1 -1
- data/lib/rundoc/code_command/file_command/append.rb +2 -0
- data/lib/rundoc/code_command/raw.rb +18 -0
- data/lib/rundoc/code_command/rundoc_command.rb +2 -1
- data/lib/rundoc/code_section.rb +21 -74
- data/lib/rundoc/peg_parser.rb +282 -0
- data/lib/rundoc/version.rb +1 -1
- data/rundoc.gemspec +2 -1
- data/test/fixtures/rails_5/rundoc.md +70 -74
- data/test/rundoc/code_commands/append_file_test.rb +2 -2
- data/test/rundoc/code_commands/background_test.rb +43 -0
- data/test/rundoc/code_commands/bash_test.rb +1 -1
- data/test/rundoc/code_commands/pipe_test.rb +1 -1
- data/test/rundoc/code_commands/remove_contents_test.rb +1 -1
- data/test/rundoc/code_section_test.rb +6 -5
- data/test/rundoc/parser_test.rb +2 -7
- data/test/rundoc/peg_parser_test.rb +348 -0
- data/test/rundoc/regex_test.rb +1 -1
- data/test/rundoc/test_parse_java.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +33 -4
data/lib/rundoc/version.rb
CHANGED
data/rundoc.gemspec
CHANGED
@@ -20,9 +20,10 @@ 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'
|
23
24
|
|
24
25
|
gem.add_development_dependency "rake"
|
25
26
|
gem.add_development_dependency "mocha"
|
26
|
-
gem.add_development_dependency "
|
27
|
+
gem.add_development_dependency "minitest"
|
27
28
|
end
|
28
29
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
```
|
2
|
-
|
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
|
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.5.3'"
|
22
|
+
```
|
19
23
|
|
20
24
|
For this guide you will need:
|
21
25
|
|
22
|
-
- Basic Ruby/Rails
|
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
|
30
|
+
## Local setup
|
28
31
|
|
29
|
-
Install the [Heroku
|
32
|
+
Install the [Heroku CLI](heroku-cli#download-and-install) on your development machine.
|
30
33
|
|
31
|
-
Once installed,
|
32
|
-
|
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,33 @@ Generating new SSH public key.
|
|
44
44
|
Uploading ssh public key /Users/adam/.ssh/id_rsa.pub
|
45
45
|
```
|
46
46
|
|
47
|
-
Press
|
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
|
-
|
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
|
-
|
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
56
|
:::>> $ gem install rails --no-ri --no-rdoc
|
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
|
-
|
62
|
+
:::>- $ rails new myapp --database=postgresql
|
64
63
|
```
|
65
64
|
|
66
65
|
Then move into your application directory.
|
67
66
|
|
68
67
|
```term
|
69
|
-
|
68
|
+
:::>- $ cd myapp
|
70
69
|
```
|
71
70
|
|
72
|
-
|
71
|
+
## Add the pg gem
|
73
72
|
|
74
|
-
|
75
|
-
|
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:
|
73
|
+
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
74
|
|
78
75
|
```ruby
|
79
76
|
gem 'sqlite3'
|
@@ -85,7 +82,7 @@ To this:
|
|
85
82
|
gem 'pg'
|
86
83
|
```
|
87
84
|
|
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](
|
85
|
+
> 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
86
|
|
90
87
|
Now re-install your dependencies (to generate a new `Gemfile.lock`):
|
91
88
|
|
@@ -93,11 +90,9 @@ Now re-install your dependencies (to generate a new `Gemfile.lock`):
|
|
93
90
|
$ bundle install
|
94
91
|
```
|
95
92
|
|
96
|
-
|
97
|
-
|
98
|
-
In addition to using the `pg` gem, you'll also need to ensure the `config/database.yml` is using the `postgresql` adapter.
|
93
|
+
For more information on why Postgres is recommended instead of Sqlite3, see [why you cannot use Sqlite3 on Heroku](sqlite3).
|
99
94
|
|
100
|
-
The development section of your `config/database.yml` file should look something like this:
|
95
|
+
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
96
|
|
102
97
|
```term
|
103
98
|
:::>> $ cat config/database.yml
|
@@ -105,15 +100,15 @@ The development section of your `config/database.yml` file should look something
|
|
105
100
|
|
106
101
|
Be careful here. If you omit the `sql` at the end of `postgresql` in the `adapter` section, your application will not work.
|
107
102
|
|
108
|
-
##
|
103
|
+
## Create a welcome page
|
109
104
|
|
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:
|
105
|
+
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
106
|
|
112
107
|
```term
|
113
|
-
|
108
|
+
:::>- $ rails generate controller welcome
|
114
109
|
```
|
115
110
|
|
116
|
-
Next we'll add an index page
|
111
|
+
Next we'll add an index page:
|
117
112
|
|
118
113
|
```html
|
119
114
|
:::>> file.write app/views/welcome/index.html.erb
|
@@ -133,14 +128,16 @@ Now we need to make Rails route to this action. We'll edit `config/routes.rb` to
|
|
133
128
|
You can verify that the page is there by running your server:
|
134
129
|
|
135
130
|
```term
|
136
|
-
|
131
|
+
:::>> background.start("rails server", name: "server")
|
132
|
+
:::-- background.stop(name: "server")
|
137
133
|
```
|
138
134
|
|
139
135
|
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
136
|
|
141
137
|
## Heroku gems
|
142
138
|
|
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:
|
139
|
+
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:
|
140
|
+
|
144
141
|
|
145
142
|
```ruby
|
146
143
|
# config/environments/production.rb
|
@@ -153,13 +150,15 @@ if ENV["RAILS_LOG_TO_STDOUT"].present?
|
|
153
150
|
end
|
154
151
|
```
|
155
152
|
|
156
|
-
## Specify Ruby version
|
153
|
+
## Specify your Ruby version
|
154
|
+
|
155
|
+
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
156
|
|
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
157
|
|
160
158
|
```ruby
|
161
|
-
|
162
|
-
|
159
|
+
:::-- $ sed -i'' -e '/^ruby/d' ./Gemfile
|
160
|
+
:::-> file.append Gemfile#4
|
161
|
+
ruby "2.5.3"
|
163
162
|
```
|
164
163
|
|
165
164
|
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 +168,11 @@ You should also be running the same version of Ruby locally. You can check this
|
|
169
168
|
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
169
|
|
171
170
|
```term
|
172
|
-
|
171
|
+
:::>- $ git --help
|
173
172
|
:::>> | $ head -n 5
|
174
173
|
```
|
175
174
|
|
176
|
-
If you don't see any output or get `command not found` you
|
175
|
+
If you don't see any output or get `command not found` you need to install Git on your system.
|
177
176
|
|
178
177
|
Once you've verified that Git works, first make sure you are in your Rails app directory by running `$ ls`:
|
179
178
|
|
@@ -186,9 +185,9 @@ The output should look like this:
|
|
186
185
|
Now run these commands in your Rails app directory to initialize and commit your code to Git:
|
187
186
|
|
188
187
|
```term
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
:::>- $ git init
|
189
|
+
:::>- $ git add .
|
190
|
+
:::>- $ git commit -m "init"
|
192
191
|
```
|
193
192
|
|
194
193
|
You can verify everything was committed correctly by running:
|
@@ -213,7 +212,7 @@ You can verify that the remote was added to your project by running:
|
|
213
212
|
:::>> $ git config --list | grep heroku
|
214
213
|
```
|
215
214
|
|
216
|
-
If you see `fatal: not in a git directory` then you are likely not in the correct directory. Otherwise you
|
215
|
+
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
216
|
|
218
217
|
Deploy your code:
|
219
218
|
|
@@ -225,13 +224,13 @@ It is always a good idea to check to see if there are any warnings or errors in
|
|
225
224
|
|
226
225
|
## Migrate your database
|
227
226
|
|
228
|
-
If you are using the database in your application you need to manually migrate the database by running:
|
227
|
+
If you are using the database in your application, you need to manually migrate the database by running:
|
229
228
|
|
230
229
|
```term
|
231
230
|
$ heroku run rake db:migrate
|
232
231
|
```
|
233
232
|
|
234
|
-
Any commands after the `heroku run`
|
233
|
+
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
234
|
|
236
235
|
## Visit your application
|
237
236
|
|
@@ -240,7 +239,7 @@ You've deployed your code to Heroku. You can now instruct Heroku to execute a pr
|
|
240
239
|
Let's ensure we have one dyno running the `web` process type:
|
241
240
|
|
242
241
|
```term
|
243
|
-
|
242
|
+
:::>- $ heroku ps:scale web=1
|
244
243
|
```
|
245
244
|
|
246
245
|
You can check the state of the app's dynos. The `heroku ps` command lists the running dynos of your application:
|
@@ -261,7 +260,7 @@ You should now see the "Hello World" text we inserted above.
|
|
261
260
|
|
262
261
|
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
262
|
|
264
|
-
## View
|
263
|
+
## View logs
|
265
264
|
|
266
265
|
If you run into any problems getting your app to perform properly, you will need to check the logs.
|
267
266
|
|
@@ -279,11 +278,11 @@ $ heroku logs --tail
|
|
279
278
|
|
280
279
|
## Dyno sleeping and scaling
|
281
280
|
|
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](
|
281
|
+
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
282
|
|
284
283
|
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
284
|
|
286
|
-
## Rails console
|
285
|
+
## Run the Rails console
|
287
286
|
|
288
287
|
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
288
|
|
@@ -295,7 +294,7 @@ irb(main):001:0> puts 1+1
|
|
295
294
|
|
296
295
|
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
296
|
|
298
|
-
## Rake
|
297
|
+
## Run Rake commands
|
299
298
|
|
300
299
|
Rake can be run as an attached process exactly like the console:
|
301
300
|
|
@@ -303,7 +302,7 @@ Rake can be run as an attached process exactly like the console:
|
|
303
302
|
$ heroku run rake db:migrate
|
304
303
|
```
|
305
304
|
|
306
|
-
##
|
305
|
+
## Configure your webserver
|
307
306
|
|
308
307
|
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
308
|
|
@@ -314,14 +313,14 @@ gem 'puma'
|
|
314
313
|
Then run
|
315
314
|
|
316
315
|
```term
|
317
|
-
|
316
|
+
:::>- $ bundle install
|
318
317
|
```
|
319
318
|
|
320
319
|
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
320
|
|
322
321
|
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
322
|
|
324
|
-
### Procfile
|
323
|
+
### Create a Procfile
|
325
324
|
|
326
325
|
Change the command used to launch your web process by creating a file called [Procfile](procfile) and entering this:
|
327
326
|
|
@@ -330,11 +329,11 @@ Change the command used to launch your web process by creating a file called [Pr
|
|
330
329
|
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
|
331
330
|
```
|
332
331
|
|
333
|
-
> Note:
|
332
|
+
> Note: This file must be named `Procfile` exactly.
|
334
333
|
|
335
334
|
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
335
|
|
337
|
-
To use the Procfile locally you can use `heroku local`.
|
336
|
+
To use the Procfile locally, you can use `heroku local`.
|
338
337
|
|
339
338
|
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
339
|
|
@@ -348,30 +347,24 @@ In addition to running commands in your `Procfile` `heroku local` can also help
|
|
348
347
|
You'll also want to add `.env` to your `.gitignore` since this is for local environment setup.
|
349
348
|
|
350
349
|
```term
|
351
|
-
|
352
|
-
|
353
|
-
|
350
|
+
:::>- $ echo ".env" >> .gitignore
|
351
|
+
:::>- $ git add .gitignore
|
352
|
+
:::>- $ git commit -m "add .env to .gitignore"
|
354
353
|
```
|
355
354
|
|
356
355
|
Test your Procfile locally using Foreman. You can now start your web server by running:
|
357
356
|
|
358
357
|
```term
|
359
|
-
|
360
|
-
|
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
|
358
|
+
:::>> background.start("heroku local", name: "local", wait: "Ctrl-C to stop")
|
359
|
+
:::-- background.stop(name: "local")
|
367
360
|
```
|
368
361
|
|
369
362
|
Looks good, so press `Ctrl+C` to exit and you can deploy your changes to Heroku:
|
370
363
|
|
371
364
|
```term
|
372
|
-
|
373
|
-
|
374
|
-
|
365
|
+
:::>- $ git add .
|
366
|
+
:::>- $ git commit -m "use puma via procfile"
|
367
|
+
:::>- $ git push heroku master
|
375
368
|
```
|
376
369
|
|
377
370
|
Check `ps`. You'll see that the web process uses your new command specifying Puma as the web server.
|
@@ -390,7 +383,7 @@ $ heroku logs
|
|
390
383
|
|
391
384
|
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
385
|
|
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](
|
386
|
+
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
387
|
|
395
388
|
## Troubleshooting
|
396
389
|
|
@@ -438,6 +431,9 @@ end
|
|
438
431
|
|
439
432
|
Confirm it works locally, then push to Heroku.
|
440
433
|
|
441
|
-
##
|
434
|
+
## Next steps
|
435
|
+
|
436
|
+
Congratulations! You have deployed your first Rails 5 application to Heroku. Here's some recommended reading:
|
442
437
|
|
443
|
-
|
438
|
+
* Visit the [Ruby support category](/categories/ruby-support) to learn more about using Ruby and Rails on Heroku.
|
439
|
+
* The [Deployment category](/categories/deployment) provides a variety of powerful integrations and features to help streamline and simplify your deployments.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class AppendFileTest < Test
|
3
|
+
class AppendFileTest < Minitest::Test
|
4
4
|
|
5
5
|
def test_appends_to_a_file
|
6
6
|
Dir.mktmpdir do |dir|
|
@@ -71,7 +71,7 @@ gem 'rails', '4.0.0'
|
|
71
71
|
Dir.chdir(dir) do
|
72
72
|
FileUtils.touch("file-1234.txt")
|
73
73
|
FileUtils.touch("file-5678.txt")
|
74
|
-
|
74
|
+
assert_raises do
|
75
75
|
cc = Rundoc::CodeCommand::FileCommand::Append.new("file-*.txt")
|
76
76
|
cc << "some text"
|
77
77
|
cc.call
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BackgroundTest < Minitest::Test
|
4
|
+
def test_background_start
|
5
|
+
Dir.mktmpdir do |dir|
|
6
|
+
Dir.chdir(dir) do
|
7
|
+
|
8
|
+
file = "foo.txt"
|
9
|
+
`echo 'foo' >> #{file}`
|
10
|
+
|
11
|
+
background_start = Rundoc::CodeCommand::Background::Start.new("tail -f #{file}",
|
12
|
+
name: "tail",
|
13
|
+
wait: "f"
|
14
|
+
)
|
15
|
+
output = background_start.call
|
16
|
+
|
17
|
+
assert_match("foo", output)
|
18
|
+
assert_equal(true, background_start.alive?)
|
19
|
+
|
20
|
+
log_read = Rundoc::CodeCommand::Background::Log::Read.new(name: "tail")
|
21
|
+
output = log_read.call
|
22
|
+
|
23
|
+
assert_equal("foo", output.chomp)
|
24
|
+
|
25
|
+
log_clear = Rundoc::CodeCommand::Background::Log::Clear.new(name: "tail")
|
26
|
+
output = log_clear.call
|
27
|
+
assert_equal("", output)
|
28
|
+
|
29
|
+
`echo 'bar' >> #{file}`
|
30
|
+
|
31
|
+
log_read = Rundoc::CodeCommand::Background::Log::Read.new(name: "tail")
|
32
|
+
output = log_read.call
|
33
|
+
|
34
|
+
assert_equal("bar", output.chomp)
|
35
|
+
|
36
|
+
background_stop = Rundoc::CodeCommand::Background::Stop.new(name: "tail")
|
37
|
+
background_stop.call
|
38
|
+
|
39
|
+
assert_equal(false, background_start.alive?)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|