rails_app_generator 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +22 -1
- data/after_templates/addons/factory_bot/_.rb +68 -0
- data/after_templates/addons/factory_bot/app/controllers/home_controller.rb +16 -0
- data/after_templates/addons/factory_bot/app/services/seed_service.rb +68 -0
- data/after_templates/addons/factory_bot/app/views/articles/index.html.erb +32 -0
- data/after_templates/addons/factory_bot/app/views/companies/index.html.erb +33 -0
- data/after_templates/addons/factory_bot/app/views/employee_roles/index.html.erb +30 -0
- data/after_templates/addons/factory_bot/app/views/employees/index.html.erb +36 -0
- data/after_templates/addons/factory_bot/app/views/home/index.html.erb +3 -0
- data/after_templates/addons/factory_bot/app/views/layouts/_footer.html.erb +0 -0
- data/after_templates/addons/factory_bot/app/views/layouts/_navbar.html.erb +17 -0
- data/after_templates/addons/factory_bot/app/views/layouts/application.html.erb +29 -0
- data/after_templates/addons/factory_bot/app/views/projects/index.html.erb +36 -0
- data/after_templates/addons/factory_bot/app/views/regions/index.html.erb +29 -0
- data/after_templates/addons/factory_bot/app/views/roles/index.html.erb +29 -0
- data/after_templates/addons/factory_bot/app/views/videos/index.html.erb +31 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a1.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a2.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a3.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a4.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a5.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a6.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a7.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a8.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/a9.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b1.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b2.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b3.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b4.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b5.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b6.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b7.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b8.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/b9.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c1.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c2.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c3.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c4.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c5.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c6.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c7.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c8.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/c9.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/d1.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/d2.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/d3.png +0 -0
- data/after_templates/addons/factory_bot/best-practices/toshima/d4.png +0 -0
- data/after_templates/addons/factory_bot/best_practice.rb +630 -0
- data/after_templates/addons/factory_bot/config/application.rb +39 -0
- data/after_templates/addons/factory_bot/custom_factories/_examples.rb +61 -0
- data/after_templates/addons/factory_bot/custom_factories/article.rb +13 -0
- data/after_templates/addons/factory_bot/custom_factories/company.rb +9 -0
- data/after_templates/addons/factory_bot/custom_factories/employee.rb +37 -0
- data/after_templates/addons/factory_bot/custom_factories/project.rb +10 -0
- data/after_templates/addons/factory_bot/custom_factories/region.rb +32 -0
- data/after_templates/addons/factory_bot/custom_factories/role.rb +21 -0
- data/after_templates/addons/factory_bot/custom_factories/user.rb +10 -0
- data/after_templates/addons/factory_bot/custom_factories/video.rb +7 -0
- data/after_templates/addons/factory_bot/db/seeds.rb +1 -0
- data/after_templates/addons/rspec/_.rb +61 -0
- data/after_templates/addons/rspec/app/controllers/home_controller.rb +8 -0
- data/after_templates/addons/rspec/app/services/seed_service.rb +31 -0
- data/after_templates/addons/rspec/app/views/home/index.html.erb +3 -0
- data/after_templates/addons/rspec/app/views/layouts/_footer.html.erb +0 -0
- data/after_templates/addons/rspec/app/views/layouts/_navbar.html.erb +5 -0
- data/after_templates/addons/rspec/app/views/layouts/application.html.erb +29 -0
- data/after_templates/addons/rspec/db/seeds.rb +8 -0
- data/after_templates/application/klueless/.rubocop.yml +40 -0
- data/after_templates/application/klueless/_.rb +28 -14
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_cop_filter.rb +15 -0
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_filename_filter.rb +13 -0
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_message_filter.rb +13 -0
- data/after_templates/application/klueless/app/avo/filters/rubocop_entry_status_filter.rb +15 -0
- data/after_templates/application/klueless/app/avo/filters/table_count_entry_tablename_filter.rb +13 -0
- data/after_templates/application/klueless/app/avo/resource_tools/rubocop_info.rb +4 -0
- data/after_templates/application/klueless/app/avo/resources/rubocop_entry_resource.rb +28 -0
- data/after_templates/application/klueless/app/avo/resources/rubocop_resource.rb +8 -7
- data/after_templates/application/klueless/app/avo/resources/table_count_entry_resource.rb +18 -0
- data/after_templates/application/klueless/app/controllers/home_controller.rb +1 -1
- data/after_templates/application/klueless/app/services/seed_service.rb +1 -1
- data/after_templates/application/klueless/app/views/home/index.html.erb +2 -2
- data/after_templates/application/klueless/app/views/layouts/_navbar.html.erb +1 -4
- data/after_templates/application/klueless/config/initializers/avo.rb +4 -2
- data/after_templates/application/klueless/db/views/{rubocop_logs_v01.sql → rubocop_entries_v01.sql} +2 -2
- data/after_templates/application/klueless/db/views/table_count_entries_v01.sql +11 -0
- data/docs/last_run/app_generator_class.json +16 -8
- data/docs/last_run/app_generator_data.json +11 -11
- data/docs/last_run/rails_options_class.json +13 -5
- data/docs/last_run/rails_options_data.json +14 -12
- data/lib/rails_app_generator/addons/rspec.rb +7 -1
- data/lib/rails_app_generator/app_generator.rb +24 -13
- data/lib/rails_app_generator/rag_initializer.rb +4 -1
- data/lib/rails_app_generator/starter.rb +3 -0
- data/lib/rails_app_generator/version.rb +1 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/profiles/addons/factory_bot.json +16 -0
- data/profiles/addons/faker.json +1 -1
- data/profiles/addons/rspec.json +14 -0
- data/profiles/application/klueless.json +3 -1
- data/templates/README.md.erb +2 -2
- data/templates/thor_task/profile/app/services/seed_service.rb +8 -4
- data/templates/thor_task/profile/profile.json.tt +2 -1
- metadata +81 -3
@@ -0,0 +1,61 @@
|
|
1
|
+
def examples
|
2
|
+
# description { Faker::Lorem.paragraphs(number: rand(1...3)).join("\n") }
|
3
|
+
Faker::Name.name
|
4
|
+
Faker::Name.unique.name
|
5
|
+
Faker::Name.unique.first_name
|
6
|
+
Faker::Name.unique.last_name
|
7
|
+
|
8
|
+
Faker::Hacker.unique.say_something_smart
|
9
|
+
Faker::String.unique.troublesome
|
10
|
+
|
11
|
+
Faker::Lorem.unique.sentences.join(' ')
|
12
|
+
Faker::Lorem.unique.words.join(' ')
|
13
|
+
Faker::Lorem.unique.characters(10)
|
14
|
+
Faker::Lorem.unique.paragraphs.join("\n\n")
|
15
|
+
|
16
|
+
Faker::Internet.email
|
17
|
+
Faker::Internet.unique.user_name
|
18
|
+
Faker::Internet.unique.url
|
19
|
+
Faker::Internet.unique.ip_v4_address
|
20
|
+
|
21
|
+
Faker::Number.unique.between(1, 10_000)
|
22
|
+
Faker::Number.unique.decimal(4, 2)
|
23
|
+
|
24
|
+
Faker::Company.catch_phrase
|
25
|
+
Faker::Company.buzzword
|
26
|
+
# When a straight answer won't do, BS to the rescue!
|
27
|
+
Faker::Company.bs
|
28
|
+
Faker::Company.logo #=> "https://pigment.github.com/fake-logos/logos/medium/color/5.png"
|
29
|
+
Faker::Company.profession #=> "firefighter"
|
30
|
+
Faker::Company.australian_business_number #=> "81137773602"
|
31
|
+
|
32
|
+
Faker::Artist.name
|
33
|
+
Faker::Address.city #=> "Imogeneborough"
|
34
|
+
Faker::Address.street_name #=> "Larkin Fork"
|
35
|
+
Faker::Address.street_address #=> "282 Kevin Brook"
|
36
|
+
Faker::Address.secondary_address #=> "Apt. 672"
|
37
|
+
Faker::Address.building_number #=> "7304"
|
38
|
+
Faker::Address.mail_box #=> "PO Box 123"
|
39
|
+
Faker::Address.community #=> "University Crossing"
|
40
|
+
Faker::Address.zip_code #=> "58517" or "23285-4905"
|
41
|
+
Faker::Address.zip #=> "58517" or "66259-8212"
|
42
|
+
Faker::Address.postcode #=> "76032-4907" or "58517"
|
43
|
+
Faker::Address.time_zone #=> "Asia/Yakutsk"
|
44
|
+
Faker::Address.street_suffix #=> "Street"
|
45
|
+
Faker::Address.city_suffix #=> "fort"
|
46
|
+
Faker::Address.city_prefix #=> "Lake"
|
47
|
+
Faker::Address.state #=> "California"
|
48
|
+
Faker::Address.state_abbr #=> "AP"
|
49
|
+
Faker::Address.country #=> "French Guiana"
|
50
|
+
|
51
|
+
# Keyword arguments: code
|
52
|
+
Faker::Address.country_by_code(code: 'NL') #=> "Netherlands"
|
53
|
+
|
54
|
+
# Keyword arguments: name
|
55
|
+
Faker::Address.country_name_to_code(name: 'united_states') #=> "US"
|
56
|
+
Faker::Address.country_code #=> "IT"
|
57
|
+
Faker::Address.country_code_long #=> "ITA"
|
58
|
+
Faker::Address.latitude #=> "-58.17256227443719"
|
59
|
+
Faker::Address.longitude #=> "-156.65548382095133"
|
60
|
+
Faker::Address.full_address #=> "282 Kevin Brook, Imogeneborough, CA 58517"
|
61
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :article do
|
3
|
+
title { Faker::Quote.famous_last_words }
|
4
|
+
body { Faker::Lorem.paragraphs(number: rand(4...10)).join("\n") }
|
5
|
+
is_featured { [true, false].sample }
|
6
|
+
published { rand(1..10) > 8 ? nil : rand(1..20).days.ago }
|
7
|
+
# employee { nil }
|
8
|
+
# tenant { nil }
|
9
|
+
trait :unpublished do
|
10
|
+
published { nil }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :employee do
|
3
|
+
first_name { Faker::Name.first_name }
|
4
|
+
last_name { Faker::Name.last_name }
|
5
|
+
email { Faker::Internet.email }
|
6
|
+
password { Faker::Internet.password }
|
7
|
+
address { Faker::Address.full_address }
|
8
|
+
role # { %i[role_contributor role_moderator role_admin].sample }
|
9
|
+
# tenant { nil }
|
10
|
+
# role { nil }
|
11
|
+
|
12
|
+
# trait :contributor do
|
13
|
+
# role :contributor_role
|
14
|
+
# end
|
15
|
+
|
16
|
+
# trait :moderator do
|
17
|
+
# role :moderator_role
|
18
|
+
# end
|
19
|
+
|
20
|
+
# trait :admin do
|
21
|
+
# role :admin_role
|
22
|
+
# end
|
23
|
+
|
24
|
+
# factory :contributor_user , traits: [:contributor]
|
25
|
+
# factory :moderator_user , traits: [:moderator]
|
26
|
+
# factory :admin_user , traits: [:admin]
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
# factory :employee do
|
31
|
+
# first_name { "MyString" }
|
32
|
+
# last_name { "MyString" }
|
33
|
+
# address { "MyText" }
|
34
|
+
# email { "MyString" }
|
35
|
+
# password { "MyString" }
|
36
|
+
# end
|
37
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :project do
|
3
|
+
name { Faker::App.name }
|
4
|
+
status { %i[closed rejected failed loading running waiting done finalized archived finished].sample }
|
5
|
+
budget { Faker::Number.decimal(l_digits: 4) }
|
6
|
+
country { Faker::Address.country_code }
|
7
|
+
progress { Faker::Number.between(from: 0, to: 100) }
|
8
|
+
# tenant { nil }
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :region do
|
3
|
+
name { Faker::Australia.location } # Faker::App.name
|
4
|
+
settings { Faker::Json.shallow_json(width: 3, options: { key: 'Name.first_name', value: 'Name.last_name' }) }
|
5
|
+
|
6
|
+
# These traits are used to define well known variations of a factory
|
7
|
+
trait :western_sydney do
|
8
|
+
name { 'Western Sydney' }
|
9
|
+
settings { { 'suburbs' => ['Blacktown', 'Parramatta', 'Penrith', 'Campbelltown', 'Liverpool'] } }
|
10
|
+
end
|
11
|
+
|
12
|
+
trait :sydney do
|
13
|
+
name { 'Sydney CBD' }
|
14
|
+
settings { { 'suburbs' => ['Sydney', 'Sydney CBD', 'Surry Hills', 'Darling Harbour', 'Barangaroo'] } }
|
15
|
+
end
|
16
|
+
|
17
|
+
trait :eastern_suburbs do
|
18
|
+
name { 'Eastern Suburbs' }
|
19
|
+
settings { { 'suburbs' => ['Bondi', 'Bondi Beach', 'Bondi Junction', 'Bronte', 'Coogee', 'Darlinghurst'] }}
|
20
|
+
end
|
21
|
+
|
22
|
+
trait :inner_west do
|
23
|
+
name { 'Inner West' }
|
24
|
+
settings { { 'suburbs' => ['Ashfield', 'Burwood', 'Campsie', 'Croydon', 'Newtown'] } }
|
25
|
+
end
|
26
|
+
|
27
|
+
trait :north_shore do
|
28
|
+
name { 'North Shore' }
|
29
|
+
settings { { 'suburbs' => ['Pymble', 'Castle Cove', 'Castlecrag', 'Chatswood', 'Crows Nest', 'Cremorne'] } }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :role do
|
3
|
+
code { 'user' }
|
4
|
+
|
5
|
+
trait :contributor do
|
6
|
+
code { 'contributor' }
|
7
|
+
end
|
8
|
+
|
9
|
+
trait :moderator do
|
10
|
+
code { 'moderator' }
|
11
|
+
end
|
12
|
+
|
13
|
+
trait :admin do
|
14
|
+
code { 'admin' }
|
15
|
+
end
|
16
|
+
|
17
|
+
# factory :contributor_role , traits: [:contributor]
|
18
|
+
# factory :moderator_role , traits: [:moderator]
|
19
|
+
# factory :admin_role , traits: [:admin]
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
SeedService.seed
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# BDD for Ruby
|
4
|
+
#
|
5
|
+
# exe/rag addons/rspec
|
6
|
+
|
7
|
+
# NOTE: Currently not implemented fully
|
8
|
+
|
9
|
+
self.local_template_path = File.dirname(__FILE__)
|
10
|
+
|
11
|
+
gac 'base rails 7 image created'
|
12
|
+
|
13
|
+
prepare_environment
|
14
|
+
|
15
|
+
after_bundle do
|
16
|
+
create_db
|
17
|
+
scaffolds
|
18
|
+
setup_customizations
|
19
|
+
migrate_db
|
20
|
+
end
|
21
|
+
|
22
|
+
def scaffolds
|
23
|
+
# add_scaffold('post', 'title', 'body:text', 'user:references')
|
24
|
+
# add_scaffold('people', 'first_name', 'last_name', 'age:integer', 'address:text')
|
25
|
+
# add_scaffold('product', 'name', 'price:integer')
|
26
|
+
end
|
27
|
+
|
28
|
+
def setup_customizations
|
29
|
+
route("root 'home#index'")
|
30
|
+
|
31
|
+
force_copy
|
32
|
+
|
33
|
+
add_controller('home', 'index')
|
34
|
+
|
35
|
+
directory "app/controllers"
|
36
|
+
directory "app/models"
|
37
|
+
directory "app/views"
|
38
|
+
template 'app/views/layouts/application.html.erb' , 'app/views/layouts/application.html.erb'
|
39
|
+
directory "app/services"
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_db
|
43
|
+
# uncomment this if you need custom configuration in database.yml
|
44
|
+
# gsub_file('config/database.yml', ' encoding: unicode', db_development_settings)
|
45
|
+
db(drop: true, create: true)
|
46
|
+
end
|
47
|
+
|
48
|
+
def migrate_db
|
49
|
+
template 'db/seeds.rb' , 'db/seeds.rb'
|
50
|
+
|
51
|
+
db(migrate: true, seed: true)
|
52
|
+
end
|
53
|
+
|
54
|
+
def db_development_settings
|
55
|
+
<<-'RUBY'
|
56
|
+
encoding: unicode
|
57
|
+
host: 127.0.0.1
|
58
|
+
username: printspeak
|
59
|
+
password: printspeak
|
60
|
+
RUBY
|
61
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
+
# Person.delete_all
|
19
|
+
# Post.delete_all
|
20
|
+
# Project.delete_all
|
21
|
+
end
|
22
|
+
|
23
|
+
def refresh
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
# FactoryBot.create_list(:post, rand(10..20))
|
28
|
+
# FactoryBot.create_list(:person, rand(10..20))
|
29
|
+
# FactoryBot.create_list(:project, rand(10..20))
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
@@ -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,8 @@
|
|
1
|
+
# SeedService.seed
|
2
|
+
# david = User.create(email: 'david@site.com', name: 'david', password: 'password')
|
3
|
+
# james = User.create(email: 'james@site.com', name: 'james', password: 'password')
|
4
|
+
# sally = User.create(email: 'sally@site.com', name: 'sally', password: 'password')
|
5
|
+
|
6
|
+
# 10.times do |i|
|
7
|
+
# Post.create(title: "Post #{i}", body: "This is the body of post #{i}", user: User.all.sample)
|
8
|
+
# 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
|
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
|
-
|
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
|
-
|
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
|
data/after_templates/application/klueless/app/avo/filters/table_count_entry_tablename_filter.rb
ADDED
@@ -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,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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|