Permalink
Browse files

task arguments dsl patch

  • Loading branch information...
1 parent 7c923f5 commit 8e757e16e30f67e2cde4d2140c8d6335266b37df @gabriel committed May 14, 2008
View
@@ -5,6 +5,8 @@
* Fixing backgroundjob init (BIN_PATH error)
* Adding --log to backgroundjob init.d
* Fixing sphinx monit start/stop/restart
+* Adding task arguments to DSL
+* Updating most of the documentation to pull from task args
== 0.3.5 2008-05-08
View
@@ -6,11 +6,12 @@ README.txt
Rakefile
config/hoe.rb
config/requirements.rb
-docs/nginx.README
lib/capitate.rb
lib/capitate/cap_ext/connections.rb
lib/capitate/cap_ext/docs.rb
+lib/capitate/cap_ext/namespace.rb
lib/capitate/cap_ext/run_via.rb
+lib/capitate/cap_ext/task_definition.rb
lib/capitate/cap_ext/variables.rb
lib/capitate/plugins/base.rb
lib/capitate/plugins/build.rb
@@ -78,6 +79,7 @@ lib/templates/logrotated/conf.erb
lib/templates/memcached/memcached.initd.centos.erb
lib/templates/memcached/memcached.monitrc.erb
lib/templates/memcached/memcached.yml.erb
+lib/templates/merb/merb-no-http.monitrc.erb
lib/templates/merb/merb.initd.centos.erb
lib/templates/merb/merb.monitrc.erb
lib/templates/mongrel/mongrel_cluster.initd.centos.erb
@@ -112,11 +114,3 @@ test/test_helper.rb
test/test_plugin_upload.rb
test/test_recipes.rb
test/test_templates.rb
-website/index.html
-website/index.txt
-website/javascripts/code_highlighter.js
-website/javascripts/rounded_corners_lite.inc.js
-website/javascripts/ruby.js
-website/stylesheets/screen.css
-website/template.rhtml
-website/template_recipe.rhtml
View
@@ -27,6 +27,8 @@ module Plugins # :nodoc:
require "capitate/cap_ext/variables"
require "capitate/cap_ext/run_via"
require "capitate/cap_ext/docs"
+require "capitate/cap_ext/namespace"
+require "capitate/cap_ext/task_definition"
class Capistrano::Configuration
include Capitate::CapExt::Variables
@@ -35,6 +37,18 @@ class Capistrano::Configuration
include Capitate::CapExt::Docs
end
+class Capistrano::TaskDefinition
+ include Capitate::CapExt::TaskDefinition
+end
+
+class Capistrano::Configuration::Namespaces::Namespace
+ include Capitate::CapExt::Namespace
+end
+
+module Capistrano::Configuration::Namespaces
+ include Capitate::CapExt::Namespace
+end
+
#module Capistrano::Configuration::Connections; end
require 'capitate/task_node'
View
@@ -172,7 +172,27 @@ def write_doc(dir, file_name = nil, title = nil, options = {}, &block)
options = ""
options = "<span class='options'>, #{task.options.inspect}</span>" unless task.options.blank?
file.puts "h3(##{task.fully_qualified_name}). #{task.fully_qualified_name}#{options}\n\n"
- file.puts "#{unindent(task.desc)}\n\n"
+ file.puts "#{unindent(task.desc)}\n\n"
+ if task.arguments
+ file.puts "h4. Parameters\n\n"
+ file.puts "<dl>\n"
+ task.arguments.each do |arg|
+ file.puts "<dt>#{arg[:name]}</dt>"
+ file.puts "<dd>#{unindent(arg[:desc])}</dd>" if arg.has_key?(:desc)
+ if arg.has_key?(:default_desc)
+ file.puts "<dd class='default'>Defaults to @#{arg[:default_desc]}@</dd>"
+ elsif arg.has_key?(:default)
+ file.puts "<dd class='default'>Defaults to @#{arg[:default].inspect}@</dd>"
+ end
+
+ if arg.has_key?(:set)
+ file.puts "<dd class='default'>Defaults to @#{arg[:set].inspect}@ (cap setting)</dd>"
+ end
+
+ file.puts "<dd class='example'>Example: @set :#{arg[:name]}, #{arg[:example]}@" if arg.has_key?(:example)
+ end
+ end
+ file.puts "</dl>\n\n"
file.puts "</div>\n\n\n"
end
end
View
@@ -2,7 +2,7 @@ module Capitate #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 3
- TINY = 5
+ TINY = 6
STRING = [MAJOR, MINOR, TINY].join('.')
end
@@ -4,45 +4,16 @@
Create (ActiveRecord) database yaml in shared path.
Note: If both @:db_host@ and @:db_socket@ are used, @db_socket@ wins.
- <dl>
- <dt>db_name</dt>
- <dd>Database name.</dd>
- <dd>@set :db_name, "app_db_name"@</dd>
-
- <dt>db_user</dt>
- <dd>Database user.</dd>
- <dd>@set :db_user, "app_db_user"@</dd>
-
- <dt>db_pass</dt>
- <dd>Database password.</dd>
- <dd>@set :db_pass, "the_password"@</dd>
-
- <dt>db_host</dt>
- <dd>Database host (can be nil, if you are using socket).</dd>
- <dd class="default">Defaults to @nil@</dd>
-
- <dt>db_socket</dt>
- <dd>Database socket (can be nil, if you are using host).</dd>
- <dd class="default">Defaults to @nil@</dd>
- <dd>@set :db_socket, "/var/lib/mysql/mysql.sock"@</dd>
-
- <dt>database_yml_template</dt>
- <dd>Path to database yml erb template.
- <dd class="default">Defaults to @rails/database.yml.erb@ (in this GEM)</dd>
- </dl>
-
"Source":#{link_to_source(__FILE__)}
DESC
+ task_arg(:db_name, "Database name")
+ task_arg(:db_user, "Database user")
+ task_arg(:db_pass, "Database password")
+ task_arg(:db_host, "Database host", :default => nil)
+ task_arg(:db_socket, "Database socket", :default => nil)
+ task_arg(:database_yml_template, "Database yml template", :default => "rails/database.yml.erb")
task :setup, :roles => :app do
- # Settings
- fetch(:db_name)
- fetch(:db_user)
- fetch(:db_pass)
- fetch_or_default(:db_host, nil)
- fetch_or_default(:db_socket, nil)
- fetch_or_default(:database_yml_template, "rails/database.yml.erb")
-
unless db_host.blank?
set :db_connect_type, "host"
set :db_connect, db_host
@@ -57,7 +28,7 @@
put template.load(database_yml_template), "#{shared_path}/config/database.yml"
end
- desc "Make symlink for database yaml"
+ desc "Make symlink for database yaml"
task :update_code do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
@@ -6,29 +6,14 @@
For pid path support, change backgroundrb script pid_file line to:
pid_file = "\#{CONFIG_FILE[:backgroundrb][:pid_file]}"
-
- <dl>
- <dt>backgroundrb_host</dt>
- <dd>Backgroundrb host</dd>
- <dd class="default">Defaults to @0.0.0.0@</dd>
- <dt>backgroundrb_port</dt>
- <dd>Backgroundrb port</dd>
- <dd class="default">Defaults to @11006@</dd>
-
- <dt>backgroundrb_yml_template</dt>
- <dd>Backgroundrb yml template</dd>
- <dd class="default">Defaults to @backgroundrb/backgroundrb.yml.erb@ in this gem.</dd>
- </dl>
-
"Source":#{link_to_source(__FILE__)}
DESC
+ task_arg(:backgroundrb_host, "Backgroundrb host", :default => "0.0.0.0")
+ task_arg(:backgroundrb_port, "Backgroundrb port", :default => 11006)
+ task_arg(:backgroundrb_pid_path, "Backgroundrb pid path", :default => Proc.new{"#{shared_path}/pids/backgroundrb.pid"}, :default_desc => "\#{shared_path}/pids/backgroundrb.pid")
+ task_arg(:backgroundrb_yml_template, "Backgroundrb yml template", :default => "backgroundrb/backgroundrb.yml.erb")
task :setup do
- fetch_or_default(:backgroundrb_host, "0.0.0.0")
- fetch_or_default(:backgroundrb_port, 11006)
- fetch_or_default(:backgroundrb_pid_path, "#{shared_path}/pids/backgroundrb.pid")
- fetch_or_default(:backgroundrb_yml_template, "backgroundrb/backgroundrb.yml.erb")
-
utils.install_template(backgroundrb_yml_template, "#{shared_path}/config/backgroundrb.yml")
end
@@ -5,35 +5,15 @@
desc <<-DESC
Setup backgroundjob for application.
- <dl>
- <dt>backgroundjob_bin_path</dt>
- <dd>Path to start.
- <dd class="default">Defaults to:
- <pre>
- \#{current_path}/script/bj --forever --rails_env=production --rails_root=\#{current_path} \
- --redirect=\#{backgroundjob_log_path} --log=\#{backgroundjob_log_path} --pidfile=\#{backgroundjob_pid_path} --daemon
- </pre>
- </dd>
- <dt>backgroundjob_pid_path</dt>
- <dd>Path to backgroundjob pid file</dd>
- <dd class="default">Defaults to @\#{shared_path}/pids/bj.pid@</dd>
-
- <dt>backgroundjob_log_path</dt>
- <dd>Path to backgroundjob log file</dd>
- <dd class="default">Defaults to @\#{shared_path}/logs/bj.log@</dd>
- </dl>
"Source":#{link_to_source(__FILE__)}
DESC
+ task_arg(:backgroundjob_bin_path, "Path to backgroundjob",
+ :default => Proc.new{"#{current_path}/script/bj run --forever --rails_env=production --rails_root=#{current_path} --redirect=#{backgroundjob_log_path} --log=#{backgroundjob_log_path} --pidfile=#{backgroundjob_pid_path} --daemon"},
+ :default_desc => "\#{current_path}/script/bj run --forever --rails_env=production --rails_root=\#{current_path} --redirect=\#{backgroundjob_log_path} --log=\#{backgroundjob_log_path} --pidfile=\#{backgroundjob_pid_path} --daemon")
+ task_arg(:backgroundjob_pid_path, "Path to backgroundjob pid file", :default => Proc.new{"#{shared_path}/pids/bj.pid"}, :default_desc => "\#{shared_path}/pids/bj.pid")
+ task_arg(:backgroundjob_log_path, "Path to backgroundjob log file", :default => Proc.new{"#{shared_path}/log/bj.log"}, :default_desc => "\#{shared_path}/log/bj.log")
task :setup do
- # Settings
- fetch_or_default(:backgroundjob_pid_path, "#{shared_path}/pids/bj.pid")
- fetch_or_default(:backgroundjob_log_path, "#{shared_path}/log/bj.log")
-
- default_bin_path = "#{current_path}/script/bj run --forever --rails_env=production --rails_root=#{current_path} \
---redirect=#{backgroundjob_log_path} --log=#{backgroundjob_log_path} --pidfile=#{backgroundjob_pid_path} --daemon"
- fetch_or_default(:backgroundjob_bin_path, default_bin_path)
-
# Install initscript
utils.install_template("backgroundjob/backgroundjob.initd.centos.erb", "/etc/init.d/backgroundjob_#{application}")
@@ -5,22 +5,11 @@
desc <<-DESC
Setup backgroundrb for application.
- <dl>
- <dt>backgroundrb_bin_path</dt>
- <dd>Path to start.
- <dd class="default">Defaults to @\#{current_path}/script/backgroundrb -e production start@</dd>
- <dt>backgroundrb_pid_path</dt>
- <dd>Path to backgroundrb pid file</dd>
- <dd class="default">Defaults to @\#{shared_path}/pids/backgroundrb.pid@</dd>
- </dl>
"Source":#{link_to_source(__FILE__)}
DESC
+ task_arg(:backgroundrb_bin_path, "Path to backgroundrb bin", :default => Proc.new{"#{current_path}/script/backgroundrb -e production start"}, :default_desc => "\#{current_path}/script/backgroundrb -e production start")
+ task_arg(:backgroundrb_pid_path, "Path to backgroundrb pid file", :default => Proc.new{"#{shared_path}/pids/backgroundrb.pid"}, :default_desc => "\#{shared_path}/pids/backgroundrb.pid")
task :setup do
-
- # Settings
- fetch_or_default(:backgroundrb_bin_path, "#{current_path}/script/backgroundrb -e production start")
- fetch_or_default(:backgroundrb_pid_path, "#{shared_path}/pids/backgroundrb.pid")
-
# Install initscript
utils.install_template("backgroundrb/backgroundrb.initd.centos.erb", "/etc/init.d/backgroundrb_#{application}")
@@ -5,36 +5,14 @@
desc <<-DESC
Add user and set user password for application. Adds user to specified groups.
- <dl>
- <dt>user_add</dt>
- <dd>User to add.</dd>
- <dd>@set :user_add, "app_user"@</dd>
-
- <dt>groups</dt>
- <dd>Groups for user to be in.</dd>
- <dd class="default">Defaults to @nil@</dd>
- <dd>@set :groups, "admin,foo"@</dd>
-
- <dt>home</dt>
- <dd>Home directory for user.</dd>
- <dd class="default">Defaults to @:deploy_to@ setting_</dd>
- <dd>@set :home, "/var/www/apps/app_name"@</dd>
-
- <dt>home_readable</dt>
- <dd>Whether home permissions are readable by all. Needed if using deploy dir as home.</dd>
- <dd class="default">Defaults to @true@</dd>
- <dd>@set :home_readable, true@</dd>
- </dl>
"Source":#{link_to_source(__FILE__)}
DESC
+ task_arg(:user_add, "User to add")
+ task_arg(:groups, "Groups for user to be in", :default => nil, :example => "\"admin,foo,bar\"")
+ task_arg(:home, "Home directory for user", :set => :deploy_to)
+ task_arg(:home_readable, "Whether home permissions are readable by all. Needed if using deploy dir as home.", :default => true)
task :add_user do
- # Settings
- fetch(:user_add)
- fetch_or_default(:groups, nil)
- fetch_or_default(:home, deploy_to)
- fetch_or_default(:home_readable, true)
-
adduser_options = []
adduser_options << "-d #{home}" unless home.blank?
adduser_options << "-G #{groups}" unless groups.blank?
@@ -2,8 +2,12 @@
namespace :centos do
desc <<-DESC
- Install imagemagick.\n
- <dl><dt>imagemagick_build_options</dt><dd>Imagemagick build options</dd></dl>
+ Install imagemagick.
+
+ "Source":#{link_to_source(__FILE__)}
+ DESC
+ task_arg(:imagemagick_build_options, <<-EOS)
+ Imagemagick build options
<pre>
<code class="ruby">
set :imagemagick_build_options, {
@@ -12,13 +16,8 @@
}
</code>
</pre>
- "Source":#{link_to_source(__FILE__)}
- DESC
- task :install do
-
- # Settings
- fetch(:imagemagick_build_options)
-
+ EOS
+ task :install do
# Install dependencies
yum.install([ "libjpeg-devel", "libpng-devel", "glib2-devel", "fontconfig-devel", "zlib-devel",
"libwmf-devel", "freetype-devel", "libtiff-devel" ])
Oops, something went wrong.

0 comments on commit 8e757e1

Please sign in to comment.