leg 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +34 -0
- data/LICENSE +21 -0
- data/README.md +59 -0
- data/Rakefile +11 -0
- data/TUTORIAL.md +243 -0
- data/bin/console +9 -0
- data/bin/setup +6 -0
- data/exe/leg +6 -0
- data/leg.gemspec +31 -0
- data/lib/leg.rb +27 -0
- data/lib/leg/cli.rb +42 -0
- data/lib/leg/commands.rb +19 -0
- data/lib/leg/commands/amend.rb +49 -0
- data/lib/leg/commands/base_command.rb +99 -0
- data/lib/leg/commands/build.rb +126 -0
- data/lib/leg/commands/commit.rb +48 -0
- data/lib/leg/commands/diff.rb +29 -0
- data/lib/leg/commands/help.rb +43 -0
- data/lib/leg/commands/init.rb +46 -0
- data/lib/leg/commands/reset.rb +26 -0
- data/lib/leg/commands/resolve.rb +31 -0
- data/lib/leg/commands/save.rb +31 -0
- data/lib/leg/commands/status.rb +54 -0
- data/lib/leg/commands/step.rb +31 -0
- data/lib/leg/config.rb +42 -0
- data/lib/leg/default_templates.rb +340 -0
- data/lib/leg/diff.rb +151 -0
- data/lib/leg/diff_transformers.rb +11 -0
- data/lib/leg/diff_transformers/base_transformer.rb +13 -0
- data/lib/leg/diff_transformers/fold_sections.rb +89 -0
- data/lib/leg/diff_transformers/omit_adjacent_removals.rb +38 -0
- data/lib/leg/diff_transformers/syntax_highlight.rb +32 -0
- data/lib/leg/diff_transformers/trim_blank_lines.rb +25 -0
- data/lib/leg/line.rb +83 -0
- data/lib/leg/markdown.rb +20 -0
- data/lib/leg/page.rb +27 -0
- data/lib/leg/representations.rb +9 -0
- data/lib/leg/representations/base_representation.rb +42 -0
- data/lib/leg/representations/git.rb +388 -0
- data/lib/leg/representations/litdiff.rb +85 -0
- data/lib/leg/step.rb +16 -0
- data/lib/leg/template.rb +95 -0
- data/lib/leg/tutorial.rb +49 -0
- data/lib/leg/version.rb +3 -0
- metadata +112 -38
- data/bin/leg +0 -9
- data/lib/snaptoken.rb +0 -24
- data/lib/snaptoken/cli.rb +0 -61
- data/lib/snaptoken/commands.rb +0 -13
- data/lib/snaptoken/commands/amend.rb +0 -27
- data/lib/snaptoken/commands/base_command.rb +0 -92
- data/lib/snaptoken/commands/build.rb +0 -107
- data/lib/snaptoken/commands/commit.rb +0 -27
- data/lib/snaptoken/commands/help.rb +0 -38
- data/lib/snaptoken/commands/resolve.rb +0 -27
- data/lib/snaptoken/commands/status.rb +0 -21
- data/lib/snaptoken/commands/step.rb +0 -35
- data/lib/snaptoken/default_templates.rb +0 -287
- data/lib/snaptoken/diff.rb +0 -180
- data/lib/snaptoken/diff_line.rb +0 -54
- data/lib/snaptoken/diff_transformers.rb +0 -9
- data/lib/snaptoken/diff_transformers/base_transformer.rb +0 -9
- data/lib/snaptoken/diff_transformers/fold_sections.rb +0 -85
- data/lib/snaptoken/diff_transformers/omit_adjacent_removals.rb +0 -28
- data/lib/snaptoken/diff_transformers/trim_blank_lines.rb +0 -21
- data/lib/snaptoken/markdown.rb +0 -18
- data/lib/snaptoken/page.rb +0 -64
- data/lib/snaptoken/representations.rb +0 -8
- data/lib/snaptoken/representations/base_representation.rb +0 -38
- data/lib/snaptoken/representations/git.rb +0 -262
- data/lib/snaptoken/representations/litdiff.rb +0 -81
- data/lib/snaptoken/step.rb +0 -27
- data/lib/snaptoken/template.rb +0 -53
- data/lib/snaptoken/tutorial.rb +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7834f53c386ef0659ed14743e180619f20998e8180ef0a0f995d87c976a30144
|
4
|
+
data.tar.gz: 841c12497eceedef73aac65e44ff1eab2c8cabf7ca38b4b6410fa0a67ed732e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b3eb5845cd13d9f8cff44029a6daf87125f0725fdc6a18aed4f6dda7a735f57eb824e0869b320cc3b007d3fc6380d476331fcac7265f0c734468d4648580677
|
7
|
+
data.tar.gz: 30e799503eb2f8ca49f6ca27063285077ce32841b32681d88e6dc9470e19065e2e4aa3cb48d7d1cd85f18393ede18deb06e054914289788b070858644ebed8b8
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at jeremy.ruten@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
leg (0.0.1)
|
5
|
+
redcarpet (= 3.4.0)
|
6
|
+
rouge (= 2.0.7)
|
7
|
+
rugged (= 0.27.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
coderay (1.1.2)
|
13
|
+
method_source (0.9.0)
|
14
|
+
minitest (5.11.3)
|
15
|
+
pry (0.11.3)
|
16
|
+
coderay (~> 1.1.0)
|
17
|
+
method_source (~> 0.9.0)
|
18
|
+
rake (10.5.0)
|
19
|
+
redcarpet (3.4.0)
|
20
|
+
rouge (2.0.7)
|
21
|
+
rugged (0.27.2)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
bundler (~> 1.16)
|
28
|
+
leg!
|
29
|
+
minitest (~> 5.0)
|
30
|
+
pry
|
31
|
+
rake (~> 10.0)
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
1.16.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jeremy Ruten
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# leg
|
2
|
+
|
3
|
+
Command line tool that helps you make step-by-step programming walkthroughs.
|
4
|
+
|
5
|
+
**NOTE:** This project is in a *very* unstable state at the moment. If you really want to use the last "stable" version of this project, head over to the [`snaptoken`](https://github.com/yjerem/leg/tree/snaptoken) branch. (Just know that it will be replaced by a completely new tool and file format in the near future.)
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
$ gem install leg
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
See the [tutorial](TUTORIAL.md)!
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
# Leg
|
18
|
+
|
19
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/leg`. To experiment with that code, run `bin/console` for an interactive prompt.
|
20
|
+
|
21
|
+
TODO: Delete this and the text above, and describe your gem
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'leg'
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
$ bundle
|
34
|
+
|
35
|
+
Or install it yourself as:
|
36
|
+
|
37
|
+
$ gem install leg
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
TODO: Write usage instructions here
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
46
|
+
|
47
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yjerem/leg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
56
|
+
|
57
|
+
## Code of Conduct
|
58
|
+
|
59
|
+
Everyone interacting in the Leg project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yjerem/leg/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/TUTORIAL.md
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
# Creating a step-by-step programming tutorial with `leg`
|
2
|
+
|
3
|
+
Install `leg` (you'll need Ruby for this):
|
4
|
+
|
5
|
+
```sh
|
6
|
+
$ gem install leg
|
7
|
+
```
|
8
|
+
|
9
|
+
Create a project folder for your tutorial, `cd` into it, and run `leg init`.
|
10
|
+
|
11
|
+
```sh
|
12
|
+
$ cd ~/projects
|
13
|
+
$ mkdir fizzbuzz-tutorial
|
14
|
+
$ cd fizzbuzz-tutorial
|
15
|
+
$ leg init
|
16
|
+
```
|
17
|
+
|
18
|
+
This creates two folders: `doc/`, where you will write the text of your
|
19
|
+
tutorial, and `step/`, which is a "working directory" that you will use to
|
20
|
+
write and modify the actual code steps of your tutorial.
|
21
|
+
|
22
|
+
(Also, a hidden `.leg/` directory is created which marks your project folder as
|
23
|
+
the root of a `leg` tutorial. This is used by `leg` internally, so you don't
|
24
|
+
have to worry about it.)
|
25
|
+
|
26
|
+
Create a file in the `step/` folder called `fizzbuzz.js`, with the following
|
27
|
+
contents:
|
28
|
+
|
29
|
+
```js
|
30
|
+
var n = 1;
|
31
|
+
while (n <= 100) {
|
32
|
+
console.log(n);
|
33
|
+
n++;
|
34
|
+
}
|
35
|
+
```
|
36
|
+
|
37
|
+
Save it, and then run `leg commit`. Congratulations, you have created your
|
38
|
+
first step! Now open `step/fizzbuzz.js` again, and modify it like so:
|
39
|
+
|
40
|
+
```js
|
41
|
+
var n = 1;
|
42
|
+
while (n <= 100) {
|
43
|
+
if (n % 3 == 0) {
|
44
|
+
console.log("Fizz");
|
45
|
+
} else {
|
46
|
+
console.log(n);
|
47
|
+
}
|
48
|
+
n++;
|
49
|
+
}
|
50
|
+
```
|
51
|
+
|
52
|
+
Save it, and then run `leg commit`. Your tutorial now has 2 steps!
|
53
|
+
|
54
|
+
## Rendering the tutorial
|
55
|
+
|
56
|
+
Run the `leg build` command to build the tutorial into a nice HTML page. Open
|
57
|
+
`build/html/tutorial.html` in your web browser to see the result.
|
58
|
+
|
59
|
+
You can add text in between the steps of your tutorial by simply adding
|
60
|
+
(Markdown-formatted) text to `doc/tutorial.litdiff`. For example:
|
61
|
+
|
62
|
+
```diff
|
63
|
+
# My FizzBuzz Tutorial
|
64
|
+
|
65
|
+
Hello! This is a step-by-step tutorial that teaches you how to write your own
|
66
|
+
[FizzBuzz](http://wiki.c2.com/?FizzBuzzTest).
|
67
|
+
|
68
|
+
The first thing to do is to write a `while` loop.
|
69
|
+
|
70
|
+
~~~ Loop through numbers 1 to 100
|
71
|
+
--- /dev/null
|
72
|
+
+++ b/fizzbuzz.js
|
73
|
+
@@ -0,0 +1,5 @@
|
74
|
+
+var n = 1;
|
75
|
+
+while (n <= 100) {
|
76
|
+
+ console.log(n);
|
77
|
+
+ n++;
|
78
|
+
+}
|
79
|
+
|
80
|
+
Now that we have our `while` loop, with the base case of printing out each
|
81
|
+
number, we can start handling special cases. We'll start with handling "Fizz".
|
82
|
+
|
83
|
+
~~~ Print "Fizz" for multiples of 3
|
84
|
+
--- a/fizzbuzz.js
|
85
|
+
+++ b/fizzbuzz.js
|
86
|
+
@@ -1,5 +1,9 @@
|
87
|
+
|var n = 1;
|
88
|
+
|while (n <= 100) {
|
89
|
+
- console.log(n);
|
90
|
+
+ if (n % 3 == 0) {
|
91
|
+
+ console.log("Fizz");
|
92
|
+
+ } else {
|
93
|
+
+ console.log(n);
|
94
|
+
+ }
|
95
|
+
| n++;
|
96
|
+
|}
|
97
|
+
```
|
98
|
+
|
99
|
+
## Adding the rest of the steps
|
100
|
+
|
101
|
+
```js
|
102
|
+
var n = 1;
|
103
|
+
while (n <= 100) {
|
104
|
+
if (n % 3 == 0) {
|
105
|
+
console.log("Fizz");
|
106
|
+
} else if (n % 5 == 0) {
|
107
|
+
console.log("Buzz");
|
108
|
+
} else {
|
109
|
+
console.log(n);
|
110
|
+
}
|
111
|
+
n++;
|
112
|
+
}
|
113
|
+
```
|
114
|
+
|
115
|
+
```js
|
116
|
+
var n = 1;
|
117
|
+
while (n <= 100) {
|
118
|
+
if (n % 3 == 0) {
|
119
|
+
console.log("Fizz");
|
120
|
+
} else if (n % 5 == 0) {
|
121
|
+
console.log("Buzz");
|
122
|
+
} else {
|
123
|
+
console.log(n);
|
124
|
+
}
|
125
|
+
n++;
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
129
|
+
```js
|
130
|
+
var n = 1;
|
131
|
+
while (n <= 100) {
|
132
|
+
if (n % 3 == 0) {
|
133
|
+
console.log("Fizz");
|
134
|
+
} else if (n % 5 == 0) {
|
135
|
+
console.log("Buzz");
|
136
|
+
} else if (n % 15 == 0) {
|
137
|
+
console.log("FizzBuzz");
|
138
|
+
} else {
|
139
|
+
console.log(n);
|
140
|
+
}
|
141
|
+
n++;
|
142
|
+
}
|
143
|
+
```
|
144
|
+
|
145
|
+
## Amending a step
|
146
|
+
|
147
|
+
Oops, that last step we committed has a bug! Let's fix that. In
|
148
|
+
`step/fizzbuzz.js`, move the `n % 15` case above the other two cases:
|
149
|
+
|
150
|
+
```js
|
151
|
+
var n = 1;
|
152
|
+
while (n <= 100) {
|
153
|
+
if (n % 15 == 0) {
|
154
|
+
console.log("FizzBuzz");
|
155
|
+
} else if (n % 3 == 0) {
|
156
|
+
console.log("Fizz");
|
157
|
+
} else if (n % 5 == 0) {
|
158
|
+
console.log("Buzz");
|
159
|
+
} else {
|
160
|
+
console.log(n);
|
161
|
+
}
|
162
|
+
n++;
|
163
|
+
}
|
164
|
+
```
|
165
|
+
|
166
|
+
Now run the `leg amend` command, and it will overwrite the step you committed
|
167
|
+
with this new code.
|
168
|
+
|
169
|
+
## Resolving conflicts
|
170
|
+
|
171
|
+
Let's try something a little more challenging. Let's say we want to rewrite our
|
172
|
+
steps to use a `for` loop instead of a `while` loop. That means going back and
|
173
|
+
amending the first step of our tutorial.
|
174
|
+
|
175
|
+
We can do that by running `leg 1` to checkout the first step of the tutorial
|
176
|
+
into the `step/` folder. Then modify `step/fizzbuzz.js` to look like this:
|
177
|
+
|
178
|
+
```js
|
179
|
+
for (var n = 1; n <= 100; n++) {
|
180
|
+
console.log(n);
|
181
|
+
}
|
182
|
+
```
|
183
|
+
|
184
|
+
Now run `leg amend`. `leg` will try to apply the change you just made to all
|
185
|
+
the steps that come after it. Often, with large files, it can do this
|
186
|
+
automatically. But sometimes you will have to resolve merge conflicts manually.
|
187
|
+
|
188
|
+
In this case, after running `leg amend`, you will get a message saying that you
|
189
|
+
need to resolve a merge conflict with step 2. To resolve the conflict, open
|
190
|
+
`step/fizzbuzz.js` and resolve it by hand, or use a merge tool. The final
|
191
|
+
result should look like this:
|
192
|
+
|
193
|
+
```js
|
194
|
+
for (var n = 1; n <= 100; n++) {
|
195
|
+
if (n % 3 == 0) {
|
196
|
+
console.log("Fizz");
|
197
|
+
} else {
|
198
|
+
console.log(n);
|
199
|
+
}
|
200
|
+
}
|
201
|
+
```
|
202
|
+
|
203
|
+
When the conflict is resolved and you've saved `step/fizzbuzz.js`, run
|
204
|
+
`leg resolve` to continue.
|
205
|
+
|
206
|
+
## Inserting steps
|
207
|
+
|
208
|
+
So far, whenever we've run `leg commit` we've been adding steps to the end of
|
209
|
+
our tutorial. We can also insert commits in the middle of our tutorial by
|
210
|
+
running `leg <step-number>`, making changes, and running `leg commit`. This
|
211
|
+
will add step(s) *after* the given `<step-number>`.
|
212
|
+
|
213
|
+
For example, let's add a step after step 1 that prints out a welcome message at
|
214
|
+
the beginning of the program. First, run `leg 1`. This checks out step 1 into
|
215
|
+
the `step/` folder. Now modify `step/fizzbuzz.js` thusly:
|
216
|
+
|
217
|
+
```js
|
218
|
+
console.log("Welcome to fizzbuzz!");
|
219
|
+
|
220
|
+
for (var n = 1; n <= 100; n++) {
|
221
|
+
console.log(n);
|
222
|
+
}
|
223
|
+
```
|
224
|
+
|
225
|
+
Save the file and run `leg commit`. A new step 2 will be inserted and all the
|
226
|
+
steps afterward will be bumped up one. Note that there may be conflicts that
|
227
|
+
need to be resolved, as is always possible when making changes to past steps.
|
228
|
+
|
229
|
+
## Splitting a step into multiple steps
|
230
|
+
|
231
|
+
(The example here will be splitting the `n % 15` step into a step that does
|
232
|
+
`n % 3 == 0 && n % 5 == 0` and then a step that simplifies that to `n % 15`.
|
233
|
+
And maybe I'll think of a third step it can be split into...)
|
234
|
+
|
235
|
+
## Reording steps
|
236
|
+
|
237
|
+
(Here we'll try moving the welcome message step to the end of the tutorial.)
|
238
|
+
|
239
|
+
## Squashing multiple steps into a single step
|
240
|
+
|
241
|
+
(I guess here we'll undo the splitting into steps of `n % 15` that we did
|
242
|
+
earlier, for lack of any better ideas.)
|
243
|
+
|