Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 35 lines (27 sloc) 1.829 kb
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
1 # Modifying the boot process
2
9f67290 Albert Wang Fix links in docs/ruby/modifying.md
albertyw authored
3 Running `zeus init` creates a default [`zeus.json`](../../examples/custom_plan/zeus.json) and [`custom_plan.rb`](../../examples/custom_plan/custom_plan.rb) that define the boot order for your application.
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
4
9f67290 Albert Wang Fix links in docs/ruby/modifying.md
albertyw authored
5 Each node under "plan" in the JSON file has an action associated with it. You can see the "command" value at the top of the hash requires `"./custom_plan.rb"`. Inspecting that file, you can see that it creates an empty subclass of `Zeus::Rails`. If you look at [that file](../../rubygem/lib/zeus/rails.rb), you will see a class with a method name corresponding to each node -- something along the lines of:
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
6
7 ```ruby
8 class Zeus::Rails < Zeus::Plan
9 def boot
10 # ...
11 end
12 def default_bundle
13 # ...
14 end
15 # ...
16 end
17 ```
18
028e009 Burke Libbey Updated documentation a bit.
authored
19 Note that an instance of the subclass class is assigned to `Zeus.plan` at the end of `custom_plan.rb`. Zeus calls methods on `Zeus.plan` to boot the application. If you follow any path to a leaf node in the tree -- for example, boot, default_bundle, development_environment, prerake -- those methods are essentially called in sequence to construct an environment for a command (rake, in this case) to run in. Zeus forks the ruby process between each step, and can restart from any of these forks.
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
20
028e009 Burke Libbey Updated documentation a bit.
authored
21 You can modify the plan by adding/removing/moving nodes in the json file and adding the corresponding methods in `custom_plan.rb`.
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
22
23 ```ruby
028e009 Burke Libbey Updated documentation a bit.
authored
24 # custom_plan.rb
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
25 require 'zeus/rails'
028e009 Burke Libbey Updated documentation a bit.
authored
26 class CustomPlan < Zeus::Rails
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
27 def boot
28 something_else
29 end
30 end
028e009 Burke Libbey Updated documentation a bit.
authored
31 Zeus.plan = CustomPlan.new
4e063d2 Burke Libbey Started ruby docs and fixed up Plan stuff a bit
authored
32 ```
33
028e009 Burke Libbey Updated documentation a bit.
authored
34 Note that there's nothing special about the naming or location of `CustomPlan`. Feel free to rename and/or move as you please, just remember to update the `command` line in `zeus.json` -- and `zeus.json` must stay at your project root, or Zeus will just use the default configuration.
Something went wrong with that request. Please try again.