Browse files

Updating README and code to match

  • Loading branch information...
1 parent d62f112 commit 5000c152868e6b66888bb2c1f2fce93d6857c436 @winton committed Nov 15, 2009
View
111 README.markdown
@@ -1,36 +1,109 @@
-GemTemplate
-===========
+Auto
+====
-A gem template for new projects.
+Automate everything!
-Requirements
+Notice
+------
+
+This gem is currently under development. Some of what you see below is a fantasy.
+
+Install
+-------
+
+<pre>
+sudo gem install auto --source http://gemcutter.org
+</pre>
+
+Introduction
------------
+Auto is a framework for writing automation scripts and plugins for those scripts.
+
<pre>
-sudo gem install stencil --source http://gemcutter.org
+require 'rubygems'
+require 'auto'
+
+question :name => "What is your name?"
+question :delete => "Delete file when finished? (y/n)"
+
+file "#{@name}.txt" do |f|
+ f &lt;&lt; 'Append to text file'
+ f = 'Overwrite text file'
+end
+
+file("#{@name}.txt").delete if @delete
</pre>
-Setup the template
-------------------
+Save it and run it like you would any other Ruby script.
+
+In this example, <code>question</code> and <code>file</code> are both methods provided by the plugins <code>auto-question</code> and <code>auto-file</code>, respectively. They are included when you install the <code>auto</code> gem, but other plugins can be obtained via Rubygems.
+
+Tasks
+-----
+
+Auto has a tasks system similar to Capistrano or Rake. In the previous example, if you had saved your script to <code>~/.auto/my/name.rb</code>, you would be able to run it by executing <code>auto my:name</code> in Terminal.
+
+Tasks may also be included via plugin. See the **Authoring Plugins** section for more information.
+
+Sessions
+--------
-You only have to do this once.
+Installing the <code>auto</code> gem also installs <code>auto-session</code>, which allows you to record the input to your Auto scripts and replay them later.
+
+To save a session, run your script or task with the <code>SESSION</code> environment variable:
+
+<pre>
+SESSION=name ruby my_name.rb
+SESSION=name auto my:name
+</pre>
+
+This session would be saved in <code>~/.auto/session/name.rb</code> (run it by executing <code>auto session:name</code>). It might look like this:
+
+<pre>
+answer :name => 'Joe'
+answer :delete => false
+run 'my:name'
+</pre>
+
+The session script is executed as any other Auto script. This is cool because you can modify your session files to get custom input for certain questions.
<pre>
-git clone git@github.com:winton/auto.git
-cd auto
-stencil
+question :name => "What is your last name?"
+answer :delete => false
+run 'my:name'
</pre>
-Setup a new project
--------------------
+You also could have deleted the <code>:name</code> answer to ask that question upon running the session.
-Do this for every new project.
+Authoring Plugins
+-----------------
+
+Plugins have a lib directory just like any other gem. Here is how the lib file for the Foo plugin might look:
<pre>
-mkdir my_project
-git init
-stencil auto
-rake rename
+# lib/foo.rb
+module Auto
+ module Foo
+
+ def foo(*args)
+ Foo.instance args
+ end
+
+ class Foo
+ class &lt;&lt;self
+
+ def instance(args)
+ # Do something
+ end
+ end
+ end
+ end
+end
</pre>
-The last command does a find-replace (gem\_template -> my\_project) on files and filenames.
+Auto uses the gem name (<code>auto-foo</code>) to find <code>lib/foo.rb</code> and include <code>Auto::Foo</code> into the environment. Now you can call the <code>foo</code> method in any of your Auto scripts.
+
+Auto plugins must have gem names with <code>auto-</code> as a prefix to be automatically required.
+
+Include Auto tasks with your plugin by adding a <code>.auto</code> directory to your gem, just as you do with your home directory (<code>~/.auto</code>).
View
2 gemspec.rb
@@ -15,5 +15,5 @@
s.name = GEM_NAME
s.platform = Gem::Platform::RUBY
s.require_path = "lib"
- s.version = "0.0.1"
+ s.version = "0.1.1"
end
View
4 lib/auto.rb
@@ -1,8 +1,6 @@
require File.dirname(__FILE__) + "/auto/require"
module Auto
- Runner.new do
- terminal($0)
- end
+ Runner.new { terminal($0) }
exit
end
View
6 lib/auto/plugins.rb
@@ -16,7 +16,7 @@ class <<self
# Add a directory to the plugin load paths.
def add(path)
- @@directories = [] if $TESTING
+ @@directories = [] if $testing
@@directories << path
@@directories.uniq!
@@plugins = nil
@@ -95,8 +95,8 @@ def initialize(directory)
end
# ~/.auto/auto-plugin/auto/task.rb
- @tasks = Dir["#{directory}/auto/**/*.rb"].sort.collect do |path|
- relative = path.gsub("#{directory}/auto/", '')
+ @tasks = Dir["#{directory}/.auto/**/*.rb"].sort.collect do |path|
+ relative = path.gsub("#{directory}/.auto/", '')
{
:name => relative[0..-4].split('/').join(':').downcase,
:path => path
View
6 spec/auto/plugins_spec.rb
@@ -27,15 +27,15 @@ module Auto
it "should provide a hash of plugin task information" do
@tasks.should == [
{
- :path => "#{@fixtures}/auto-plugin-0.0.0/auto/plugin/task.rb",
+ :path => "#{@fixtures}/auto-plugin-0.0.0/.auto/plugin/task.rb",
:name => "plugin:task"
},
{
- :path => "#{@fixtures}/auto-plugin2/auto/plugin2/task.rb",
+ :path => "#{@fixtures}/auto-plugin2/.auto/plugin2/task.rb",
:name => "plugin2:task"
},
{
- :path => "#{@fixtures}/auto-plugin2/auto/plugin2/task2.rb",
+ :path => "#{@fixtures}/auto-plugin2/.auto/plugin2/task2.rb",
:name => "plugin2:task2"
}
]
View
0 ...plugins/auto-plugin2/auto/plugin2/task.rb → ...ns/auto-plugin-0.0.0/.auto/plugin/task.rb
File renamed without changes.
View
0 ...ins/auto-plugin-0.0.0/auto/plugin/task.rb → ...lugins/auto-plugin2/.auto/plugin2/task.rb
File renamed without changes.
View
0 ...lugins/auto-plugin2/auto/plugin2/task2.rb → ...ugins/auto-plugin2/.auto/plugin2/task2.rb
File renamed without changes.

0 comments on commit 5000c15

Please sign in to comment.