Sha256: 40ee76dd6f2daf2f24406b6de2164b38429f8fd2b399d257673de372705d56d2

Contents?: true

Size: 898 Bytes

Versions: 3

Compression:

Stored size: 898 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|
            File.directory?(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

3 entries across 3 versions & 1 rubygems

Version Path
engineyard-recipes-0.4.0 lib/engineyard-recipes/generators/base_generator.rb
engineyard-recipes-0.3.2 lib/engineyard-recipes/generators/base_generator.rb
engineyard-recipes-0.3.2.pre lib/engineyard-recipes/generators/base_generator.rb