automate-it 0.9.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.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.hgignore +10 -0
  4. data/.loadpath +5 -0
  5. data/.project +17 -0
  6. data/CHANGES.txt +314 -0
  7. data/Hoe.rake +40 -0
  8. data/Manifest.txt +164 -0
  9. data/README.txt +40 -0
  10. data/Rakefile +256 -0
  11. data/TESTING.txt +57 -0
  12. data/TODO.txt +50 -0
  13. data/TUTORIAL.txt +391 -0
  14. data/automate-it.gemspec +25 -0
  15. data/bin/ai +3 -0
  16. data/bin/aifield +75 -0
  17. data/bin/aissh +93 -0
  18. data/bin/aitag +134 -0
  19. data/bin/automateit +133 -0
  20. data/docs/friendly_errors.txt +50 -0
  21. data/docs/previews.txt +86 -0
  22. data/examples/basic/Rakefile +26 -0
  23. data/examples/basic/config/automateit_env.rb +16 -0
  24. data/examples/basic/config/fields.yml +3 -0
  25. data/examples/basic/config/tags.yml +7 -0
  26. data/examples/basic/dist/README.txt +9 -0
  27. data/examples/basic/dist/myapp_server.erb +30 -0
  28. data/examples/basic/install.log +15 -0
  29. data/examples/basic/lib/README.txt +10 -0
  30. data/examples/basic/recipes/README.txt +4 -0
  31. data/examples/basic/recipes/install.rb +61 -0
  32. data/examples/basic/recipes/uninstall.rb +6 -0
  33. data/gpl.txt +674 -0
  34. data/helpers/cpan_wrapper.pl +220 -0
  35. data/helpers/which.cmd +7 -0
  36. data/lib/automateit.rb +55 -0
  37. data/lib/automateit/account_manager.rb +114 -0
  38. data/lib/automateit/account_manager/base.rb +138 -0
  39. data/lib/automateit/account_manager/etc.rb +128 -0
  40. data/lib/automateit/account_manager/nscd.rb +33 -0
  41. data/lib/automateit/account_manager/passwd_expect.rb +40 -0
  42. data/lib/automateit/account_manager/passwd_pty.rb +69 -0
  43. data/lib/automateit/account_manager/posix.rb +138 -0
  44. data/lib/automateit/address_manager.rb +88 -0
  45. data/lib/automateit/address_manager/base.rb +171 -0
  46. data/lib/automateit/address_manager/bsd.rb +28 -0
  47. data/lib/automateit/address_manager/freebsd.rb +59 -0
  48. data/lib/automateit/address_manager/linux.rb +42 -0
  49. data/lib/automateit/address_manager/openbsd.rb +66 -0
  50. data/lib/automateit/address_manager/portable.rb +37 -0
  51. data/lib/automateit/address_manager/sunos.rb +34 -0
  52. data/lib/automateit/cli.rb +85 -0
  53. data/lib/automateit/common.rb +65 -0
  54. data/lib/automateit/constants.rb +35 -0
  55. data/lib/automateit/download_manager.rb +48 -0
  56. data/lib/automateit/edit_manager.rb +321 -0
  57. data/lib/automateit/error.rb +10 -0
  58. data/lib/automateit/field_manager.rb +103 -0
  59. data/lib/automateit/interpreter.rb +631 -0
  60. data/lib/automateit/package_manager.rb +257 -0
  61. data/lib/automateit/package_manager/apt.rb +27 -0
  62. data/lib/automateit/package_manager/cpan.rb +101 -0
  63. data/lib/automateit/package_manager/dpkg.rb +54 -0
  64. data/lib/automateit/package_manager/egg.rb +64 -0
  65. data/lib/automateit/package_manager/gem.rb +201 -0
  66. data/lib/automateit/package_manager/pear.rb +95 -0
  67. data/lib/automateit/package_manager/pecl.rb +80 -0
  68. data/lib/automateit/package_manager/portage.rb +69 -0
  69. data/lib/automateit/package_manager/yum.rb +65 -0
  70. data/lib/automateit/platform_manager.rb +49 -0
  71. data/lib/automateit/platform_manager/darwin.rb +30 -0
  72. data/lib/automateit/platform_manager/debian.rb +26 -0
  73. data/lib/automateit/platform_manager/freebsd.rb +29 -0
  74. data/lib/automateit/platform_manager/gentoo.rb +26 -0
  75. data/lib/automateit/platform_manager/lsb.rb +44 -0
  76. data/lib/automateit/platform_manager/openbsd.rb +28 -0
  77. data/lib/automateit/platform_manager/struct.rb +80 -0
  78. data/lib/automateit/platform_manager/sunos.rb +39 -0
  79. data/lib/automateit/platform_manager/uname.rb +29 -0
  80. data/lib/automateit/platform_manager/windows.rb +40 -0
  81. data/lib/automateit/plugin.rb +7 -0
  82. data/lib/automateit/plugin/base.rb +32 -0
  83. data/lib/automateit/plugin/driver.rb +256 -0
  84. data/lib/automateit/plugin/manager.rb +224 -0
  85. data/lib/automateit/project.rb +493 -0
  86. data/lib/automateit/root.rb +17 -0
  87. data/lib/automateit/service_manager.rb +93 -0
  88. data/lib/automateit/service_manager/chkconfig.rb +39 -0
  89. data/lib/automateit/service_manager/rc_update.rb +37 -0
  90. data/lib/automateit/service_manager/sysv.rb +139 -0
  91. data/lib/automateit/service_manager/update_rcd.rb +35 -0
  92. data/lib/automateit/shell_manager.rb +316 -0
  93. data/lib/automateit/shell_manager/base_link.rb +67 -0
  94. data/lib/automateit/shell_manager/link.rb +24 -0
  95. data/lib/automateit/shell_manager/portable.rb +523 -0
  96. data/lib/automateit/shell_manager/symlink.rb +32 -0
  97. data/lib/automateit/shell_manager/which_base.rb +30 -0
  98. data/lib/automateit/shell_manager/which_unix.rb +16 -0
  99. data/lib/automateit/shell_manager/which_windows.rb +20 -0
  100. data/lib/automateit/tag_manager.rb +127 -0
  101. data/lib/automateit/tag_manager/struct.rb +121 -0
  102. data/lib/automateit/tag_manager/tag_parser.rb +93 -0
  103. data/lib/automateit/tag_manager/yaml.rb +29 -0
  104. data/lib/automateit/template_manager.rb +56 -0
  105. data/lib/automateit/template_manager/base.rb +181 -0
  106. data/lib/automateit/template_manager/erb.rb +17 -0
  107. data/lib/ext/metaclass.rb +17 -0
  108. data/lib/ext/object.rb +18 -0
  109. data/lib/ext/shell_escape.rb +7 -0
  110. data/lib/hashcache.rb +22 -0
  111. data/lib/helpful_erb.rb +63 -0
  112. data/lib/inactive_support.rb +53 -0
  113. data/lib/inactive_support/basic_object.rb +6 -0
  114. data/lib/inactive_support/clean_logger.rb +127 -0
  115. data/lib/inactive_support/core_ext/array/extract_options.rb +19 -0
  116. data/lib/inactive_support/core_ext/blank.rb +50 -0
  117. data/lib/inactive_support/core_ext/class/attribute_accessors.rb +48 -0
  118. data/lib/inactive_support/core_ext/class/inheritable_attributes.rb +140 -0
  119. data/lib/inactive_support/core_ext/enumerable.rb +63 -0
  120. data/lib/inactive_support/core_ext/hash/keys.rb +54 -0
  121. data/lib/inactive_support/core_ext/module/aliasing.rb +70 -0
  122. data/lib/inactive_support/core_ext/numeric/time.rb +91 -0
  123. data/lib/inactive_support/core_ext/string/inflections.rb +153 -0
  124. data/lib/inactive_support/core_ext/symbol.rb +14 -0
  125. data/lib/inactive_support/core_ext/time/conversions.rb +96 -0
  126. data/lib/inactive_support/duration.rb +96 -0
  127. data/lib/inactive_support/inflections.rb +53 -0
  128. data/lib/inactive_support/inflector.rb +282 -0
  129. data/lib/nested_error.rb +33 -0
  130. data/lib/nitpick.rb +33 -0
  131. data/lib/queued_logger.rb +68 -0
  132. data/lib/tempster.rb +250 -0
  133. data/misc/index_gem_repository.rb +304 -0
  134. data/misc/setup_egg.rb +12 -0
  135. data/misc/setup_gem_dependencies.sh +6 -0
  136. data/misc/setup_rubygems.sh +21 -0
  137. metadata +279 -0
@@ -0,0 +1,493 @@
1
+ module AutomateIt
2
+ # = Project
3
+ #
4
+ # An AutomateIt Project is a collection of related recipes, tags, fields and
5
+ # custom plugins.
6
+ #
7
+ # === Create a project
8
+ #
9
+ # You can create a project by running the following from the Unix shell:
10
+ #
11
+ # automateit --create myproject
12
+ #
13
+ # This will create a directory called +myproject+ with a number of
14
+ # directories and files. Each directory has a <tt>README.txt</tt> that
15
+ # explains what it's used for.
16
+ #
17
+ # === Advantages of a project over raw recipe files
18
+ #
19
+ # Although you can run recipes without a project, putting your recipes into a
20
+ # project provides you with the following benefits:
21
+ #
22
+ # 1. Directory structure to organize your files.
23
+ # 2. Automatically loads tags from project's <tt>config/tags.yml</tt> file.
24
+ # 3. Loads fields from the <tt>config/fields.yml</tt> file.
25
+ # 4. Loads all custom plugins and libraries found in the +lib+ directory.
26
+ # 5. Provides a +dist+ method that corresponds to your project's +dist+
27
+ # directory. Using this method will save you from having to type paths for
28
+ # files you intend to distribute from recipes, e.g.:
29
+ # cp(dist+"/source.txt", "/tmp/target.txt")
30
+ #
31
+ # === Using a project
32
+ #
33
+ # For example, create a new project:
34
+ #
35
+ # automateit --create hello_project
36
+ #
37
+ # Inside this project, edit its fields, which are stored in the
38
+ # <tt>config/fields.yml</tt> file, and make it look like this:
39
+ #
40
+ # greeting: Hello world!
41
+ #
42
+ # Then create a recipe in the <tt>recipes/greet.rb</tt> file:
43
+ #
44
+ # puts lookup(:greeting)
45
+ #
46
+ # You can run the recipe:
47
+ #
48
+ # automateit recipes/greet.rb
49
+ #
50
+ # And you should get the following output:
51
+ #
52
+ # Hello world!
53
+ #
54
+ # === Partitioning recipes
55
+ #
56
+ # You should split up your recipe code into different recipe files. This will
57
+ # improve the clarity of your code because each file can perform one task,
58
+ # and you'll also be able to easily execute a specific recipe.
59
+ #
60
+ # For example, you can use a task-specific <tt>recipes/postgresql.rb</tt> to
61
+ # set up the PostgreSQL database server, and a <tt>recipes/apache.rb</tt> to
62
+ # setup the Apache web server.
63
+ #
64
+ # === Running recipes from other recipes
65
+ #
66
+ # You can run one recipe from another. It's a good idea to create a top-level
67
+ # recipe that invokes the other recipes. This lets you run a single recipe
68
+ # that will in turn run all your other recipes in the correct order, such as
69
+ # setting up the database server before the web server so that websites.
70
+ #
71
+ # For example, consider a <tt>recipes/all.rb</tt> file with these lines:
72
+ #
73
+ # invoke 'postgresql' if tagged? :postgresql_server
74
+ # invoke 'nginx' if tagged? :nginx_server
75
+ # invoke 'apache' if tagged? :apache_server
76
+ #
77
+ # The first line above checks to see if the current host has the
78
+ # <tt>postgresql_server</tt> tag, and if it does, invokes the
79
+ # <tt>recipes/postgresql.rb</tt> recipe.
80
+ #
81
+ # You must run recipes from other recipes using AutomateIt's +invoke+ method
82
+ # and not Ruby's +require+, because the +invoke+ passes along the AutomateIt
83
+ # interpreter to the other recipes so they can continue execution.
84
+ #
85
+ # === Using project libraries
86
+ #
87
+ # Any files ending with <tt>.rb</tt> that you put into the project's
88
+ # <tt>lib</tt> directory will be loaded before your recipe starts executing.
89
+ # This is a good way to add common features, custom plugins and such.
90
+ #
91
+ # For example, put the following into a new <tt>lib/meow.rb</tt> file:
92
+ #
93
+ # def meow
94
+ # "MEOW!"
95
+ # end
96
+ #
97
+ # Now create a new recipe that uses this method in <tt>recipes/speak.rb</tt>
98
+ #
99
+ # puts meow
100
+ #
101
+ # Now you can run it:
102
+ #
103
+ # automateit recipes/speak.rb
104
+ #
105
+ # And you'll get this:
106
+ #
107
+ # MEOW!
108
+ #
109
+ # === Specifying project paths on the Unix shell
110
+ #
111
+ # AutomateIt will load the project automatically if you're executing a recipe
112
+ # that's inside a project's +recipes+ directory.
113
+ #
114
+ # For example, assume that you've create your project as
115
+ # <tt>/tmp/hello_project</tt> and have a recipe at
116
+ # <tt>/tmp/hello_project/recipes/greet.rb</tt>.
117
+ #
118
+ # You can execute the recipe with a full path:
119
+ #
120
+ # automateit /tmp/hello_project/recipes/greet.rb
121
+ #
122
+ # Or execute it with a relative path:
123
+ #
124
+ # cd /tmp/hello_project/recipes
125
+ # automateit greet.rb
126
+ #
127
+ # Or you can prepend a header to the <tt>greet.rb</tt> recipe so it looks like this
128
+ #
129
+ # #!/usr/bin/env automateit
130
+ #
131
+ # puts lookup(:greeting)
132
+ #
133
+ # And then make the file executable:
134
+ #
135
+ # chmod a+X /tmp/hello_project/recipes/greet.rb
136
+ #
137
+ # And execute the recipe directly:
138
+ #
139
+ # /tmp/hello_project/recipes/greet.rb
140
+ #
141
+ # === Specifying project paths for embedded programs
142
+ #
143
+ # If you're embedding the Interpreter into another Ruby program, you can run recipes and they'll automatically load the project if applicable. For example:
144
+ #
145
+ # require 'rubygems'
146
+ # require 'automateit'
147
+ # AutomateIt.invoke("/tmp/hello_project/recipes/greet.rb")
148
+ #
149
+ # Or if you may specify the project path explicitly:
150
+ #
151
+ # require 'rubygems'
152
+ # require 'automateit'
153
+ # interpreter = AutomateIt.new(:project => "/tmp/hello_project")
154
+ # puts interpreter.lookup("greeting")
155
+ #
156
+ # === Tag and field command-line helpers
157
+ #
158
+ # You can access a project's tags and fields from the Unix shell. This
159
+ # helps other programs access configuration data and make use of your roles.
160
+ #
161
+ # For example, with the <tt>hello_project</tt> we've created, we can lookup
162
+ # fields from the Unix shell like this:
163
+ #
164
+ # aifield -p /tmp/hello_project greeting
165
+ #
166
+ # The <tt>-p</tt> specifies the project path (its an alias for
167
+ # <tt>--project</tt>).
168
+ #
169
+ # More commands are available. For documentation and examples run the
170
+ # following commands from the Unix shell:
171
+ #
172
+ # aifield --help
173
+ # aitag --help
174
+ #
175
+ # Sometimes it's convenient to set a default project path so you don't need
176
+ # to type as much by specifing the <tt>AUTOMATEIT_PROJECT</tt> environmental
177
+ # variable (or <tt>AIP</tt> if you want a shortcut) and use it like this:
178
+ #
179
+ # export AUTOMATEIT_PROJECT=/tmp/hello_project
180
+ # aifield greeting
181
+ #
182
+ # === Sharing a project between systems
183
+ #
184
+ # If you want to share a project between different hosts, you're responsible for distributing the files between them. This isn't a big deal though because these are just text files and your OS has dozens of excellent ways to distribute these.
185
+ #
186
+ # Common approaches to distribution:
187
+ # * <b>Shared directory</b>: Your hosts mount a shared network directory (e.g., +nfs+ or +smb+) with your project. This is very easy if your hosts already have a shared directory, but can be a nuisance otherwise because it opens potential security holes and risks having you hosts hang if the master goes offline.
188
+ # * <b>Client pull</b>: Your hosts download the latest copy of your project from a master repository using a remote copy tool (e.g., +rsync+) or a revision control system (e.g., +cvs+, +svn+, +hg+). This is a safe, simple and secure option.
189
+ # * <b>Server push</b>: You have a master push out the project files to clients using a remote copy tool and then invoke +automateit+ on them via SSH. This can be awkward and time-consuming because the server must go through a list of all hosts and copy files to them individually.
190
+ #
191
+ # An example of a complete solution for distributing system configuration management files:
192
+ # 1. Setup an +svn+ or other version control repository to store your project and create a special account for the hosts to use to checkout code.
193
+ # 2. Write a wrapper script for running the recipes, for example, write a "/usr/bin/myautomateit" shell script like:
194
+ #
195
+ # #!/bin/sh
196
+ # cd /var/local/myautomateit
197
+ # svn update --quiet
198
+ # automateit recipe/default.rb
199
+ # 3. Run this wrapper once an hour using cron so that your systems are always up to date. AutomateIt only prints output when it makes a change, so cron will only email you when you commit new code to the repository and the hosts make changes.
200
+ # 4. If you need to run a recipe on the machine right now, SSH into it and run the wrapper.
201
+ # 5. If you need to run the script early on a bunch of machines and don't want to manually SSH into each one, you can leverage the +aitag+ (see <tt>aitag --help</tt>) to execute a Unix command across multiple systems. For example, you could use a Unix shell command like this to execute the wrapper on all hosts tagged with +apache_servers+:
202
+ #
203
+ # for host in `aitag -p /var/local/myautomateit -w apache_server`; do
204
+ # echo "# $host"
205
+ # ssh $host myautomateit
206
+ # done
207
+ #
208
+ # === Curios
209
+ #
210
+ # In case you're interested, the project creator is actually an AutomateIt
211
+ # recipe. You can read the recipe source code by looking at the
212
+ # AutomateIt::Project::create method.
213
+ class Project < Common
214
+ # Create a new project.
215
+ #
216
+ # Options:
217
+ # * :create -- Project path to create. Required.
218
+ # * All other options are passed to the AutomateIt::Interpreter.
219
+ def self.create(opts)
220
+ display = lambda {|message| puts message if ! opts[:verbosity] || (opts[:verbosity] && opts[:verbosity] <= Logger::INFO) }
221
+
222
+ path = opts.delete(:create) \
223
+ or raise ArgumentError.new(":create option not specified")
224
+ interpreter = AutomateIt.new(opts)
225
+ interpreter.instance_eval do
226
+ # +render+ only files that don't exist.
227
+ template_manager.default_check = :exists
228
+
229
+ mkdir_p(path) do |created|
230
+ display.call PNOTE+"%s AutomateIt project at: %s" %
231
+ [created ? "Creating" : "Updating", path]
232
+
233
+ render(:text => WELCOME_CONTENT, :to => "README_AutomateIt.txt")
234
+ render(:text => RAKEFILE_CONTENT, :to => "Rakefile")
235
+
236
+ mkdir("config")
237
+ render(:text => TAGS_CONTENT, :to => "config/tags.yml")
238
+ render(:text => FIELDS_CONTENT, :to => "config/fields.yml")
239
+ render(:text => ENV_CONTENT, :to => "config/automateit_env.rb")
240
+
241
+ mkdir("dist")
242
+ render(:text => DIST_README_CONTENT, :to => "dist/README_AutomateIt_dist.txt")
243
+
244
+ mkdir("lib")
245
+ render(:text => BASE_README_CONTENT, :to => "lib/README_AutomateIt_lib.txt")
246
+
247
+ mkdir("recipes")
248
+ render(:text => RECIPE_README_CONTENT, :to => "recipes/README_AutomateIt_recipes.txt")
249
+ render(:text => RECIPE_HELLO_CONTENT, :to => "recipes/hello.rb")
250
+ end
251
+
252
+ if log.info? and not opts[:quiet]
253
+ puts '-----------------------------------------------------------------------'
254
+ puts WELCOME_MESSAGE
255
+ puts '-----------------------------------------------------------------------'
256
+ end
257
+ end # of interpreter.instance_eval
258
+ end
259
+
260
+ #---[ Default text content for generated files ]------------------------
261
+
262
+ WELCOME_MESSAGE = <<-EOB #:nodoc:
263
+ Welcome to AutomateIt!
264
+
265
+ Learn:
266
+ * See it in action at http://AutomateIt.org/screenshots
267
+ * Read the tutorial at http://AutomateIt.org/tutorial
268
+ * Read the documentation at http://AutomateIt.org/documentation
269
+ * See the README files created in the project
270
+
271
+ Run:
272
+ * `automateit -p .` -- Starts interactive shell for project
273
+ * `automateit recipes/hello.rb` -- Runs a recipe called recipes/hello.rb
274
+ * `automateit -n recipes/hello.rb` -- Previews recipe
275
+
276
+ Rake:
277
+ * `rake` -- Starts interactive shell for project
278
+ * `rake hello` -- Runs sample recipe
279
+ * `rake preview` -- Turns on preview mode
280
+ * `rake preview hello` -- Previews the sample recipe
281
+
282
+ Changes:
283
+ * Sign up for RSS feed at http://automateit.org/changes
284
+ EOB
285
+
286
+ welcome_lines = WELCOME_MESSAGE.split(/\n/)
287
+ welcome_title = welcome_lines.first
288
+ welcome_body = welcome_lines[2, welcome_lines.size]
289
+ WELCOME_CONTENT = <<-EOB #:nodoc:
290
+ #-----------------------------------------------------------------------
291
+ #
292
+ # == #{welcome_title}
293
+ #
294
+ #{welcome_body.map{|t| "# %s" % t}.join("\n")}
295
+ #
296
+ #-----------------------------------------------------------------------
297
+ EOB
298
+
299
+ TAGS_CONTENT = <<-EOB # :nodoc:
300
+ # Put your roles here
301
+
302
+ #-----------------------------------------------------------------------
303
+ #
304
+ # == TAGS
305
+ #
306
+ # This is an AutomateIt tags file. Use it to assign tags to hosts so you
307
+ # can manage multiple hosts as a group.
308
+ #
309
+ # For example, in this file assign the tag "myrole" to two computers
310
+ # named "host1" and "host2":
311
+ #
312
+ # myrole:
313
+ # - host1
314
+ # - host2
315
+ #
316
+ # Then check from a recipe if this host has this tag:
317
+ #
318
+ # if tagged?("myrole")
319
+ # # Code will only run if this host is tagged with "myrole"
320
+ # end
321
+ #
322
+ # You can also retrieve tags:
323
+ #
324
+ # puts "Tags for this host: \#{tags.inspect}"
325
+ # # => ["myrole"]
326
+ # puts "Tags for a specific host: \#{tags_for("host1").inspect}"
327
+ # # => ["myrole"]
328
+ # puts "Hosts with a tag: \#{hosts_tagged_with("myrole").inspect}"
329
+ # # => ["host1", "host2"]
330
+ #
331
+ # You will likely see additional tags which are automatically added
332
+ # based on the host's operating system, architecture, hostnames, etc.
333
+ #
334
+ # You may use ERB statements within this file.
335
+ #
336
+ # See AutomateIt::TagManager for further details.
337
+ #
338
+ #-----------------------------------------------------------------------
339
+ EOB
340
+
341
+ FIELDS_CONTENT = <<-EOB #:nodoc:
342
+ # Put your fields here
343
+
344
+ #-----------------------------------------------------------------------
345
+ #
346
+ # == FIELDS
347
+ #
348
+ # This is an AutomateIt fields file. Fields are useful for extracting
349
+ # configuration-specific arguments out of your recipe logic, and making
350
+ # them easier to share between recipes and access from other programs.
351
+ #
352
+ # For example, declare fields using YAML:
353
+ #
354
+ # foo: bar
355
+ # mydaemon:
356
+ # mykey: myvalue
357
+ #
358
+ # And retrieve field values from a recipe:
359
+ #
360
+ # lookup("foo") # => "bar"
361
+ # lookup("mydaemon") # => {"mykey" => "myvalue"}
362
+ # lookup("mydaemon#mykey") # => "myvalue"
363
+ #
364
+ # You may use ERB statements within this file. Because this file is
365
+ # loaded after the tags, you can use ERB to dynamically set fields for
366
+ # specific groups of hosts, e.g.:
367
+ #
368
+ # magical: <%%= tagged?("magical_hosts") ? true : false %>
369
+ #
370
+ # See AutomateIt::FieldManager for further details.
371
+ #
372
+ #-----------------------------------------------------------------------
373
+ EOB
374
+
375
+ ENV_CONTENT = <<-EOB #:nodoc:
376
+ # Put your environment commands here
377
+
378
+ #-----------------------------------------------------------------------
379
+ #
380
+ # == ENVIRONMENT
381
+ #
382
+ # This is an AutomateIt environment file. Use it to customize AutomateIt
383
+ # and provide settings to recipes, interactive shell, or embedded
384
+ # Interpreters using this project.
385
+ #
386
+ # The "self" in this file is an Interpreter instance, so you can execute
387
+ # all the same commands that you'd normally put in a recipe.
388
+ #
389
+ # This file is loaded after the project's tags, fields and libraries.
390
+ #
391
+ #-----------------------------------------------------------------------
392
+ EOB
393
+
394
+ BASE_README_CONTENT = <<-EOB #:nodoc:
395
+ #-----------------------------------------------------------------------
396
+ #
397
+ # == LIB
398
+ #
399
+ # This is your AutomateIt project's "lib" directory. You can put custom
400
+ # plugins and convenience methods into this directory.
401
+ #
402
+ # For example, create a convenience method for geteting the time by
403
+ # creating a "lib/now.rb" file with the following contents:
404
+ #
405
+ # def now
406
+ # DateTime.now
407
+ # end
408
+ #
409
+ # This will provide a "now" method that's available to your recipes,
410
+ # interactive shell or embedded interpreter.
411
+ #
412
+ # Libraries are loaded every time an AutomateIt interpreter is started.
413
+ # It loads all "*.rb" files in this directory, and all "init.rb" files
414
+ # in subdirectories of this directory.
415
+ #
416
+ #-----------------------------------------------------------------------
417
+ EOB
418
+
419
+ DIST_README_CONTENT = <<-EOB #:nodoc:
420
+ #-----------------------------------------------------------------------
421
+ #
422
+ # == DIST
423
+ #
424
+ # This is your AutomateIt project's "dist" directory. It's a place for
425
+ # keeping files and templates you plan to distribute.
426
+ #
427
+ # You can retrieve this directory's path using the "dist" method in
428
+ # recipes, for example:
429
+ #
430
+ # # Display the "dist" directory's path
431
+ # puts dist
432
+ #
433
+ # # Render the template file "dist/foo.erb"
434
+ # render(:file => dist+"/foo.erb", ...)
435
+ #
436
+ # # Or copy the same file somewhere
437
+ # cp(dist+"/foo.erb", ...)
438
+ #
439
+ #-----------------------------------------------------------------------
440
+ EOB
441
+
442
+ RECIPE_README_CONTENT = <<-EOB #:nodoc:
443
+ #-----------------------------------------------------------------------
444
+ #
445
+ # == RECIPES
446
+ #
447
+ # This is your AutomateIt project's "recipes" directory. You should put
448
+ # recipes into this directory.
449
+ #
450
+ # For example, create a "recipes/hello.rb" file with these contents:
451
+ #
452
+ # puts "Hello"
453
+ #
454
+ # And execute it with:
455
+ #
456
+ # automateit recipes/your_recipe.rb
457
+ #
458
+ #-----------------------------------------------------------------------
459
+ EOB
460
+
461
+ RECIPE_HELLO_CONTENT = <<-'EOB' #:nodoc
462
+ puts "Hello, I'm an #{self.class} -- pleased to meet you!"
463
+ puts "I'm in preview mode" if preview?
464
+ EOB
465
+
466
+ RAKEFILE_CONTENT = <<-EOB #:nodoc
467
+ require "automateit"
468
+
469
+ # Create an Interpreter for project in current directory.
470
+ @interpreter = AutomateIt.new(:project => ".")
471
+
472
+ # Include Interpreter's methods into Rake session.
473
+ @interpreter.include_in(self)
474
+
475
+ task :default => :shell
476
+
477
+ desc "Interactive AutomateIt shell"
478
+ task :shell do
479
+ AutomateIt::CLI.run
480
+ end
481
+
482
+ desc "Run a recipe"
483
+ task :hello do
484
+ invoke "hello"
485
+ end
486
+
487
+ desc "Preview action, e.g, 'rake preview hello'"
488
+ task :preview do
489
+ preview true
490
+ end
491
+ EOB
492
+ end
493
+ end