Skip to content

Commit fc989cf

Browse files
committed
Add documentation for script management feature
Update markdown link to a subsection Update playground demo video
1 parent 30eed45 commit fc989cf

File tree

3 files changed

+79
-9
lines changed

3 files changed

+79
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
/test/dummy/log/*.log
99
/test/dummy/storage/
1010
/test/dummy/tmp/
11+
/test/dummy/lib/playground/personal/
1112
node_modules

README.md

+62-9
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,38 @@
22

33
Back-and-forths from your editor and your rails console is a thing of the past!
44

5-
![CleanShot 2022-03-12 at 23 41 03](https://user-images.githubusercontent.com/7149034/158014859-47625c95-aa59-489a-9681-eb36e378dcba.gif)
5+
![playground-demo](https://user-images.githubusercontent.com/7149034/158045230-3129bf4e-8eeb-4096-9293-04a8c6003bed.gif)
66

7-
Inspired by the Go playground and SQL Server Management Studio (SSMS) Query Editor, `rails-playground` is a rails engine that eases experiments with your application domain.
7+
## Features
8+
9+
### Query Editor
810

9-
In addition to a web console, `rails-playground` comes with a script management feature to help your personal and team development. It allows you to:
11+
Inspired by the Go playground and SQL Server Management Studio (SSMS) Query Editor, `rails-playground` is a rails engine that eases experiments with your application domain.
1012

11-
* use and save gitignored scripts for personal use.
12-
* use and save version-controller scripts with your team.
13+
### Script Management
1314

14-
This way, shared scripts stay close to the code and more maintainable while your personal script do not pollute the git history.
15+
The gem also comes with a script management tool to help share useful scripts with your teamates. Shared scripts stay close to the code and become more maintainable while personal scripts are git ignored and don't pollute the git history.
1516

1617
## Usage
1718

19+
### Query Editor
20+
1821
There are three ways to run ruby code in the console:
1922

2023
* Select your code in the editor and press cmd+Enter
2124
* Put your cursor on any line (no selection) and press cmd+Enter
2225
* Type your code straight in the terminal box just like in a rails console
2326

27+
### Script Management
28+
29+
Any files under `lib/playground` folder will appear in the sidebar. You can filter them by name from the search input.
30+
31+
See [Ignoring personal scripts](#ignoring-personal-scripts) to share scripts with your team while ignoring personal scripts.
32+
2433
## Installation
2534

35+
### Query Editor
36+
2637
Playground is built on top of `web-console` gem. Just like `web-console`, it's only meant to be used in development. Every `web-console` information still holds true for `rails-playground`. Check `web-console` [repository for more information](https://github.com/rails/web-console)
2738

2839
Add this line to your application's Gemfile under the development group:
@@ -33,14 +44,14 @@ group :development do
3344
end
3445
```
3546

36-
_**Naming issue:** The gem was originally supposed to be called `playground` but it already exists in RubyGems... Thus the gem is now called `rails-playground` but the functionality remains under the `playground` namespace for now._
47+
_**Naming issue:** The gem was originally called `playground` but it already exists in RubyGems... Thus the gem is now called `rails-playground` but the functionality remains under the `playground` namespace for now._
3748

3849
And then execute:
3950
```bash
4051
$ bundle
4152
```
4253

43-
Finally mount the engine in your routes file and access the playground at `http://localhost:{PORT}/playground` on your local machine.
54+
Finally mount the engine in your routes file and access the web playground at `/playground` on your local host.
4455

4556
```ruby
4657
Rails.application.routes.draw do
@@ -49,7 +60,49 @@ Rails.application.routes.draw do
4960
end
5061
```
5162

52-
_You can choose any relative path and switch from `/playground` to `/rails/play` for example._
63+
_Nothing stops you from choosing any relative path. For example you could switch from `/playground` to `/rails/play`._
64+
65+
### Ignoring personal scripts
66+
67+
Adding a folder from lib/playground in `.gitignore` will still show in the sidebar.
68+
**Decide on a convention** with your teamates and commit the path to your `.gitignore`.
69+
Unlike any other scripts, any changes made to ignored scripts won't be recorded in your git history.
70+
71+
**Example**
72+
73+
Here is an example of file structure
74+
75+
* scripts version controlled
76+
* lib/playground/shared_script_a.rb
77+
* lib/playground/shared_script_b.rb
78+
* lib/playground/namespace/shared_script_c.rb
79+
* scripts ignored
80+
* lib/playground/my_scripts/my_script_a.rb
81+
* lib/playground/my_scripts/my_script_b.rb
82+
83+
```
84+
.gitignore
85+
86+
/lib/playground/my_scripts/
87+
```
88+
89+
```
90+
my_app/
91+
├─ app/
92+
├─ bin/
93+
├─ config/
94+
├─ db/
95+
├─ lib/
96+
│ ├─ playground/
97+
│ │ ├─ namespace/
98+
│ │ │ ├─ shared_script_c.rb
99+
│ │ ├─ my_scripts/
100+
│ │ │ ├─ my_script_a.rb
101+
│ │ │ ├─ my_script_b.rb
102+
│ │ ├─ shared_script_a.rb
103+
│ │ ├─ shared_script_b.rb
104+
├─ .gitignore
105+
```
53106

54107
## Troubleshouting
55108

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Access your application domain as if you were in a rails console.
2+
# There are three ways to run code in the console:
3+
4+
# 1 - Select all the code from line 5 to 11 and press cmd+Enter
5+
module HelloWorld
6+
module_function
7+
8+
def hello
9+
"Hello, World!"
10+
end
11+
end
12+
13+
# 2 - Put your cursor on line 14 (no selection) and press cmd+Enter
14+
HelloWorld.hello
15+
16+
# 3 - Type "HelloWorld.hello" in the terminal box below and press cmd+Enter

0 commit comments

Comments
 (0)