effective_developer 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +31 -9
 - data/app/models/effective/code_writer.rb +218 -0
 - data/lib/effective_developer/version.rb +1 -1
 - data/lib/generators/effective/ability_generator.rb +78 -0
 - data/lib/generators/effective/controller_generator.rb +27 -9
 - data/lib/generators/effective/datatable_generator.rb +20 -2
 - data/lib/generators/effective/form_generator.rb +46 -0
 - data/lib/generators/effective/helpers.rb +94 -11
 - data/lib/generators/effective/menu_generator.rb +52 -0
 - data/lib/generators/effective/migration_generator.rb +16 -2
 - data/lib/generators/effective/model_generator.rb +23 -1
 - data/lib/generators/effective/route_generator.rb +58 -2
 - data/lib/generators/effective/scaffold_controller_generator.rb +51 -0
 - data/lib/generators/effective/scaffold_generator.rb +25 -52
 - data/lib/generators/effective/views_generator.rb +47 -0
 - data/lib/scaffolds/controllers/controller.rb +142 -0
 - data/lib/scaffolds/datatables/datatable.rb +18 -0
 - data/lib/scaffolds/forms/_form.html.haml +9 -0
 - data/lib/{generators/effective_developer/csv_importer.rb.erb → scaffolds/importers/csv_importer.rb} +0 -0
 - data/lib/scaffolds/models/model.rb +48 -0
 - data/lib/scaffolds/views/_resource.html.haml +7 -0
 - data/lib/scaffolds/views/edit.html.haml +3 -0
 - data/lib/scaffolds/views/index.html.haml +10 -0
 - data/lib/scaffolds/views/new.html.haml +3 -0
 - data/lib/scaffolds/views/show.html.haml +3 -0
 - data/lib/tasks/effective_csv_importer.rake +1 -1
 - metadata +18 -12
 - data/app/scaffolds/controllers/controller.rb +0 -13
 - data/app/scaffolds/datatables/datatable.rb +0 -14
 - data/app/scaffolds/models/model.rb +0 -15
 - data/app/scaffolds/views/_form.html.haml +0 -15
 - data/app/scaffolds/views/edit.html.haml +0 -7
 - data/app/scaffolds/views/index.html.haml +0 -25
 - data/app/scaffolds/views/new.html.haml +0 -5
 - data/app/scaffolds/views/show.html.haml +0 -11
 - data/lib/generators/effective/view_generator.rb +0 -40
 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # rails generate effective:views NAME [action action] [options]
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Generates a view
         
     | 
| 
      
 4 
     | 
    
         
            +
            # rails generate effective:views Thing
         
     | 
| 
      
 5 
     | 
    
         
            +
            # rails generate effective:views Thing index show new
         
     | 
| 
      
 6 
     | 
    
         
            +
            # rails generate effective:views Thing index show --attributes name:string description:text
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            module Effective
         
     | 
| 
      
 9 
     | 
    
         
            +
              module Generators
         
     | 
| 
      
 10 
     | 
    
         
            +
                class ViewsGenerator < Rails::Generators::NamedBase
         
     | 
| 
      
 11 
     | 
    
         
            +
                  include Helpers
         
     | 
| 
      
 12 
     | 
    
         
            +
                  source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  desc 'Creates views in your app/views folder.'
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  argument :actions, type: :array, default: ['crud'], banner: 'action action'
         
     | 
| 
      
 17 
     | 
    
         
            +
                  class_option :attributes, type: :array, default: [], desc: 'Included form attributes, otherwise read from model'
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  def assign_attributes
         
     | 
| 
      
 20 
     | 
    
         
            +
                    @attributes = (invoked_attributes.presence || klass_attributes).map do |attribute|
         
     | 
| 
      
 21 
     | 
    
         
            +
                      Rails::Generators::GeneratedAttribute.parse(attribute)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    self.class.send(:attr_reader, :attributes)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  def invoke_views
         
     | 
| 
      
 28 
     | 
    
         
            +
                    say_status :invoke, :views, :white
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def create_views
         
     | 
| 
      
 32 
     | 
    
         
            +
                    (invoked_actions & available_actions).each do |action|
         
     | 
| 
      
 33 
     | 
    
         
            +
                      template "views/#{action}.html.haml", File.join('app/views', namespace_path, (namespace_path.present? ? '' : class_path), plural_name, "#{action}.html.haml")
         
     | 
| 
      
 34 
     | 
    
         
            +
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    template "views/_resource.html.haml", File.join('app/views', namespace_path, (namespace_path.present? ? '' : class_path), plural_name, "_#{singular_name}.html.haml")
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  private
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  def available_actions
         
     | 
| 
      
 42 
     | 
    
         
            +
                    %w(index new show edit)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,142 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <% if namespaced? -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            require_dependency '<%= namespaced_path %>/application_controller'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 5 
     | 
    
         
            +
            <% module_namespacing do -%>
         
     | 
| 
      
 6 
     | 
    
         
            +
            class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.presence, ApplicationController].compact.join('::') %>
         
     | 
| 
      
 7 
     | 
    
         
            +
              before_action :authenticate_user! # Devise enforce user is present
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            <% if actions.delete('index') -%>
         
     | 
| 
      
 10 
     | 
    
         
            +
              def index
         
     | 
| 
      
 11 
     | 
    
         
            +
                @page_title = '<%= plural_name.titleize %>'
         
     | 
| 
      
 12 
     | 
    
         
            +
                authorize! :index, <%= class_name %>
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                @datatable = Effective::Datatables::<%= namespaced_class_name %>.new(params[:scopes])
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 18 
     | 
    
         
            +
            <% if actions.delete('new') -%>
         
     | 
| 
      
 19 
     | 
    
         
            +
              def new
         
     | 
| 
      
 20 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.new
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                @page_title = 'New <%= human_name %>'
         
     | 
| 
      
 23 
     | 
    
         
            +
                authorize! :new, @<%= singular_name %>
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 27 
     | 
    
         
            +
            <% if actions.delete('create') -%>
         
     | 
| 
      
 28 
     | 
    
         
            +
              def create
         
     | 
| 
      
 29 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.new(permitted_params)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                @page_title = 'New <%= human_name %>'
         
     | 
| 
      
 32 
     | 
    
         
            +
                authorize! :create, @<%= singular_name %>
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                if @<%= singular_name %>.save
         
     | 
| 
      
 35 
     | 
    
         
            +
                  flash[:success] = 'Successfully created <%= singular_name %>'
         
     | 
| 
      
 36 
     | 
    
         
            +
                  redirect_to(redirect_path)
         
     | 
| 
      
 37 
     | 
    
         
            +
                else
         
     | 
| 
      
 38 
     | 
    
         
            +
                  flash.now[:danger] = "Unable to create <%= singular_name %>: #{@<%= singular_name %>.errors.full_messages.to_sentence}"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  render :new
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 44 
     | 
    
         
            +
            <% if actions.delete('show') -%>
         
     | 
| 
      
 45 
     | 
    
         
            +
              def show
         
     | 
| 
      
 46 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                @page_title = @<%= singular_name %>.to_s
         
     | 
| 
      
 49 
     | 
    
         
            +
                authorize! :show, @<%= singular_name %>
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 53 
     | 
    
         
            +
            <% if actions.delete('edit') -%>
         
     | 
| 
      
 54 
     | 
    
         
            +
              def edit
         
     | 
| 
      
 55 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                @page_title = "Edit #{@<%= singular_name %>}"
         
     | 
| 
      
 58 
     | 
    
         
            +
                authorize! :edit, @<%= singular_name %>
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 62 
     | 
    
         
            +
            <% if actions.delete('update') -%>
         
     | 
| 
      
 63 
     | 
    
         
            +
              def update
         
     | 
| 
      
 64 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                @page_title = "Edit #{@<%= singular_name %>}"
         
     | 
| 
      
 67 
     | 
    
         
            +
                authorize! :update, @<%= singular_name %>
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                if @<%= singular_name %>.update_attributes(permitted_params)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  flash[:success] = 'Successfully updated <%= singular_name %>'
         
     | 
| 
      
 71 
     | 
    
         
            +
                  redirect_to(redirect_path)
         
     | 
| 
      
 72 
     | 
    
         
            +
                else
         
     | 
| 
      
 73 
     | 
    
         
            +
                  flash.now[:danger] = "Unable to update <%= singular_name %>: #{@<%= singular_name %>.errors.full_messages.to_sentence}"
         
     | 
| 
      
 74 
     | 
    
         
            +
                  render :edit
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 79 
     | 
    
         
            +
            <% if actions.delete('destroy') -%>
         
     | 
| 
      
 80 
     | 
    
         
            +
              def destroy
         
     | 
| 
      
 81 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         
     | 
| 
      
 82 
     | 
    
         
            +
                authorize! :destroy, @<%= singular_name %>
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                if @<%= singular_name %>.destroy
         
     | 
| 
      
 85 
     | 
    
         
            +
                  flash[:success] = 'Successfully deleted <%= singular_name %>'
         
     | 
| 
      
 86 
     | 
    
         
            +
                else
         
     | 
| 
      
 87 
     | 
    
         
            +
                  flash.now[:danger] = "Unable to delete <%= singular_name %>: #{@<%= singular_name %>.errors.full_messages.to_sentence}"
         
     | 
| 
      
 88 
     | 
    
         
            +
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                redirect_to <%= index_path %>
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 94 
     | 
    
         
            +
            <% if actions.delete('unarchive') -%>
         
     | 
| 
      
 95 
     | 
    
         
            +
              def unarchive
         
     | 
| 
      
 96 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         
     | 
| 
      
 97 
     | 
    
         
            +
                authorize! :unarchive, @<%= singular_name %>
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                if @<%= singular_name %>.unarchive
         
     | 
| 
      
 100 
     | 
    
         
            +
                  flash[:success] = 'Successfully restored <%= singular_name %>'
         
     | 
| 
      
 101 
     | 
    
         
            +
                else
         
     | 
| 
      
 102 
     | 
    
         
            +
                  flash.now[:danger] = "Unable to restore <%= singular_name %>: #{@<%= singular_name %>.errors.full_messages.to_sentence}"
         
     | 
| 
      
 103 
     | 
    
         
            +
                end
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                redirect_to <%= index_path %>
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 109 
     | 
    
         
            +
            <% actions.each do |action| -%>
         
     | 
| 
      
 110 
     | 
    
         
            +
              def <%= action %>
         
     | 
| 
      
 111 
     | 
    
         
            +
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                @page_title = "<%= action.titleize %> #{@<%= singular_name %>}"
         
     | 
| 
      
 114 
     | 
    
         
            +
                authorize! :<%= action %>, @<%= singular_name %>
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 118 
     | 
    
         
            +
              private
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
              def permitted_params
         
     | 
| 
      
 121 
     | 
    
         
            +
                params.require(:<%= singular_name %>).permit(:id,
         
     | 
| 
      
 122 
     | 
    
         
            +
            <% attributes_names.each_slice(8).with_index do |slice, index| -%>
         
     | 
| 
      
 123 
     | 
    
         
            +
                  <%= slice.map { |name| permitted_param_for(name) }.join(', ') %><%= ',' if ((index+1) * 8) < attributes.length %>
         
     | 
| 
      
 124 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 125 
     | 
    
         
            +
                )
         
     | 
| 
      
 126 
     | 
    
         
            +
              end
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
              def redirect_path
         
     | 
| 
      
 129 
     | 
    
         
            +
                case params[:commit].to_s
         
     | 
| 
      
 130 
     | 
    
         
            +
                when 'Save'
         
     | 
| 
      
 131 
     | 
    
         
            +
                  <%= edit_path %>
         
     | 
| 
      
 132 
     | 
    
         
            +
                when 'Save and Continue'
         
     | 
| 
      
 133 
     | 
    
         
            +
                  <%= index_path %>
         
     | 
| 
      
 134 
     | 
    
         
            +
                when 'Save and Add New'
         
     | 
| 
      
 135 
     | 
    
         
            +
                  <%= new_path %>
         
     | 
| 
      
 136 
     | 
    
         
            +
                else
         
     | 
| 
      
 137 
     | 
    
         
            +
                  raise 'Unexpected redirect path'
         
     | 
| 
      
 138 
     | 
    
         
            +
                end
         
     | 
| 
      
 139 
     | 
    
         
            +
              end
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
            end
         
     | 
| 
      
 142 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Effective
         
     | 
| 
      
 2 
     | 
    
         
            +
              module Datatables
         
     | 
| 
      
 3 
     | 
    
         
            +
                class <%= namespaced_class_name %> < Effective::Datatable
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                  datatable do<% attributes.each do |attribute| %>
         
     | 
| 
      
 6 
     | 
    
         
            +
                    table_column :<%= attribute.name -%>
         
     | 
| 
      
 7 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                    actions_column
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def collection
         
     | 
| 
      
 13 
     | 
    
         
            +
                    <%= class_name %>.all
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = simple_form_for(<%= form_for %>) do |f|
         
     | 
| 
      
 2 
     | 
    
         
            +
            <% for attribute in attributes -%>
         
     | 
| 
      
 3 
     | 
    
         
            +
              = f.input :<%= attribute.name %>
         
     | 
| 
      
 4 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              %p.text-right
         
     | 
| 
      
 7 
     | 
    
         
            +
                = f.button :submit, 'Save', data: { disable_with: 'Saving...' }
         
     | 
| 
      
 8 
     | 
    
         
            +
                = f.button :submit, 'Save and Continue', data: { disable_with: 'Saving...' }
         
     | 
| 
      
 9 
     | 
    
         
            +
                = f.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
         
     | 
    
        data/lib/{generators/effective_developer/csv_importer.rb.erb → scaffolds/importers/csv_importer.rb}
    RENAMED
    
    | 
         
            File without changes
         
     | 
| 
         @@ -0,0 +1,48 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <% module_namespacing do -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            class <%= class_name %> < <%= parent_class_name.classify %>
         
     | 
| 
      
 3 
     | 
    
         
            +
            <% attributes.select(&:reference?).each do |attribute| -%>
         
     | 
| 
      
 4 
     | 
    
         
            +
              belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %>
         
     | 
| 
      
 5 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 6 
     | 
    
         
            +
            <% attributes.select(&:token?).each do |attribute| -%>
         
     | 
| 
      
 7 
     | 
    
         
            +
              has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
         
     | 
| 
      
 8 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 9 
     | 
    
         
            +
            <% if attributes.any?(&:password_digest?) -%>
         
     | 
| 
      
 10 
     | 
    
         
            +
              has_secure_password
         
     | 
| 
      
 11 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              # Attributes
         
     | 
| 
      
 14 
     | 
    
         
            +
            <% attributes.each do |attribute| -%>
         
     | 
| 
      
 15 
     | 
    
         
            +
              # <%= attribute.name.ljust(max_attribute_name_length) %> :<%= attribute.type %>
         
     | 
| 
      
 16 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 17 
     | 
    
         
            +
            <% if archived_attribute.present? -%>
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              scope :<%= plural_table_name %>, -> { where(archived: false) }
         
     | 
| 
      
 20 
     | 
    
         
            +
              scope :archived, -> { where(archived: true) }
         
     | 
| 
      
 21 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            <% attributes.each do |attribute| -%>
         
     | 
| 
      
 24 
     | 
    
         
            +
              validates :<%= attribute.name %>, presence: true
         
     | 
| 
      
 25 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            <% if to_s_attribute.present? -%>
         
     | 
| 
      
 28 
     | 
    
         
            +
              def to_s
         
     | 
| 
      
 29 
     | 
    
         
            +
                <%= to_s_attribute.name %> || 'New <%= human_name %>'
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            <% else -%>
         
     | 
| 
      
 32 
     | 
    
         
            +
              def to_s
         
     | 
| 
      
 33 
     | 
    
         
            +
                '<%= human_name %>'
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 36 
     | 
    
         
            +
            <% if archived_attribute.present? -%>
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              def destroy
         
     | 
| 
      
 39 
     | 
    
         
            +
                update_column(:archived, true) # This intentionally skips validation
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              def unarchive
         
     | 
| 
      
 43 
     | 
    
         
            +
                update_column(:archived, false) # This intentionally skips validation
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            end
         
     | 
| 
      
 48 
     | 
    
         
            +
            <% end -%>
         
     | 
| 
         @@ -0,0 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            %h1= @page_title
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            - if can?(:new, <%= class_name %>)
         
     | 
| 
      
 4 
     | 
    
         
            +
              %p.text-right= link_to 'New <%= human_name %>', <%= new_path %>, class: 'btn btn-primary'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            - if @datatable.present?
         
     | 
| 
      
 7 
     | 
    
         
            +
              = render_datatable_scopes(@datatable)
         
     | 
| 
      
 8 
     | 
    
         
            +
              = render_datatable(@datatable)
         
     | 
| 
      
 9 
     | 
    
         
            +
            - else
         
     | 
| 
      
 10 
     | 
    
         
            +
              %p There are no <%= plural_name %>.
         
     | 
| 
         @@ -57,7 +57,7 @@ namespace :csv do 
     | 
|
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                  require 'csv'
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                  generator = ERB.new(File.read(File.dirname(__FILE__) + '/../ 
     | 
| 
      
 60 
     | 
    
         
            +
                  generator = ERB.new(File.read(File.dirname(__FILE__) + '/../scaffolds/importers/csv_importer.rb'))
         
     | 
| 
       61 
61 
     | 
    
         
             
                  letters = ('A'..'AT').to_a
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                  Dir['lib/csv_importers/data/*.csv'].each do |file|
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: effective_developer
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Code and Effect
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-12- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-12-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -35,29 +35,35 @@ files: 
     | 
|
| 
       35 
35 
     | 
    
         
             
            - README.md
         
     | 
| 
       36 
36 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       37 
37 
     | 
    
         
             
            - app/models/effective/access_denied.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - app/models/effective/code_writer.rb
         
     | 
| 
       38 
39 
     | 
    
         
             
            - app/models/effective/csv_importer.rb
         
     | 
| 
       39 
     | 
    
         
            -
            - app/scaffolds/controllers/controller.rb
         
     | 
| 
       40 
     | 
    
         
            -
            - app/scaffolds/datatables/datatable.rb
         
     | 
| 
       41 
     | 
    
         
            -
            - app/scaffolds/models/model.rb
         
     | 
| 
       42 
     | 
    
         
            -
            - app/scaffolds/views/_form.html.haml
         
     | 
| 
       43 
     | 
    
         
            -
            - app/scaffolds/views/edit.html.haml
         
     | 
| 
       44 
     | 
    
         
            -
            - app/scaffolds/views/index.html.haml
         
     | 
| 
       45 
     | 
    
         
            -
            - app/scaffolds/views/new.html.haml
         
     | 
| 
       46 
     | 
    
         
            -
            - app/scaffolds/views/show.html.haml
         
     | 
| 
       47 
40 
     | 
    
         
             
            - config/effective_developer.rb
         
     | 
| 
       48 
41 
     | 
    
         
             
            - lib/effective_developer.rb
         
     | 
| 
       49 
42 
     | 
    
         
             
            - lib/effective_developer/engine.rb
         
     | 
| 
       50 
43 
     | 
    
         
             
            - lib/effective_developer/version.rb
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/generators/effective/ability_generator.rb
         
     | 
| 
       51 
45 
     | 
    
         
             
            - lib/generators/effective/controller_generator.rb
         
     | 
| 
       52 
46 
     | 
    
         
             
            - lib/generators/effective/datatable_generator.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/generators/effective/form_generator.rb
         
     | 
| 
       53 
48 
     | 
    
         
             
            - lib/generators/effective/helpers.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - lib/generators/effective/menu_generator.rb
         
     | 
| 
       54 
50 
     | 
    
         
             
            - lib/generators/effective/migration_generator.rb
         
     | 
| 
       55 
51 
     | 
    
         
             
            - lib/generators/effective/model_generator.rb
         
     | 
| 
       56 
52 
     | 
    
         
             
            - lib/generators/effective/route_generator.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/generators/effective/scaffold_controller_generator.rb
         
     | 
| 
       57 
54 
     | 
    
         
             
            - lib/generators/effective/scaffold_generator.rb
         
     | 
| 
       58 
     | 
    
         
            -
            - lib/generators/effective/ 
     | 
| 
       59 
     | 
    
         
            -
            - lib/generators/effective_developer/csv_importer.rb.erb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/generators/effective/views_generator.rb
         
     | 
| 
       60 
56 
     | 
    
         
             
            - lib/generators/effective_developer/install_generator.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/scaffolds/controllers/controller.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/scaffolds/datatables/datatable.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - lib/scaffolds/forms/_form.html.haml
         
     | 
| 
      
 60 
     | 
    
         
            +
            - lib/scaffolds/importers/csv_importer.rb
         
     | 
| 
      
 61 
     | 
    
         
            +
            - lib/scaffolds/models/model.rb
         
     | 
| 
      
 62 
     | 
    
         
            +
            - lib/scaffolds/views/_resource.html.haml
         
     | 
| 
      
 63 
     | 
    
         
            +
            - lib/scaffolds/views/edit.html.haml
         
     | 
| 
      
 64 
     | 
    
         
            +
            - lib/scaffolds/views/index.html.haml
         
     | 
| 
      
 65 
     | 
    
         
            +
            - lib/scaffolds/views/new.html.haml
         
     | 
| 
      
 66 
     | 
    
         
            +
            - lib/scaffolds/views/show.html.haml
         
     | 
| 
       61 
67 
     | 
    
         
             
            - lib/tasks/effective_csv_importer.rake
         
     | 
| 
       62 
68 
     | 
    
         
             
            - lib/tasks/pg_pull.rake
         
     | 
| 
       63 
69 
     | 
    
         
             
            - lib/tasks/reset_pk_sequence.rake
         
     | 
| 
         @@ -1,13 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <% if namespaced? -%>
         
     | 
| 
       2 
     | 
    
         
            -
            require_dependency "<%= namespaced_path %>/application_controller"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
       5 
     | 
    
         
            -
            <% module_namespacing do -%>
         
     | 
| 
       6 
     | 
    
         
            -
            class <%= class_name %>Controller < ApplicationController
         
     | 
| 
       7 
     | 
    
         
            -
            <% actions.each do |action| -%>
         
     | 
| 
       8 
     | 
    
         
            -
              def <%= action %>
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
            <%= "\n" unless action == actions.last -%>
         
     | 
| 
       11 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
       13 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
         @@ -1,15 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            <% module_namespacing do -%>
         
     | 
| 
       2 
     | 
    
         
            -
            class <%= class_name %> < <%= parent_class_name.classify %>
         
     | 
| 
       3 
     | 
    
         
            -
            <% attributes.select(&:reference?).each do |attribute| -%>
         
     | 
| 
       4 
     | 
    
         
            -
              belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %>
         
     | 
| 
       5 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
       6 
     | 
    
         
            -
            <% attributes.select(&:token?).each do |attribute| -%>
         
     | 
| 
       7 
     | 
    
         
            -
              has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
         
     | 
| 
       8 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
       9 
     | 
    
         
            -
            <% if attributes.any?(&:password_digest?) -%>
         
     | 
| 
       10 
     | 
    
         
            -
              has_secure_password
         
     | 
| 
       11 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
| 
       13 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            MINE
         
     | 
| 
         @@ -1,15 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            = form_for @<%= singular_table_name %> do |f|
         
     | 
| 
       2 
     | 
    
         
            -
              - if @<%= singular_table_name %>.errors.any?
         
     | 
| 
       3 
     | 
    
         
            -
                #error_explanation
         
     | 
| 
       4 
     | 
    
         
            -
                  %h2= "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
         
     | 
| 
       5 
     | 
    
         
            -
                  %ul
         
     | 
| 
       6 
     | 
    
         
            -
                    - @<%= singular_table_name %>.errors.full_messages.each do |msg|
         
     | 
| 
       7 
     | 
    
         
            -
                      %li= msg
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            <% for attribute in attributes -%>
         
     | 
| 
       10 
     | 
    
         
            -
              .field
         
     | 
| 
       11 
     | 
    
         
            -
                = f.label :<%= attribute.name %>
         
     | 
| 
       12 
     | 
    
         
            -
                = f.<%= attribute.field_type %> :<%= attribute.name %>
         
     | 
| 
       13 
     | 
    
         
            -
            <% end -%>
         
     | 
| 
       14 
     | 
    
         
            -
              .actions
         
     | 
| 
       15 
     | 
    
         
            -
                = f.submit 'Save'
         
     |