Sha256: d1564f5dbd2f45f4512b3e75e5792572f6001aba272d41a81cd2ea5d69dcdf93

Contents?: true

Size: 1.1 KB

Versions: 17

Compression:

Stored size: 1.1 KB

Contents

# -*- encoding : utf-8 -*-
require 'rails/generators/migration'
require 'mdwa/dsl'

module Mdwa
  module Generators

    class UserGenerator < Rails::Generators::Base

      source_root File.expand_path('../templates', __FILE__)
      
      attr_accessor :user
      
      argument :user_name
      
      class_option :requirement, :type => :string, :desc => 'Requirement alias'

      def initialize(*args, &block)
        super
        @user = user_name.singularize.camelize
      end
    
      def generate_user
        file_name = "#{MDWA::DSL::USERS_PATH}#{@user.underscore}.rb"
        # if file doesn't exist, create it
        # if file exists, include the in_requirements clause
        if !File.exist?( Rails.root + file_name )
          template 'user.rb', file_name
        else
          append_to_file( file_name, "\nMDWA::DSL.user('#{@user}').in_requirements << '#{options.requirement}'" ) unless options.requirement.blank?
        end
        
        generate "mdwa:entity #{@user} --user --requirement=\"#{options.requirement}\""
      end

    end # class user generator

  end # generators
end # mdwa

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mdd-3.1.4 lib/generators/mdwa/user/user_generator.rb
mdd-3.1.2 lib/generators/mdwa/user/user_generator.rb
mdd-3.1.1 lib/generators/mdwa/user/user_generator.rb
mdd-3.1.0 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.20 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.19 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.18 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.17 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.16 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.15 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.14 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.13 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.10 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.9 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.8 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.7 lib/generators/mdwa/user/user_generator.rb
mdd-3.0.6 lib/generators/mdwa/user/user_generator.rb