Class: CapRecipes

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/capify.rb

Overview

require File.dirname(__FILE__) + “/../lib/templates”

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



9
# File 'lib/capify.rb', line 9

def self.banner; "cap-recipes [path] task task2 task3"; end

.source_rootObject



8
# File 'lib/capify.rb', line 8

def self.source_root; File.expand_path(File.dirname(__FILE__)); end

Instance Method Details

#capifyObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/capify.rb', line 17

def capify
  unless options[:list]
    capfile_temp = "templates/Capfile.tt"
    deploy_temp = "templates/deploy.rb.tt"
    @recipes = requires.collect { |task| "require 'cap_recipes/tasks/#{task}'" }.join("\n")
    template capfile_temp, File.join(path,'/Capfile')
    template deploy_temp, File.join(path,'/config/deploy.rb')
  else
    folders = Dir.glob( File.dirname(__FILE__) + "/../lib/cap_recipes/tasks/*.rb").inject({}) do |packages,file|
      desc =  IO.readlines(file).first
      packages[File.basename(file, ".rb")] = ((desc =~ /#/) ? desc : "No description")
      packages
    end
    puts "Available Recipes:\n"
    puts folders.collect { |folder,desc| "\t* #{folder} - #{desc}"}.join("\n")
  end
end