Sha256: b2c695a95ab3b70599503bef5c326d7a64886273b5839dd0c79644a82ab17325

Contents?: true

Size: 969 Bytes

Versions: 3

Compression:

Stored size: 969 Bytes

Contents

module Controll
  module Generators
    class SetupGenerator < ::Rails::Generators::Base
      desc 'Sets up a Rails 3 prooject with a folder structure in app for controll artifacts'

      argument :folders, type: :array, required: false, desc: 'creates specific folders for controll artifacts'

      def main_flow
        empty_directory "app/controll"
        inside "app/controll" do
          create_folders.each do |folder|
            empty_directory folder
          end
        end
      end

      protected

      def create_folders
        return mapper_folders unless folders.empty?
        valid_folders
      end

      def mapper_folders
        @mapper_folders ||= folders.map {|f| f.to_s.underscore }.select{|f| valid_artifact? f }
      end

      def valid_folder? folder
        valid_folders.include? folder.to_s.underscore
      end

      def valid_folders
        %w{executors flows notifiers commanders assistants}
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
controll-0.3.2 lib/generators/controll/setup_generator.rb
controll-0.3.1 lib/generators/controll/setup_generator.rb
controll-0.3.0 lib/generators/controll/setup_generator.rb