Sha256: 0693ec149eaaa94561e322012c73a3e455e29604b6a33959d14e8718e9b945e2

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require 'thor/group'

module Engineyard::Recipes
  module Generators
    class BaseGenerator < Thor::Group
      include Thor::Actions

      protected
      def cookbooks_destination
        @cookbooks_destination ||= begin
          return "." if self.respond_to?(:flags) && flags[:local] # check for bonus --local flag in CLI
          possible_paths = ['deploy/cookbooks', 'cookbooks']
          destination = possible_paths.find do |cookbooks|
            Dir.exist?(File.join(destination_root, cookbooks))
          end
          unless destination
            error "Cannot discover cookbooks folder"
          end
          destination
        end
      end
      
      def cookbooks_dir(child_path)
        File.join(cookbooks_destination, child_path)
      end
      
      def say(msg, color = nil)
        color ? shell.say(msg, color) : shell.say(msg)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
engineyard-recipes-0.3.0 lib/engineyard-recipes/generators/base_generator.rb