rails_app_generator 0.3.1 → 0.3.2

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +22 -1
  4. data/after_templates/addons/factory_bot/_.rb +82 -0
  5. data/after_templates/addons/factory_bot/app/controllers/home_controller.rb +10 -0
  6. data/after_templates/addons/factory_bot/app/services/seed_service.rb +35 -0
  7. data/after_templates/addons/factory_bot/app/views/home/index.html.erb +3 -0
  8. data/after_templates/addons/factory_bot/app/views/layouts/_footer.html.erb +0 -0
  9. data/after_templates/addons/factory_bot/app/views/layouts/_navbar.html.erb +10 -0
  10. data/after_templates/addons/factory_bot/app/views/layouts/application.html.erb +29 -0
  11. data/after_templates/addons/factory_bot/db/seeds.rb +1 -0
  12. data/after_templates/addons/factory_bot/factories.rb +73 -0
  13. data/after_templates/addons/factory_bot/factory-create-user.png +0 -0
  14. data/after_templates/addons/factory_bot/factory-employee-bad.png +0 -0
  15. data/after_templates/addons/factory_bot/factory-employee-good.png +0 -0
  16. data/after_templates/addons/factory_bot/factory-role.png +0 -0
  17. data/after_templates/addons/factory_bot/factory-video.png +0 -0
  18. data/after_templates/application/klueless/.rubocop.yml +40 -0
  19. data/after_templates/application/klueless/_.rb +28 -14
  20. data/after_templates/application/klueless/app/avo/filters/rubocop_entry_cop_filter.rb +15 -0
  21. data/after_templates/application/klueless/app/avo/filters/rubocop_entry_filename_filter.rb +13 -0
  22. data/after_templates/application/klueless/app/avo/filters/rubocop_entry_message_filter.rb +13 -0
  23. data/after_templates/application/klueless/app/avo/filters/rubocop_entry_status_filter.rb +15 -0
  24. data/after_templates/application/klueless/app/avo/filters/table_count_entry_tablename_filter.rb +13 -0
  25. data/after_templates/application/klueless/app/avo/resource_tools/rubocop_info.rb +4 -0
  26. data/after_templates/application/klueless/app/avo/resources/rubocop_entry_resource.rb +28 -0
  27. data/after_templates/application/klueless/app/avo/resources/rubocop_resource.rb +8 -7
  28. data/after_templates/application/klueless/app/avo/resources/table_count_entry_resource.rb +18 -0
  29. data/after_templates/application/klueless/app/controllers/home_controller.rb +1 -1
  30. data/after_templates/application/klueless/app/services/seed_service.rb +1 -1
  31. data/after_templates/application/klueless/app/views/home/index.html.erb +2 -2
  32. data/after_templates/application/klueless/app/views/layouts/_navbar.html.erb +1 -4
  33. data/after_templates/application/klueless/config/initializers/avo.rb +4 -2
  34. data/after_templates/application/klueless/db/views/{rubocop_logs_v01.sql → rubocop_entries_v01.sql} +2 -2
  35. data/after_templates/application/klueless/db/views/table_count_entries_v01.sql +11 -0
  36. data/docs/last_run/app_generator_data.json +10 -11
  37. data/docs/last_run/rails_options_data.json +14 -12
  38. data/lib/rails_app_generator/app_generator.rb +18 -4
  39. data/lib/rails_app_generator/starter.rb +3 -0
  40. data/lib/rails_app_generator/version.rb +1 -1
  41. data/package-lock.json +2 -2
  42. data/package.json +1 -1
  43. data/profiles/addons/factory_bot.json +18 -0
  44. data/profiles/addons/faker.json +1 -1
  45. data/profiles/application/klueless.json +3 -1
  46. data/templates/README.md.erb +2 -2
  47. data/templates/thor_task/profile/app/services/seed_service.rb +8 -4
  48. data/templates/thor_task/profile/profile.json.tt +2 -1
  49. metadata +28 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c6189ce2463be4e23bbda3e3b1d17c03142b60a7a754feeb7d7dcc75c26fc5f
4
- data.tar.gz: 2d216396594ae4ee2d86626c9b3202419ae6a69536f564e7ba3a044771f7bd0d
3
+ metadata.gz: c53c84982de8f9b1f3180f4c84b7527a04cc623dac815cdec90d325f7e56183f
4
+ data.tar.gz: 0f2d44fc8597836b396faa7b3ef6995896e41222b34362a0cb73802bd2fbd70d
5
5
  SHA512:
6
- metadata.gz: 56a17d613f635bb7242ca6c04a93f0ec0f8a03ca987a30813ad15ce3f9d015eb174d8ec7d14d24a12cab3e0011756d702e67704ddfb2841e39ca1e18b1921683
7
- data.tar.gz: 35bb905e32d9d650f828754ac4696ddd13c55ed9503f9bd270f30addae97c3a8b6e53ef8cd450c70a65b5630ac5437e1db8e0fc1a4a55a25c5a416c71e92c82f
6
+ metadata.gz: 0d2f6fe3d00ca2befc5acaf668f58f655c60e7f0a0d14f7670067f5e3847861e92cf93a927d284d36546a26bf85ea8beebb7ac76cc183d88c0bf2b06e8c60d18
7
+ data.tar.gz: 24704cce18d58445b1a1d69122df8e098e3f2b87627030df4b1e863931e7320e0da89e71b8e5d4ac7e886c03c01d7b593aec20da3cc3165703771e8b5945c4c9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.3.1](https://github.com/klueless-io/rails_app_generator/compare/v0.3.0...v0.3.1) (2022-09-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * rename to when_folder_exist ([3363b0c](https://github.com/klueless-io/rails_app_generator/commit/3363b0c5df5c161f3578ae422b79c3bb7f3b863e))
7
+
1
8
  # [0.3.0](https://github.com/klueless-io/rails_app_generator/compare/v0.2.43...v0.3.0) (2022-09-02)
2
9
 
3
10
 
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
  gem install rails_app_generator
23
23
  ```
24
24
 
25
- Use the Gem
25
+ ### Use the Gem
26
26
 
27
27
  ```
28
28
  rag rag-simple
@@ -30,6 +30,27 @@ rag rag-tailwind
30
30
  rag rag-bootstrap
31
31
  ```
32
32
 
33
+ ### Create new Addon to Rails App Generator
34
+
35
+ If you need to make a new addon available then use `thor addon:new`
36
+
37
+ Generally an Addon will be for a gem so if you use the `--gem` option, it will bring in the GEM info such as latest version number
38
+
39
+ ```
40
+ thor addon:new image_processing --gem
41
+ thor addon:new kaminari --gem
42
+ ```
43
+
44
+ ### Create new Profile to Rails App Generator
45
+
46
+ A profile is a sample Rails application template with files that allows you to test one or more Addons and produces a working Rails 7 application.
47
+
48
+ If you are just keeping the example to a simple GEM then use the `--variant` option with the folder you would like to write code into, e.g. `addons`
49
+
50
+ ```
51
+ thor profile:new factory_bot --variant=addons
52
+ thor profile:new kaminari --variant=addons
53
+ ```
33
54
 
34
55
  ## Notes
35
56
 
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ # factory_bot provides a framework and DSL for defining and using factories - less error-prone, more explicit, and all-around easier to work with than fixtures.
4
+ #
5
+ # exe/rag addons/factory_bot
6
+
7
+ self.local_template_path = File.dirname(__FILE__)
8
+
9
+ gac 'base rails 7 image created'
10
+
11
+ prepare_environment
12
+
13
+ after_bundle do
14
+ create_db
15
+ scaffolds
16
+ setup_customizations
17
+ migrate_db
18
+ end
19
+
20
+ # Goals:
21
+ # - Store Factories in subfolder under spec
22
+ # -
23
+ # - Use the faker GEM with both standard and custom data
24
+ # - Custom data goes in custom locales folder, see: https://stackoverflow.com/questions/28153540/extending-faker-in-a-gem-where-do-i-put-the-yaml-file
25
+ # - Use associations to affectively create related records
26
+ # - Create default and NULL factory example
27
+ # - Create Seed Data services
28
+ # - Add support for STI
29
+ # - Add support for polymorphic associations
30
+ # Things to be aware of in faker
31
+ # - Random focused data is better then sequence
32
+ # sequence(:name) { |n| "Category #{n}" }
33
+ # vs
34
+ # name { Faker::Hipster.word }
35
+ # -
36
+
37
+
38
+ def scaffolds
39
+ add_scaffold('app', 'title', 'description', 'settings:json')
40
+ add_scaffold('tenant', 'name', 'slug', 'active:boolean', 'app:references')
41
+ add_scaffold('role', 'code') # contributor, moderator, admin
42
+ add_scaffold('employee', 'first_name', 'last_name', 'address:text', 'email', 'password', 'tenant:references', 'role:references')
43
+ add_scaffold('project', 'name', 'status', 'budget:decimal', 'country', 'progress:integer', 'tenant:references')
44
+ add_scaffold('article', 'title', 'body:text', 'is_featured:boolean', 'employee:references', 'tenant:references')
45
+ add_scaffold('video', 'title', 'youtube_id', '', 'article:references')
46
+ end
47
+
48
+ def setup_customizations
49
+ route("root 'home#index'")
50
+
51
+ force_copy
52
+
53
+ add_controller('home', 'index', 'reseed')
54
+
55
+ directory "app/controllers"
56
+ directory "app/models"
57
+ directory "app/views"
58
+ template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
59
+ directory "app/services"
60
+ copy_file 'factories.rb'
61
+ end
62
+
63
+ def create_db
64
+ # uncomment this if you need custom configuration in database.yml
65
+ # gsub_file('config/database.yml', ' encoding: unicode', db_development_settings)
66
+ db(create: true)
67
+ end
68
+
69
+ def migrate_db
70
+ template 'db/seeds.rb' , 'db/seeds.rb'
71
+
72
+ db(migrate: true, seed: true)
73
+ end
74
+
75
+ def db_development_settings
76
+ <<-'RUBY'
77
+ encoding: unicode
78
+ host: 127.0.0.1
79
+ username: printspeak
80
+ password: printspeak
81
+ RUBY
82
+ end
@@ -0,0 +1,10 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def reseed
6
+ SeedService.seed(variant: :reset)
7
+
8
+ redirect_back_or_to root_path
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ class SeedService
2
+ class << self
3
+ def seed(variant: :reset)
4
+ service = SeedService.new
5
+ service.call(variant: variant)
6
+ end
7
+ end
8
+
9
+ def call(variant: :reset)
10
+ reset if variant == :reset
11
+ refresh if variant == :refresh
12
+ create
13
+ end
14
+
15
+ private
16
+
17
+ def reset
18
+ Article.delete_all
19
+ Project.delete_all
20
+ Employee.delete_all
21
+ Tenant.delete_all
22
+ App.delete_all
23
+ end
24
+
25
+ def refresh
26
+ end
27
+
28
+ def create
29
+ app = FactoryBot.create(:app)
30
+ tenants = FactoryBot.create_list(:tenant, rand(10..20), app: app)
31
+ employees = FactoryBot.create_list(:employee, rand(10..20), tenant: tenants.sample)
32
+ _articles = FactoryBot.create_list(:article, rand(10..20), tenant: tenants.sample, employee: employees.sample)
33
+ _projects = FactoryBot.create_list(:project, rand(10..20), tenant: tenants.sample)
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ <h1>Factory bot</h1>
2
+
3
+ <p>factory_bot provides a framework and DSL for defining and using factories - less error-prone, more explicit, and all-around easier to work with than fixtures.</p>
@@ -0,0 +1,10 @@
1
+ <%= link_to 'Home', root_path %>
2
+ | <%= link_to 'Apps', apps_path %>
3
+ | <%= link_to 'Tenants', tenants_path %>
4
+ | <%= link_to 'Employees', employees_path %>
5
+ | <%= link_to 'Roles', roles_path %>
6
+ | <%= link_to 'Projects', projects_path %>
7
+ | <%= link_to 'Articles', articles_path %>
8
+ | <%= link_to 'Videos', videos_path %>
9
+ | <%= link_to 'Re-Seed', home_reseed_path, style: 'color: blue; font-weight: 600;' %>
10
+ <hr />
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= camelized %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%%= csrf_meta_tags %>
7
+ <%%= csp_meta_tag %>
8
+
9
+ <%- if options[:skip_hotwire] || options[:skip_javascript] -%>
10
+ <%%= stylesheet_link_tag "application" %>
11
+ <%- else -%>
12
+ <%%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
13
+ <%- end -%>
14
+ </head>
15
+
16
+ <body>
17
+ <header>
18
+ <%%= render 'layouts/navbar' %>
19
+ <hr />
20
+ </header>
21
+ <main>
22
+ <%%= yield %>
23
+ </main>
24
+ <footer>
25
+ <%%= render 'layouts/footer' %>
26
+ </footer>
27
+ </body>
28
+ </html>
29
+
@@ -0,0 +1 @@
1
+ SeedService.seed
@@ -0,0 +1,73 @@
1
+ FactoryBot.define do
2
+ factory :app do
3
+ title { Faker::Name.name } # Faker::App.name
4
+ description { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
5
+ settings { { 'foo' => 'bar' } }
6
+ end
7
+
8
+ factory :tenant do
9
+ name { Faker::Name.name }
10
+ slug { Faker::Internet.slug }
11
+ active { [true, false].sample }
12
+ app
13
+ end
14
+
15
+ factory :employee do
16
+ first_name { Faker::Name.first_name }
17
+ last_name { Faker::Name.last_name }
18
+ email { Faker::Internet.email }
19
+ password { Faker::Internet.password }
20
+ address { Faker::Address.full_address }
21
+ end
22
+
23
+ factory :article do
24
+ title { Faker::Quote.famous_last_words }
25
+ body { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
26
+ is_featured { [true, false].sample }
27
+ end
28
+
29
+ factory :project do
30
+ name { Faker::App.name }
31
+ status { [:closed, :rejected, :failed, :loading, :running, :waiting, :done, :finalized, :archived, :finished].sample }
32
+ budget { Faker::Number.decimal(l_digits: 4) }
33
+ country { Faker::Address.country_code }
34
+ progress { Faker::Number.between(from: 0, to: 100) }
35
+ end
36
+ end
37
+
38
+ def examples
39
+ Faker::Name.name
40
+ Faker::Name.unique.name
41
+
42
+ Faker::Internet.email
43
+
44
+ Faker::Artist.name
45
+ Faker::Address.city #=> "Imogeneborough"
46
+ Faker::Address.street_name #=> "Larkin Fork"
47
+ Faker::Address.street_address #=> "282 Kevin Brook"
48
+ Faker::Address.secondary_address #=> "Apt. 672"
49
+ Faker::Address.building_number #=> "7304"
50
+ Faker::Address.mail_box #=> "PO Box 123"
51
+ Faker::Address.community #=> "University Crossing"
52
+ Faker::Address.zip_code #=> "58517" or "23285-4905"
53
+ Faker::Address.zip #=> "58517" or "66259-8212"
54
+ Faker::Address.postcode #=> "76032-4907" or "58517"
55
+ Faker::Address.time_zone #=> "Asia/Yakutsk"
56
+ Faker::Address.street_suffix #=> "Street"
57
+ Faker::Address.city_suffix #=> "fort"
58
+ Faker::Address.city_prefix #=> "Lake"
59
+ Faker::Address.state #=> "California"
60
+ Faker::Address.state_abbr #=> "AP"
61
+ Faker::Address.country #=> "French Guiana"
62
+
63
+ # Keyword arguments: code
64
+ Faker::Address.country_by_code(code: 'NL') #=> "Netherlands"
65
+
66
+ # Keyword arguments: name
67
+ Faker::Address.country_name_to_code(name: 'united_states') #=> "US"
68
+ Faker::Address.country_code #=> "IT"
69
+ Faker::Address.country_code_long #=> "ITA"
70
+ Faker::Address.latitude #=> "-58.17256227443719"
71
+ Faker::Address.longitude #=> "-156.65548382095133"
72
+ Faker::Address.full_address #=> "282 Kevin Brook, Imogeneborough, CA 58517"
73
+ end
@@ -0,0 +1,40 @@
1
+ require:
2
+ - rubocop-rails
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+ Exclude:
7
+ - bin/*
8
+ - db/schema.rb
9
+ - db/migrate/*
10
+ - node_modules/**/*
11
+
12
+ Naming/AccessorMethodName:
13
+ Enabled: false
14
+
15
+ Metrics/MethodLength:
16
+ CountAsOne: ['array', 'heredoc']
17
+ AllowedMethods: ['describe', 'context']
18
+
19
+ Metrics/BlockLength:
20
+ AllowedMethods: ['describe', 'context']
21
+ Exclude:
22
+ - config/environments/*.rb
23
+ - '**/*.rake'
24
+
25
+ Layout/LineLength:
26
+ Max: 120
27
+
28
+ Layout/MultilineMethodCallIndentation:
29
+ EnforcedStyle: indented
30
+
31
+ Lint/EmptyBlock:
32
+ Exclude:
33
+ - spec/factories/*
34
+
35
+ Style/BlockDelimiters:
36
+ Exclude:
37
+ - spec/**/*
38
+
39
+ Style/Documentation:
40
+ Enabled: false
@@ -14,9 +14,9 @@ after_bundle do
14
14
  force_copy
15
15
  create_db
16
16
  scaffolds
17
+ setup_avo
17
18
  setup_customizations
18
19
  migrate_db
19
- setup_avo
20
20
 
21
21
  swap1 = ' resources :users'
22
22
  swap2 = " devise_for :users, controllers: { sessions: 'users/sessions', registrations: 'users/registrations' }"
@@ -27,6 +27,8 @@ end
27
27
  def scaffolds
28
28
  add_scaffold_controller('users', 'name', 'email')
29
29
 
30
+ add_scaffold('booking', 'name', 'state')
31
+
30
32
  add_scaffold('rails_app', 'name', 'user:references') # name of the rails_app
31
33
 
32
34
  # no of records in each table per region
@@ -45,9 +47,8 @@ def scaffolds
45
47
  # add_scaffold('db_schema_index', 'name', 'fields', 'using', 'order:jsonb', 'where', 'unique', 'db_schema_table:references')
46
48
  # add_scaffold('db_schema_view', 'name', 'materialized:boolean', 'sql_definition', 'db_schema_table:references')
47
49
 
48
- generate('scenic:model rubocop_log --materialized')
49
-
50
- directory "db/views"
50
+ generate('scenic:model rubocop_entry --materialized')
51
+ generate('scenic:model table_count_entry')
51
52
  end
52
53
 
53
54
  def setup_customizations
@@ -63,29 +64,42 @@ def setup_customizations
63
64
  template 'app/views/layouts/application.html.erb', 'app/views/layouts/application.html.erb'
64
65
  directory "app/queries"
65
66
  directory "app/services"
67
+ directory "db/views" # takes views from both scaffolds and customizations
68
+
69
+ copy_file '.rubocop.yml', '.rubocop.yml'
66
70
  end
67
71
 
68
72
  def setup_avo
69
- # generate('avo:install')
73
+ generate('avo:resource rails_app')
74
+
75
+ generate('avo:resource table_count')
76
+ generate('avo:resource table_count_entry')
77
+ generate('avo:filter table_count_tablename_filter')
78
+
79
+ generate('avo:resource rubocop')
80
+ generate('avo:resource_tool rubocop_info')
81
+
82
+ generate('avo:resource rubocop_entry')
83
+ generate('avo:filter rubocop_entry_cop_filter')
84
+ generate('avo:filter rubocop_entry_filename_filter')
85
+ generate('avo:filter rubocop_entry_message_filter')
86
+ generate('avo:filter rubocop_entry_status_filter')
87
+
88
+ generate('avo:resource db_schema')
89
+ generate('avo:resource user')
70
90
 
71
- generate('avo:resource RailsApp')
72
- generate('avo:resource TableCount')
73
- generate('avo:resource Rubocop')
74
- generate('avo:resource DbSchema')
75
- generate('avo:resource User')
76
91
  # generate('avo:dashboard Dashboard')
77
92
 
78
93
  directory "app/avo"
79
94
  directory "config/initializers"
80
95
  directory "config/locales"
81
-
82
- # # add devise support
83
- # gsub_file 'config/initializers/avo.rb', %(# config.current_user_method = {}), 'config.current_user_method = :current_user'
84
96
  end
85
97
 
86
98
  def create_db
87
99
  gsub_file('config/database.yml', ' encoding: unicode', db_development_settings)
88
- db(drop: true, create: true)
100
+
101
+ db_recreate(environment: :development)
102
+ db_recreate(environment: :test)
89
103
  end
90
104
 
91
105
  def migrate_db
@@ -0,0 +1,15 @@
1
+ class RubocopEntryCopFilter < Avo::Filters::MultipleSelectFilter
2
+ self.name = "Cop"
3
+
4
+ def apply(_request, query, values)
5
+ query.where(cop: values)
6
+ end
7
+
8
+ def options
9
+ RubocopEntry
10
+ .select(:cop)
11
+ .distinct
12
+ .order(:cop)
13
+ .map { |entry| [entry.cop, entry.cop] }.to_h
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ class RubocopEntryFilenameFilter < Avo::Filters::TextFilter
2
+ self.name = "FileName"
3
+
4
+ def apply(_request, query, value)
5
+ values = value.split(" ")
6
+
7
+ values.each do |word|
8
+ query = query.where("file_name ILIKE ?", "%#{word}%")
9
+ end
10
+
11
+ query
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class RubocopEntryMessageFilter < Avo::Filters::TextFilter
2
+ self.name = "Message"
3
+
4
+ def apply(_request, query, value)
5
+ values = value.split(" ")
6
+
7
+ values.each do |word|
8
+ query = query.where("message ILIKE ?", "%#{word}%")
9
+ end
10
+
11
+ query
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ class RubocopEntryStatusFilter < Avo::Filters::SelectFilter
2
+ self.name = "Status"
3
+
4
+ def apply(_request, query, value)
5
+ query.where(status: value)
6
+ end
7
+
8
+ def options
9
+ RubocopEntry
10
+ .select(:status)
11
+ .distinct
12
+ .order(:status)
13
+ .map { |entry| [entry.status, entry.status] }.to_h
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ class TableCountEntryTablenameFilter < Avo::Filters::TextFilter
2
+ self.name = "Table Name"
3
+
4
+ def apply(_request, query, value)
5
+ values = value.split(" ")
6
+
7
+ values.each do |word|
8
+ query = query.where("table_name ILIKE ?", "%#{word}%")
9
+ end
10
+
11
+ query
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ class RubocopInfo < Avo::BaseResourceTool
2
+ self.name = "Rubocop info"
3
+ self.partial = "avo/resource_tools/rubocop_info"
4
+ end
@@ -0,0 +1,28 @@
1
+ class RubocopEntryResource < Avo::BaseResource
2
+ filter RubocopEntryFilenameFilter
3
+ filter RubocopEntryMessageFilter
4
+ filter RubocopEntryStatusFilter
5
+ filter RubocopEntryCopFilter
6
+
7
+ self.title = :file_name
8
+ self.includes = []
9
+
10
+ self.search_query = ->(params:) do
11
+ scope.ransack(
12
+ cop_cont: params[:q],
13
+ file_name_cont: params[:q],
14
+ position_cont: params[:q],
15
+ status_cont: params[:q],
16
+ status_message_cont: params[:q],
17
+ m: "or"
18
+ ).result(distinct: false)
19
+ end
20
+
21
+ field :cop , as: :text
22
+ field :file_name , as: :text
23
+ # field :full_line , as: :text
24
+ field :position , as: :text
25
+ # field :status , as: :text
26
+ field :status_message , as: :text
27
+ field :message , as: :text
28
+ end
@@ -9,12 +9,13 @@ class RubocopResource < Avo::BaseResource
9
9
  field :id, as: :id
10
10
  # field :data, as: :textarea, only_on: [:edit]
11
11
  # field :user_name, as: :text
12
+ tool RubocopInfo, show_on: :edit
12
13
 
13
- tabs do
14
- tab "List of Cops" do
15
- panel do
16
- field :id, as: :id
17
- end
18
- end
19
- end
14
+ # tabs do
15
+ # tab "List of Cops" do
16
+ # panel do
17
+ # field :id, as: :id
18
+ # end
19
+ # end
20
+ # end
20
21
  end
@@ -0,0 +1,18 @@
1
+ class TableCountEntryResource < Avo::BaseResource
2
+ filter TableCountEntryTablenameFilter
3
+
4
+ self.title = :table_count
5
+ self.includes = []
6
+
7
+ self.search_query = ->(params:) do
8
+ scope.ransack(
9
+ table_count_cont: params[:q],
10
+ m: "or"
11
+ ).result(distinct: false)
12
+ end
13
+
14
+ field :table_count, as: :text
15
+ field :au, as: :text
16
+ field :eu, as: :text
17
+ field :us, as: :text
18
+ end
@@ -13,7 +13,7 @@ class HomeController < ApplicationController
13
13
  end
14
14
 
15
15
  def refresh_material_view
16
- RubocopLog.refresh
16
+ RubocopEntry.refresh
17
17
 
18
18
  redirect_back_or_to root_path
19
19
  end
@@ -36,7 +36,7 @@ class SeedService
36
36
  def create
37
37
  refresh_printspeak
38
38
 
39
- RubocopLog.refresh
39
+ RubocopEntry.refresh
40
40
  end
41
41
 
42
42
  def refresh_printspeak
@@ -1,6 +1,6 @@
1
1
  <h1><%= I18n.t('application_name') %></h1>
2
2
 
3
- <p>The Klue is to do Less</p>
3
+ <%# <p>The Klue is to do Less</p>
4
4
 
5
5
  <p>No Code as a Service - Rails Application Builder</p>
6
-
6
+ %>
@@ -1,10 +1,7 @@
1
1
  <%= link_to 'Home', root_path %>
2
+ | <%= link_to 'Bookings', bookings_path %>
2
3
  | <%= link_to 'Re-Seed', home_reseed_path, style: 'color: blue; font-weight: 600;' %>
3
4
  | <%= link_to 'Refresh Material View', home_refresh_material_view_path, style: 'color: blue; font-weight: 600;' %>
4
5
  | <%= link_to 'Quick Sign In', home_quick_signin_path %>
5
6
  | <%= link_to 'Admin', avo_path %>
6
- <hr />
7
-
8
- <%= link_to 'Visits (View)', home_visitors_by_monument_path %>
9
- | <%= link_to 'Visits (Materialized)', home_individual_visitors_by_monument_path %>
10
7
  <hr />
@@ -78,8 +78,10 @@ Avo.configure do |config|
78
78
  resource :table_count, label: 'Table Count'
79
79
  end
80
80
 
81
- # group "Xxx" do # , collapsable: true, collapsed: true
82
- # end
81
+ group "Live Views", collapsable: true, collapsed: true do
82
+ resource :rubocop_entries, label: 'Rubo Cop'
83
+ resource :table_count_entries, label: 'Table Count'
84
+ end
83
85
 
84
86
  group "Admin" do
85
87
  resource :user
@@ -9,7 +9,7 @@ lines AS (
9
9
  jsonb_array_elements(files)->'lines' as lines
10
10
  FROM files
11
11
  ),
12
- rubocop_log AS (
12
+ denormalized AS (
13
13
  SELECT
14
14
  jsonb_array_elements(lines)->>'position' as position,
15
15
  jsonb_array_elements(lines)->>'status' as status,
@@ -20,4 +20,4 @@ rubocop_log AS (
20
20
  jsonb_array_elements(lines)->>'file_name' as file_name
21
21
  FROM lines
22
22
  )
23
- select * from rubocop_log
23
+ select row_number() OVER () AS id, * from denormalized
@@ -0,0 +1,11 @@
1
+ WITH
2
+
3
+ denormalized AS (
4
+ SELECT
5
+ jsonb_array_elements(data)->>'table_name' as table_name,
6
+ jsonb_array_elements(data)->>'au' as au,
7
+ jsonb_array_elements(data)->>'eu' as eu,
8
+ jsonb_array_elements(data)->>'us' as us
9
+ FROM table_counts
10
+ )
11
+ select * from denormalized order by table_name
@@ -3,7 +3,7 @@
3
3
  "skip_namespace": false,
4
4
  "skip_collision_check": false,
5
5
  "ruby": "/Users/davidcruwys/.asdf/installs/ruby/3.1.1/bin/ruby",
6
- "database": "postgresql",
6
+ "database": "sqlite3",
7
7
  "skip_git": false,
8
8
  "skip_keeps": false,
9
9
  "skip_action_mailer": false,
@@ -33,15 +33,15 @@
33
33
  "add_acts_as_list": false,
34
34
  "add_administrate": false,
35
35
  "add_annotate": true,
36
- "add_avo": true,
36
+ "add_avo": false,
37
37
  "add_bcrypt": false,
38
- "add_brakeman": true,
38
+ "add_brakeman": false,
39
39
  "add_browser": false,
40
- "add_bundler_audit": true,
40
+ "add_bundler_audit": false,
41
41
  "add_chartkick": false,
42
- "add_devise": true,
42
+ "add_devise": false,
43
43
  "add_devise_masquerade": false,
44
- "add_dotenv": true,
44
+ "add_dotenv": false,
45
45
  "add_factory_bot_rails": true,
46
46
  "add_faker": true,
47
47
  "add_friendly_id": false,
@@ -52,7 +52,7 @@
52
52
  "add_image_processing": false,
53
53
  "add_kaminari": false,
54
54
  "add_lograge": false,
55
- "add_minimal_css": false,
55
+ "add_minimal_css": true,
56
56
  "minimal_css_library": "water.css",
57
57
  "add_mini_magick": false,
58
58
  "add_motor_admin": false,
@@ -60,13 +60,12 @@
60
60
  "add_pretender": false,
61
61
  "add_public_suffix": false,
62
62
  "add_rails_html_sanitizer": false,
63
- "add_scenic": true,
63
+ "add_scenic": false,
64
64
  "add_ransack": false,
65
65
  "add_redcarpet": false,
66
66
  "add_rolify": false,
67
- "add_rubocop": true,
67
+ "add_rubocop": false,
68
68
  "add_twilio_ruby": false,
69
- "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/application/klueless/_.rb",
70
- "css": "tailwind"
69
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot/_.rb"
71
70
  }
72
71
  }
@@ -7,8 +7,8 @@
7
7
  "quiet": false,
8
8
  "skip": false,
9
9
  "ruby": "/Users/davidcruwys/.asdf/installs/ruby/3.1.1/bin/ruby",
10
- "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/application/klueless/_.rb",
11
- "database": "postgresql",
10
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot/_.rb",
11
+ "database": "sqlite3",
12
12
  "skip_git": false,
13
13
  "skip_keeps": false,
14
14
  "skip_action_mailer": false,
@@ -36,22 +36,22 @@
36
36
  "api": false,
37
37
  "minimal": false,
38
38
  "javascript": "importmap",
39
- "css": "tailwind",
39
+ "css": "",
40
40
  "skip_bundle": false,
41
41
  "note": "",
42
42
  "test": "rspec",
43
43
  "add_acts_as_list": false,
44
44
  "add_administrate": false,
45
45
  "add_annotate": true,
46
- "add_avo": true,
46
+ "add_avo": false,
47
47
  "add_bcrypt": false,
48
- "add_brakeman": true,
48
+ "add_brakeman": false,
49
49
  "add_browser": false,
50
- "add_bundler_audit": true,
50
+ "add_bundler_audit": false,
51
51
  "add_chartkick": false,
52
- "add_devise": true,
52
+ "add_devise": false,
53
53
  "add_devise_masquerade": false,
54
- "add_dotenv": true,
54
+ "add_dotenv": false,
55
55
  "add_factory_bot_rails": true,
56
56
  "add_faker": true,
57
57
  "add_friendly_id": false,
@@ -62,7 +62,7 @@
62
62
  "add_image_processing": false,
63
63
  "add_kaminari": false,
64
64
  "add_lograge": false,
65
- "add_minimal_css": false,
65
+ "add_minimal_css": true,
66
66
  "minimal_css_library": "water.css",
67
67
  "add_mini_magick": false,
68
68
  "add_motor_admin": false,
@@ -70,11 +70,13 @@
70
70
  "add_pretender": false,
71
71
  "add_public_suffix": false,
72
72
  "add_rails_html_sanitizer": false,
73
- "add_scenic": true,
73
+ "add_scenic": false,
74
74
  "add_ransack": false,
75
75
  "add_redcarpet": false,
76
76
  "add_rolify": false,
77
- "add_rubocop": true,
78
- "add_twilio_ruby": false
77
+ "add_rubocop": false,
78
+ "add_twilio_ruby": false,
79
+ "add_factory_bot": true,
80
+ "add_rspec": true
79
81
  }
80
82
  }
@@ -71,7 +71,7 @@ module RailsAppGenerator
71
71
  puts "gem not available for '#{gem_name}'"
72
72
 
73
73
  # THIS CODE DOES NOT REALLY WORK
74
- return Dir.pwd if Dir.pwd.end_with?('dev/kgems/rails_app_generator') # code smell: this is for my local development environment
74
+ return Dir.pwd if Dir.pwd.end_with?('dev/kgems/rails_app_generator') # code smell: this is for my local test environment
75
75
 
76
76
  raise "'#{gem_name}' not available"
77
77
  end
@@ -103,7 +103,7 @@ module RailsAppGenerator
103
103
  # def rails_customization
104
104
  # puts 'rails customizations'
105
105
  # # invoke :customize_gemfile
106
- # # invoke :setup_development_environment
106
+ # # invoke :setup_test_environment
107
107
  # # invoke :setup_production_environment
108
108
  # # invoke :setup_secret_token
109
109
  # # invoke :configure_app
@@ -292,8 +292,17 @@ module RailsAppGenerator
292
292
  rails_command('db:migrate')
293
293
  end
294
294
 
295
- def db(drop: false, create: false, migrate: false, seed: false)
295
+ def db_recreate(environment: nil)
296
+ db_environment(environment) if environment
297
+ # when a DB does not exist, the drop will fail, but we still need to run create separately
298
+ db(drop: true)
299
+ db(create: true)
300
+ end
301
+
302
+ def db(environment: nil, drop: false, create: false, migrate: false, seed: false)
296
303
  commands = []
304
+
305
+ commands << "db:environment:set RAILS_ENV=#{environment}" if environment
297
306
  commands << 'db:drop' if drop
298
307
  commands << 'db:create' if create
299
308
  commands << 'db:migrate' if migrate
@@ -301,6 +310,10 @@ module RailsAppGenerator
301
310
  rails_command(commands.join(' '))
302
311
  end
303
312
 
313
+ def db_environment(environment)
314
+ rails_command("db:environment:set RAILS_ENV=#{environment}")
315
+ end
316
+
304
317
  def db_seed
305
318
  rails_command('db:seed')
306
319
  end
@@ -350,11 +363,12 @@ module RailsAppGenerator
350
363
 
351
364
  # copy_file in railties and copy_file in thor have different signatures
352
365
  # I may want to remove this method because it just causes pain at the moment
353
- def copy_file(source, destination, args = {})
366
+ def copy_file(source, destination = nil, args = {})
354
367
  # puts source
355
368
  # puts destination
356
369
  # puts args
357
370
  args = { force: true }.merge(args) if force_copy?
371
+ destination ||= source
358
372
 
359
373
  super(source, destination, args)
360
374
  end
@@ -63,12 +63,14 @@ module RailsAppGenerator
63
63
  end
64
64
  end
65
65
 
66
+ # rubocop:disable Metrics/AbcSize
66
67
  def handle_target_folder_found?
67
68
  return true unless File.directory?(target_path)
68
69
 
69
70
  case when_folder_exist
70
71
  when 'abort'
71
72
  puts "Target folder [#{target_path}] already exists. Aborting"
73
+ puts 'Maybe you want to use when_folder_exist option with one of these values [destroy overwrite keep_git]'
72
74
  false
73
75
  when 'destroy'
74
76
  puts "Target folder [#{target_path}] already exists. Destroying it"
@@ -85,6 +87,7 @@ module RailsAppGenerator
85
87
  raise "Invalid when_folder_exist: #{when_folder_exist}"
86
88
  end
87
89
  end
90
+ # rubocop:enable Metrics/AbcSize
88
91
 
89
92
  private
90
93
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAppGenerator
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
data/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "rails_app_generator",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "rails_app_generator",
9
- "version": "0.3.1",
9
+ "version": "0.3.2",
10
10
  "dependencies": {
11
11
  "daisyui": "^2.20.0"
12
12
  },
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rails_app_generator",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Create new Rails Application with custom opinions",
5
5
  "scripts": {
6
6
  "release": "semantic-release"
@@ -0,0 +1,18 @@
1
+ {
2
+ "args": {
3
+ "app_path": "r7_factory_bot",
4
+ "destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons",
5
+ "when_folder_exist": "keep_git"
6
+ },
7
+ "opts": {
8
+ "skip_git": false,
9
+ "skip_test": true,
10
+ "add_minimal_css": true,
11
+ "template": "/Users/davidcruwys/dev/kgems/rails_app_generator/after_templates/addons/factory_bot/_.rb",
12
+ "add_annotate": true,
13
+ "add_factory_bot": true,
14
+ "add_factory_bot_rails": true,
15
+ "add_faker": true,
16
+ "add_rspec": true
17
+ }
18
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "args": {
3
- "app_path": "faker",
3
+ "app_path": "r7_faker",
4
4
  "destination_root": "/Users/davidcruwys/dev/kgems/rails_app_generator/a/addons"
5
5
  },
6
6
  "opts": {
@@ -18,7 +18,9 @@
18
18
  "add_dotenv": true,
19
19
  "add_factory_bot_rails": true,
20
20
  "add_faker": true,
21
- "add_ransack": false,
21
+ "add_kaminari": true,
22
+ "add_lograge": true,
23
+ "add_ransack": true,
22
24
  "add_rubocop": true,
23
25
  "add_scenic": true
24
26
  }
@@ -18,9 +18,9 @@ Open your browser on [localhost:3000](http://localhost:3000).
18
18
 
19
19
  ## Development
20
20
 
21
- This app was generated using [Schienenzeppelin](https://github.com/hschne/schienenzeppelin) - there are tons of little tweaks to simplify your development workflow.
21
+ This app was generated using [Klueless - RailsAppGenerator](https://github.com/klueless-io/rails_app_generator) - there are tons of little tweaks to simplify your development workflow.
22
22
 
23
- For more details refer to the [Documentation](https://github.com/hschne/schienenzeppelin)
23
+ For more details refer to the [Documentation](https://github.com/klueless-io/rails_app_generator)
24
24
 
25
25
  ## Deployment
26
26
 
@@ -1,13 +1,14 @@
1
1
  class SeedService
2
2
  class << self
3
- def seed
3
+ def seed(variant: :reset)
4
4
  service = SeedService.new
5
- service.call
5
+ service.call(variant: variant)
6
6
  end
7
7
  end
8
8
 
9
- def call
10
- reset
9
+ def call(variant: :reset)
10
+ reset if variant == :reset
11
+ refresh if variant == :refresh
11
12
  create
12
13
  end
13
14
 
@@ -19,6 +20,9 @@ class SeedService
19
20
  # Project.delete_all
20
21
  end
21
22
 
23
+ def refresh
24
+ end
25
+
22
26
  def create
23
27
  # FactoryBot.create_list(:post, rand(10..20))
24
28
  # FactoryBot.create_list(:person, rand(10..20))
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "args": {
3
3
  "app_path": "r7_<%= data.name_snake %>",
4
- "destination_root": "<%= data.destination_root %>"
4
+ "destination_root": "<%= data.destination_root %>",
5
+ "when_folder_exist": "destroy"
5
6
  },
6
7
  "opts": {
7
8
  "skip_git": true,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_app_generator
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
  - David Cruwys
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-02 00:00:00.000000000 Z
11
+ date: 2022-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootsnap
@@ -294,6 +294,20 @@ files:
294
294
  - after_templates/addons/dotenv/app/controllers/home_controller.rb
295
295
  - after_templates/addons/dotenv/app/views/home/index.html.erb
296
296
  - after_templates/addons/dotenv/app/views/layouts/application.html.erb
297
+ - after_templates/addons/factory_bot/_.rb
298
+ - after_templates/addons/factory_bot/app/controllers/home_controller.rb
299
+ - after_templates/addons/factory_bot/app/services/seed_service.rb
300
+ - after_templates/addons/factory_bot/app/views/home/index.html.erb
301
+ - after_templates/addons/factory_bot/app/views/layouts/_footer.html.erb
302
+ - after_templates/addons/factory_bot/app/views/layouts/_navbar.html.erb
303
+ - after_templates/addons/factory_bot/app/views/layouts/application.html.erb
304
+ - after_templates/addons/factory_bot/db/seeds.rb
305
+ - after_templates/addons/factory_bot/factories.rb
306
+ - after_templates/addons/factory_bot/factory-create-user.png
307
+ - after_templates/addons/factory_bot/factory-employee-bad.png
308
+ - after_templates/addons/factory_bot/factory-employee-good.png
309
+ - after_templates/addons/factory_bot/factory-role.png
310
+ - after_templates/addons/factory_bot/factory-video.png
297
311
  - after_templates/addons/factory_bot_rails/_.rb
298
312
  - after_templates/addons/factory_bot_rails/app/controllers/home_controller.rb
299
313
  - after_templates/addons/factory_bot_rails/app/services/seed_service.rb
@@ -457,6 +471,7 @@ files:
457
471
  - after_templates/addons/twilio_ruby/app/controllers/home_controller.rb
458
472
  - after_templates/addons/twilio_ruby/app/views/home/index.html.erb
459
473
  - after_templates/addons/twilio_ruby/config/initializers/twilio.rb
474
+ - after_templates/application/klueless/.rubocop.yml
460
475
  - after_templates/application/klueless/_.rb
461
476
  - after_templates/application/klueless/app/avo/cards/amount_raised.rb
462
477
  - after_templates/application/klueless/app/avo/cards/example_custom_partial.rb
@@ -464,9 +479,17 @@ files:
464
479
  - after_templates/application/klueless/app/avo/cards/percent_done.rb
465
480
  - after_templates/application/klueless/app/avo/cards/rubocop_card.rb
466
481
  - after_templates/application/klueless/app/avo/dashboards/dashboard.rb
482
+ - after_templates/application/klueless/app/avo/filters/rubocop_entry_cop_filter.rb
483
+ - after_templates/application/klueless/app/avo/filters/rubocop_entry_filename_filter.rb
484
+ - after_templates/application/klueless/app/avo/filters/rubocop_entry_message_filter.rb
485
+ - after_templates/application/klueless/app/avo/filters/rubocop_entry_status_filter.rb
486
+ - after_templates/application/klueless/app/avo/filters/table_count_entry_tablename_filter.rb
487
+ - after_templates/application/klueless/app/avo/resource_tools/rubocop_info.rb
467
488
  - after_templates/application/klueless/app/avo/resources/db_schema_resource.rb
468
489
  - after_templates/application/klueless/app/avo/resources/rails_app_resource.rb
490
+ - after_templates/application/klueless/app/avo/resources/rubocop_entry_resource.rb
469
491
  - after_templates/application/klueless/app/avo/resources/rubocop_resource.rb
492
+ - after_templates/application/klueless/app/avo/resources/table_count_entry_resource.rb
470
493
  - after_templates/application/klueless/app/avo/resources/table_count_resource.rb
471
494
  - after_templates/application/klueless/app/avo/resources/user_resource.rb
472
495
  - after_templates/application/klueless/app/controllers/home_controller.rb
@@ -486,7 +509,8 @@ files:
486
509
  - after_templates/application/klueless/config/initializers/avo.rb
487
510
  - after_templates/application/klueless/config/locales/en.yml
488
511
  - after_templates/application/klueless/db/seeds.rb
489
- - after_templates/application/klueless/db/views/rubocop_logs_v01.sql
512
+ - after_templates/application/klueless/db/views/rubocop_entries_v01.sql
513
+ - after_templates/application/klueless/db/views/table_count_entries_v01.sql
490
514
  - after_templates/application/printspeak/_.rb
491
515
  - after_templates/application/printspeak/app/assets/images/.keep
492
516
  - after_templates/application/printspeak/app/assets/images/about/1.jpg
@@ -801,6 +825,7 @@ files:
801
825
  - profiles/addons/devise.json
802
826
  - profiles/addons/devise_masquerade.json
803
827
  - profiles/addons/dotenv.json
828
+ - profiles/addons/factory_bot.json
804
829
  - profiles/addons/factory_bot_rails.json
805
830
  - profiles/addons/faker.json
806
831
  - profiles/addons/friendly_id.json