Sha256: 4090b36c6d2b17e7bcfcda7d4457096f8266fb58ca195857f4c50301bdc5cda2

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'thor/group'

module Engineyard::Recipes
  module Generators
    class SmGenerator < BaseGenerator
      include Thor::Actions
      attr_accessor :command
      
      argument :recipe_name
      argument :sm_ext_uri
      argument :sm_ext_commands, :type => :array
      argument :sm_vendor_path, :required => false

      def self.source_root
        File.join(File.dirname(__FILE__), "sm_generator", "templates")
      end
      
      def install_cookbooks
        directory "cookbooks", cookbooks_destination
      end
      
      def wrap_commands
        template_file = 'command_recipe.rb.tt'
        sm_ext_commands.each do |command|
          self.command = command # for the template
          recipe = cookbooks_dir "#{recipe_name}/recipes/#{command}.rb"
          template(template_file, recipe)
        end
      end
      
      def auto_require_package
        file = cookbooks_dir "main/recipes/default.rb"
        require_recipe = "\nrequire_recipe '#{recipe_name}'\n"
        append_to_file file, require_recipe
      end
      
      private
      def say(msg, color = nil)
        color ? shell.say(msg, color) : shell.say(msg)
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
engineyard-recipes-0.3.2.pre lib/engineyard-recipes/generators/sm_generator.rb
engineyard-recipes-0.3.0 lib/engineyard-recipes/generators/sm_generator.rb