Sha256: 00113d398debec310ec8a40e27fb2203738c197728a8c38768a99c30b5df5835

Contents?: true

Size: 1014 Bytes

Versions: 5

Compression:

Stored size: 1014 Bytes

Contents

#require 'thor/actions'


module Playmo
  class Action
    cattr_accessor :actions

    # TODO: Сделать опцию dry-run, когда ничего не происходит, а только
    # показывается порядок запуска рецептов
    def initialize(recipe, &block)
      # Откладываем непосредственный запуск
      @@actions ||= []
      @@actions << [recipe, block]

      #recipe.instance_eval &block
      #puts "fuck" if block_given?
      #if block.arity > 0
      #  puts "We have args!"
      #  recipe.instance_eval &block
      #else
        #puts "It seems we have answers"
      #  instance_eval &block
      #end
    end

    def self.execute_all
      @@actions.each do |action|
      	recipe, block = action[0], action[1]
        
        recipe.class.class_eval do
          source_root "#{Playmo::ROOT}/recipes/templates/#{recipe.name}_recipe"
        end

      	recipe.instance_eval &block
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
playmo-0.1.6 lib/playmo/action.rb
playmo-0.1.5 lib/playmo/action.rb
playmo-0.1.4 lib/playmo/action.rb
playmo-0.1.3 lib/playmo/action.rb
playmo-0.1.2 lib/playmo/action.rb