lightek_vpm 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57ba49acb0a7262e46f111972f6723e47fe83126b5975f1c5d9bc93afd51d3e0
4
- data.tar.gz: ff17b6cd2765c9dccee6409ac97e94a6d425a3f85b9ecf333c619352eee268df
3
+ metadata.gz: ebabfa9aab439ee66275cf6211fd21e00a3190e36658770dded372f8f95ba3e3
4
+ data.tar.gz: d43b92ce7c199e2f7d7e14637eff35993b55be71538717bc21fb2140ffb4af44
5
5
  SHA512:
6
- metadata.gz: 31b76fdf30f015c06a67d47a4f4bdea5bbc0cd69dd73b536e9dc8aab0a2d283a6090d0a7212aa07cefae450c4e08388ef92c08699518eb5f1858ff79d6ce5635
7
- data.tar.gz: 140567ecf8af9f04bcd81c53f7f1f5b17b0df8cce2349a7d3842df82319578f5ae0fe1c294ad3f7bc9942205d7dc08e0c9f9b60f18596ec94cc53e40b6b341f4
6
+ metadata.gz: d2b569be3929a4996f0c210eb3516a02a95ee940a12d644a557906b794fd68bfcc5624256331aed9a8379cbbdea2617fe590702773b101be7fa8a90d6527c138
7
+ data.tar.gz: 5511a8048c0f929c68378aeebc479efe86a2d102192af88565fbec14a648a521e2ed4fa16b7977aac40b05bc1ac8fe8578206dbfe34f07e86693b0512ef1b660
@@ -1,45 +1,44 @@
1
- source_root File.expand_path('../templates', __FILE__)
2
1
  require 'rails/generators'
3
2
  require 'generators/lightek_vpm/generator_helpers'
4
- module LightekVpm
5
- module Generators
6
- # Custom scaffolding generator
7
- class ControllerGenerator < Rails::Generators::NamedBase
8
- include Rails::Generators::ResourceHelper
9
- class_option :skip_show, type: :boolean, default: false, desc: "Skip "show" action"
10
-
11
- desc 'Generates controller, controller_spec and views for the model with the given NAME.'
12
-
13
- def copy_controller_and_spec_files
14
- template "controller.rb", File.join("app/controllers", "#{controller_file_name}_controller.rb")
15
- end
16
3
 
17
- def copy_view_files
18
- directory_path = File.join("app/views", controller_file_path)
19
- empty_directory directory_path
20
-
21
- view_files.each do |file_name|
22
- template "views/#{file_name}.html.erb", File.join(directory_path, "#{file_name}.html.erb")
4
+ module LightekVpm
5
+ module Generators
6
+ # Custom scaffolding generator
7
+ class ControllerGenerator < Rails::Generators::NamedBase
8
+ include Rails::Generators::ResourceHelper
9
+ class_option :skip_show, type: :boolean, default: false, desc: 'Skip "show" action'
10
+
11
+ desc 'Generates controller, controller_spec and views for the model with the given NAME.'
12
+
13
+ def copy_controller_and_spec_files
14
+ template 'controller.rb', File.join('app/controllers', "#{controller_file_name}_controller.rb")
15
+ end
16
+
17
+ def copy_view_files
18
+ directory_path = File.join('app/views', controller_file_path)
19
+ empty_directory directory_path
20
+
21
+ view_files.each do |file_name|
22
+ template "views/#{file_name}.html.erb", File.join(directory_path, "#{file_name}.html.erb")
23
+ end
24
+ end
25
+
26
+ def add_routes
27
+ routes_string = "resources :#{singular_name}"
28
+ routes_string += ', except: :show' unless show_action?
29
+ route routes_string
30
+ end
31
+
32
+ def add_abilities
33
+ ability_string = "n can :manage, #{class_name}, user_id: user.id"
34
+ inject_into_file "#{Rails.root}/app/models/ability.rb", ability_string, after: /def initialize[a-z()]+/i
35
+ end
36
+
37
+ private
38
+
39
+ def show_action?
40
+ !options['skip_show']
41
+ end
23
42
  end
24
43
  end
25
-
26
- def add_routes
27
- routes_string = "resources :#{singular_name}"
28
- routes_string += ', except: :show' unless show_action?
29
- route routes_string
30
- end
31
-
32
- def add_abilities
33
- ability_string = "n can :manage, #{class_name}, user_id: user.id"
34
- inject_into_file "#{Rails.root}/app/models/ability.rb", ability_string, after: /def initialize[a-z()]+/i
35
- end
36
-
37
- private
38
-
39
- def show_action?
40
- !options['skip_show']
41
- end
42
-
43
- end
44
- end
45
- end
44
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LightekVpm
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightek_vpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marlon Henry
@@ -17,9 +17,6 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - lib/generators/controller_generator.rb
21
- - lib/generators/generator_helpers.rb
22
- - lib/generators/init_generator.rb
23
20
  - lib/generators/lightek_vpm/controller_generator.rb
24
21
  - lib/generators/lightek_vpm/generator_helpers.rb
25
22
  - lib/generators/lightek_vpm/init_generator.rb
@@ -30,13 +27,6 @@ files:
30
27
  - lib/generators/lightek_vpm/templates/views/new.html.erb
31
28
  - lib/generators/lightek_vpm/templates/views/show.html.erb
32
29
  - lib/generators/lightek_vpm/test_generator.rb
33
- - lib/generators/templates/controller.rb
34
- - lib/generators/templates/views/_form.html.erb
35
- - lib/generators/templates/views/edit.html.erb
36
- - lib/generators/templates/views/index.html.erb
37
- - lib/generators/templates/views/new.html.erb
38
- - lib/generators/templates/views/show.html.erb
39
- - lib/generators/test_generator.rb
40
30
  - lib/lightek_vpm.rb
41
31
  - lib/lightek_vpm/version.rb
42
32
  homepage: http://lighteksystems.tech
@@ -1,45 +0,0 @@
1
- source_root File.expand_path('../templates', __FILE__)
2
- require 'rails/generators'
3
- require 'generators/lightek_vpm/generator_helpers'
4
- module LightekVpm
5
- module Generators
6
- # Custom scaffolding generator
7
- class ControllerGenerator < Rails::Generators::NamedBase
8
- include Rails::Generators::ResourceHelper
9
- class_option :skip_show, type: :boolean, default: false, desc: "Skip "show" action"
10
-
11
- desc 'Generates controller, controller_spec and views for the model with the given NAME.'
12
-
13
- def copy_controller_and_spec_files
14
- template "controller.rb", File.join("app/controllers", "#{controller_file_name}_controller.rb")
15
- end
16
-
17
- def copy_view_files
18
- directory_path = File.join("app/views", controller_file_path)
19
- empty_directory directory_path
20
-
21
- view_files.each do |file_name|
22
- template "views/#{file_name}.html.erb", File.join(directory_path, "#{file_name}.html.erb")
23
- end
24
- end
25
-
26
- def add_routes
27
- routes_string = "resources :#{singular_name}"
28
- routes_string += ', except: :show' unless show_action?
29
- route routes_string
30
- end
31
-
32
- def add_abilities
33
- ability_string = "n can :manage, #{class_name}, user_id: user.id"
34
- inject_into_file "#{Rails.root}/app/models/ability.rb", ability_string, after: /def initialize[a-z()]+/i
35
- end
36
-
37
- private
38
-
39
- def show_action?
40
- !options['skip_show']
41
- end
42
-
43
- end
44
- end
45
- end
@@ -1,50 +0,0 @@
1
- module LightekVpm
2
- module Generators
3
- # Some helpers for generating scaffolding
4
- module GeneratorHelpers
5
-
6
- attr_accessor :options, :attributes
7
-
8
- private
9
-
10
- def model_columns_for_attributes
11
- class_name.constantize.columns.reject do |column|
12
- column.name.to_s =~ /^(id|user_id|created_at|updated_at)$/
13
- end
14
- end
15
-
16
- def editable_attributes
17
- attributes ||= model_columns_for_attributes.map do |column|
18
- Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
19
- end
20
- end
21
-
22
- def view_files
23
- actions = %w(index new edit _form)
24
- actions << 'show' if show_action?
25
- actions
26
- end
27
-
28
- def all_actions
29
- actions = %w(index new create edit update destroy)
30
- actions << 'show' if show_action?
31
- actions
32
- end
33
-
34
- def controller_methods(dir_name)
35
- all_actions.map do |action|
36
- read_template("#{dir_name}/#{action}.rb")
37
- end.join("n").strip
38
- end
39
-
40
- def read_template(relative_path)
41
- ERB.new(File.read(source_path(relative_path)), nil, '-').result(binding)
42
- end
43
-
44
- def source_path(relative_path)
45
- File.expand_path(File.join("../templates/", relative_path), __FILE__)
46
- end
47
-
48
- end
49
- end
50
- End
@@ -1,54 +0,0 @@
1
- source_root File.expand_path('../templates', __FILE__)
2
- require 'rails/generators'
3
- module LightekVpm
4
- module Generators
5
- class InitGenerator < Rails::Generators::Base
6
-
7
- def add_gems_needed
8
- desc "Adding the gems and models needed for base work"
9
- # Add Bootstrap gem
10
- puts "Adding Bootstrap gem..."
11
- gem 'bootstrap', '~> 5.3.3'
12
-
13
- # Run bundle install
14
- puts "Running bundle install..."
15
- Bundler.with_clean_env { run 'bundle install' }
16
-
17
- # Add Devise gem
18
- puts "Adding Devise gem..."
19
- gem 'devise'
20
- Bundler.with_clean_env { run 'bundle install' }
21
-
22
- # Run Devise installation
23
- puts "Now installing Devise..."
24
- generate 'devise:install'
25
-
26
- # Create Devise User model
27
- puts "Creating User model with Devise..."
28
- generate 'devise User role:integer first_name:string last_name:string bio:text website:string twitter:string facebook:string instagram:string dob:date street:string city:string state:string'
29
- puts "Running db migration for user"
30
- rake 'db:migrate'
31
-
32
-
33
- # Add CanCanCan gem
34
- puts "Adding CanCanCan gem..."
35
- gem 'cancancan'
36
- Bundler.with_clean_env { run 'bundle install' }
37
-
38
- # Run CanCanCan installation (if needed)
39
- # Replace the following lines with CanCanCan installation commands if necessary
40
-
41
- # Add ActionText gem
42
- puts "Adding ActionText gem..."
43
- gem 'actiontext'
44
- Bundler.with_clean_env { run 'bundle install' }
45
-
46
- # Install Action Text
47
- puts "Installing Action Text..."
48
- generate 'action_text:install'
49
- rake 'db:migrate'
50
- end
51
-
52
- end
53
- end
54
- end
@@ -1,47 +0,0 @@
1
- class <%= controller_class_name %>Controller < ApplicationController
2
- before_action :authenticate_user!
3
- load_and_authorize_resource
4
-
5
- def index
6
- end
7
-
8
- <% if show_action? -%>
9
-
10
- def show
11
- end
12
- <% end -%>
13
-
14
- def new
15
- end
16
-
17
- def create
18
- if @<%= singular_name %>.save
19
- redirect_to @<%= singular_name %>, notice: '<%= human_name %> was successfully created.'
20
- else
21
- render :new
22
- end
23
- end
24
-
25
- def edit
26
- end
27
-
28
- def update
29
- if @<%= singular_name %>.update(<%= singular_name %>_params)
30
- redirect_to @<%= singular_name %>, notice: '<%= human_name %> was successfully updated.'
31
- else
32
- render :edit
33
- end
34
- end
35
-
36
- def destroy
37
- @<%= singular_name %>.destroy
38
- redirect_to <%= plural_name %>_url, notice: '<%= human_name %> was successfully destroyed.'
39
- end
40
-
41
- private
42
-
43
- def <%= singular_name %>_params
44
- params.require(:<%= singular_name %>).permit(<%= editable_attributes.map { |a| a.name.prepend(':') }.join(', ') %>)
45
- end
46
-
47
- end
@@ -1,26 +0,0 @@
1
- <%= "<%= form_for @#{singular_name} do |f| %%>" %>
2
-
3
- <div class="row">
4
- <div class="col-md-4">
5
- <%= "<% if @#{singular_name}.errors.any? %%>" %>
6
- <div id="error_explanation">
7
- <%= "<h2><%= pluralize(@#{singular_name}.errors.count, 'error') %%>" %> prohibited this <%= class_name %> from being saved:</h2>
8
- <ul class="list-unstyled">
9
- <%= "<% @#{singular_name}.errors.full_messages.each do |message| %%>" %>
10
- <%= "<li><%= message %%></li>" %>
11
- <%= "<% end %%>" %>
12
- </ul>
13
- </div>
14
- <%= "<% end %%>" %>
15
- <% editable_attributes.each do |attribute| %>
16
- <div class="form-group">
17
- <%= "<%= f.label :#{attribute.name} %%>" %>
18
- <%= "<%= f.#{attribute.field_type} :#{attribute.name}, class: \"form-control\" %%>" %>
19
- </div>
20
- <% end -%>
21
-
22
- <%= "<%= f.submit 'Submit', class: \"btn btn-success\" %%>" %>
23
- </div>
24
- </div>
25
-
26
- <%= "<% end %%>" %>
@@ -1,2 +0,0 @@
1
- <h3>Edit <%= human_name %></h3>
2
- <%= "<%= render 'form', #{singular_name}: @#{singular_name} %%>" %>
@@ -1,19 +0,0 @@
1
- <%= "<%= link_to 'Create new', new_#{singular_name}_path, class: 'btn btn-primary btn-sm mb-2' %%>" %>
2
-
3
- <table class="table table-sm">
4
- <tbody>
5
- <%= "<% @#{plural_name}.each do |#{singular_name}| %%>" %>
6
- <tr>
7
- <td> <%= "<%= #{singular_name}.id %%>" %> </td>
8
- <td> [ADD INFO] </td>
9
- <td>
10
- <% if show_action? -%>
11
- <%= "<%= link_to 'Show', #{singular_name}_path(#{singular_name}), class: 'btn btn-sm btn-outline-info' %%>" %>
12
- <% end -%>
13
- <%= "<%= link_to 'Edit', edit_#{singular_name}_path(#{singular_name}), class: 'btn btn-sm btn-outline-info' %%>" %>
14
- <%= "<%= link_to 'Destroy', #{singular_name}_path(#{singular_name}), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-outline-danger' %%>" %>
15
- </td>
16
- </tr>
17
- <%= "<% end %%>" %>
18
- </tbody>
19
- </table>
@@ -1,2 +0,0 @@
1
- <h3>Create <%= human_name %></h3>
2
- <%= "<%= render 'form', #{singular_name}: @#{singular_name} %%>" %>
@@ -1,12 +0,0 @@
1
- <div>
2
- <% editable_attributes.each do |attribute| -%>
3
- <dl class="row">
4
- <dt class="col-sm-3"><%= attribute.human_name.titleize %>:</dt>
5
- <dd class="col-sm-9"><%= "<%= @#{singular_name}.#{attribute.name} %%>" %></dd>
6
- </dl>
7
- <% end -%>
8
- </div>
9
- <p>
10
- <%= "<%= link_to 'Edit', edit_#{singular_name}_path(@#{singular_name}), class: 'btn btn-sm btn-outline-info' %%>" %>
11
- <%= "<%= link_to 'Destroy', #{singular_name}_path(@#{singular_name}), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-outline-danger' %%>" %>
12
- </p>
@@ -1,11 +0,0 @@
1
- require "thor"
2
-
3
- module LightekVpm
4
- class TestGenerator < Thor::Group
5
- include Thor::Actions
6
-
7
- def testing
8
- say "Testing this out to see if I got it right this in the main generator directory"
9
- end
10
- end
11
- end