Skip to content

Commit

Permalink
KBP-175 #time 1h pronto runner problems solved
Browse files Browse the repository at this point in the history
  • Loading branch information
İsmail Akbudak committed Jan 9, 2018
1 parent 6d980cc commit 9d4c156
Show file tree
Hide file tree
Showing 13 changed files with 116 additions and 60 deletions.
3 changes: 2 additions & 1 deletion .flayignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
templates/app_files/app/controllers/**/*.rb
templates/app_files/app/mailers/**/*.rb
templates/app_files/app/mailers/**/*.rb
lib/cybele/helpers/paperclip.rb
4 changes: 3 additions & 1 deletion .haml-lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
linters:
LineLength:
max: 100
max: 100
UnnecessaryStringOutput:
enabled: false
6 changes: 5 additions & 1 deletion config.reek
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ FeatureEnvy:
enabled: false

UtilityFunction:
public_methods_only: true
public_methods_only: true

TooManyStatements:
enabled: true
max_statements: 6
41 changes: 23 additions & 18 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,11 @@ def initialize(*args)
# Set options
@options = options.dup

return dependency_control(@options) if @options[:skip_ask]

say 'Ask cybele options', :green
option_with_ask_limited(:database, DATABASES)
option_with_ask_yes(:skip_create_database)
option_with_ask_yes(:skip_sidekiq)
option_with_ask_yes(:skip_simple_form)
option_with_ask_yes(:skip_show_for)
option_with_ask_yes(:skip_haml)
option_with_ask_yes(:skip_view_files)
option_with_ask_yes(:skip_docker)
@options.freeze
dependency_control(@options)
dependency_control(@options) if @options[:skip_ask]
ask_questions(@options) unless @options[:skip_ask]
end

# :reek:TooManyStatements
def customize_gemfile
say 'Customize gem file', :green
build :add_gems
Expand Down Expand Up @@ -302,6 +292,21 @@ def get_builder_class

private

# :reek:TooManyStatements
def ask_questions(options)
say 'Ask cybele options', :green
option_with_ask_limited(:database, DATABASES)
option_with_ask_yes(:skip_create_database)
option_with_ask_yes(:skip_sidekiq)
option_with_ask_yes(:skip_simple_form)
option_with_ask_yes(:skip_show_for)
option_with_ask_yes(:skip_haml)
option_with_ask_yes(:skip_view_files)
option_with_ask_yes(:skip_docker)
options.freeze
dependency_control(options)
end

def option_with_ask_yes(key)
say "==> #{key.to_s.humanize}", :green
say 'Type for answer yes: y|yes', :green
Expand All @@ -318,6 +323,7 @@ def dependency_control(selected_options)
arg_checker(selected_options, :skip_view_files, %i[skip_haml skip_show_for skip_simple_form])
end

# :reek:TooManyStatements
def arg_checker(selected_options, option, option_array)
return if selected_options[option]
puts "#{option} dependency error!"
Expand All @@ -328,11 +334,10 @@ def arg_checker(selected_options, option, option_array)
failed = true
end
end
if failed
puts
puts 'See --help for more info'
exit 0
end
return unless failed
puts
puts 'See --help for more info'
exit 0
end
end
end
32 changes: 23 additions & 9 deletions lib/cybele/helpers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ def generate_devise_settings
def generate_devise_models
generate 'devise User name:string surname:string is_active:boolean time_zone:string'
generate 'devise Admin name:string surname:string is_active:boolean time_zone:string'
remove_file 'config/locales/devise.en.yml', force: true
copy_file 'config/locales/devise.en.yml', 'config/locales/devise.en.yml'
copy_file 'config/locales/devise.tr.yml', 'config/locales/devise.tr.yml'
inject_into_file 'db/seeds.rb', after: "# Character.create(name: 'Luke', movie: movies.first)\n" do
template_content('devise/seeds.rb.erb')
end
configure_devise_locale_files
devise_seeds
configure_app_name(%w[db/seeds.rb])
Dir.glob('db/migrate/*devise_create*.rb') do |f|
replace_in_file f, 't.boolean :is_active', 't.boolean :is_active, default: true'
end
add_default_value_to_migrations
end

def generate_devise_views
Expand All @@ -48,6 +42,26 @@ def add_devise_strong_parameter
template_content('devise/devise_before_action_strong_parameter.rb.erb'),
after: 'class ApplicationController < ActionController::Base'
end

private

def configure_devise_locale_files
remove_file 'config/locales/devise.en.yml', force: true
copy_file 'config/locales/devise.en.yml', 'config/locales/devise.en.yml'
copy_file 'config/locales/devise.tr.yml', 'config/locales/devise.tr.yml'
end

def devise_seeds
inject_into_file 'db/seeds.rb', after: "# Character.create(name: 'Luke', movie: movies.first)\n" do
template_content('devise/seeds.rb.erb')
end
end

def add_default_value_to_migrations
Dir.glob('db/migrate/*devise_create*.rb') do |file|
replace_in_file file, 't.boolean :is_active', 't.boolean :is_active, default: true'
end
end
end
end
end
33 changes: 20 additions & 13 deletions lib/cybele/helpers/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,27 @@ def setup_docker_development_env
private

def docker_dotenv_files
unless @options[:skip_sidekiq]
%w[.env.local env.sample].each do |env|
append_file(env, template_content('docker/docker_env_local_sample_sidekiq.erb'))
end
%w[staging production].each do |env|
append_file(".env.#{env}", template_content('docker/docker_env_staging_production_sidekiq.erb'))
end
docker_dotenv_sidekiq
%w[.env.local env.sample].each do |env|
append_template_to_file(env, 'docker/docker_env_local_sample.erb')
end
append_file('env.sample', template_content('docker/docker_env_local_sample.erb'))
append_file('.env.local', template_content('docker/docker_env_local_sample.erb'))
unless @options[:skip_sidekiq]
%w[.env.local env.sample].each do |env|
append_file(env, template_content('docker/docker_env_local_sample_host.erb'))
end
docker_dotenv_sidekiq_local
end

def docker_dotenv_sidekiq_local
return if @options[:skip_sidekiq]
%w[.env.local env.sample].each do |env|
append_template_to_file(env, 'docker/docker_env_local_sample_host.erb')
end
end

def docker_dotenv_sidekiq
return if @options[:skip_sidekiq]
%w[.env.local env.sample].each do |env|
append_template_to_file(env, 'docker/docker_env_local_sample_sidekiq.erb')
end
%w[staging production].each do |env|
append_template_to_file(".env.#{env}", 'docker/docker_env_staging_production_sidekiq.erb')
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/cybele/helpers/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def configure_action_mailer
def configure_smtp
configure_environment 'staging',
template_content('recipient_interceptor/recipient_interceptor_staging.rb.erb')
configure_environment 'production', template_content('mailer/smtp.rb.erb')
configure_environment 'staging', template_content('mailer/smtp.rb.erb')
configure_environment 'development', template_content('mailer/smtp.rb.erb')
%w[production staging development].each do |env|
configure_environment env, template_content('mailer/smtp.rb.erb')
end
append_template_to_file 'config/settings.yml', 'mailer/mailer_settings.yml.erb'
%w[.env.local .env.production .env.staging env.sample].each do |env|
append_file(env, template_content('mailer/.env.local.erb'))
append_template_to_file(env, 'mailer/.env.local.erb')
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/cybele/helpers/pronto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def create_config_files
'pronto/example.pronto.yml.erb' => 'example.pronto.yml',
'pronto/.haml-lint.yml.erb' => '.haml-lint.yml',
'pronto/config.reek.erb' => 'config.reek',
'pronto/.rubocop.yml.erb' => '.rubocop.yml'
'pronto/.rubocop.yml.erb' => '.rubocop.yml',
'pronto/.flayignore.erb' => '.flayignore'
)
end
end
Expand Down
8 changes: 4 additions & 4 deletions templates/app_files/app/views/hq/audits/_filters.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
url: hq_audits_path) do |f|
.form-group
%label
= "#{ t('activerecord.attributes.audits.user_type') }: "
= "#{t('activerecord.attributes.audits.user_type')}: "
= f.input_field :user_type_eq, label: false, class: 'form-control chosen-select',
placeholder: t('activerecord.attributes.audits.user'),
collection: audit_users, include_blank: t('view.select')
Expand All @@ -20,21 +20,21 @@
- type = params[:q][:user_type_eq]
- if type == 'Admin'
%label
= "#{ t('activerecord.attributes.audits.user') }: "
= "#{t('activerecord.attributes.audits.user')}: "
= f.input_field :user_id_eq, label: false, class: 'form-control chosen-select',
placeholder: t('activerecord.attributes.audits.user'),
collection: admins, include_blank: t('view.select')
.form-group
%label
= "#{ t('activerecord.attributes.audits.action') }: "
= "#{t('activerecord.attributes.audits.action')}: "
= f.input_field :action_eq, label: false, class: 'form-control chosen-select',
placeholder: t('activerecord.attributes.audits.action'),
collection: actions_collection,
include_blank: t('view.select')
.form-group
.input-group
%label
= "#{ t('activerecord.attributes.audits.auditable_type') }: "
= "#{t('activerecord.attributes.audits.auditable_type')}: "
= f.input_field :auditable_type_eq, label: false, class: 'form-control chosen-select',
placeholder: t('activerecord.attributes.audits.auditable_type'),
collection: auditable_types_collection(auditable_types),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
.list-group.border-0.card.text-center.text-md-left
%a.list-group-item.d-inline-block{ 'data-parent' => '#sidebar',
href: hq_dashboard_index_path,
class: css_class(hq_dashboard_index_path, not_exist: 'collapsed') }
class: css_class(hq_dashboard_index_path,
not_exist: 'collapsed') }
%i.fas.fa-home
%span.d-none.d-md-inline= t('view.dock.dashboard')
%a.list-group-item.d-inline-block{ 'aria-expanded' => 'false',
'data-parent' => '#sidebar',
'data-toggle' => 'collapse',
href: '#menu_users',
class: css_class([hq_admins_path, hq_users_path], not_exist: 'collapsed') }
href: '#menu-users',
class: css_class([hq_admins_path, hq_users_path],
not_exist: 'collapsed') }
%i.fas.fa-list
%span.d-none.d-md-inline
= t('view.dock.system_users')
.collapse#menu_users{ class: css_class([hq_admins_path, hq_users_path], exist: 'show') }
%a.list-group-item{ 'data-parent' => '#menu_users', href: hq_admins_path }
.collapse#menu-users{ class: css_class([hq_admins_path, hq_users_path], exist: 'show') }
%a.list-group-item{ 'data-parent' => '#menu-users', href: hq_admins_path }
%i.fas.fa-users
= t('activerecord.models.admins')
%a.list-group-item{ 'data-parent' => '#menu_users', href: hq_users_path }
%a.list-group-item{ 'data-parent' => '#menu-users', href: hq_users_path }
%i.fas.fa-users
= t('activerecord.models.users')

Expand Down
5 changes: 5 additions & 0 deletions templates/pronto/.flayignore.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
app/controllers/**/*.rb
app/mailers/**/*.rb
db/migrate/**/*.rb
config/**/*.rb
bin/*
4 changes: 3 additions & 1 deletion templates/pronto/.haml-lint.yml.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
linters:
LineLength:
max: 100
max: 100
UnnecessaryStringOutput:
enabled: false
15 changes: 14 additions & 1 deletion templates/pronto/config.reek.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,17 @@ IrresponsibleModule:

"lib/modules":
IrresponsibleModule:
enabled: true
enabled: true

DuplicateMethodCall:
enabled: false

FeatureEnvy:
enabled: false

UtilityFunction:
public_methods_only: true

TooManyStatements:
enabled: true
max_statements: 6

0 comments on commit 9d4c156

Please sign in to comment.