Module: GenericApp
- Defined in:
- lib/generic_app.rb,
lib/generic_app/version.rb
Overview
rubocop:disable Metrics/ModuleLength
Constant Summary collapse
- VERSION =
'3.0.22'
Class Method Summary collapse
-
.create_new(subdir_name, email, title) ⇒ Object
Create app, stick with SQLite database in development.
- .email_update(subdir_name, email) ⇒ Object
- .git_clone(subdir_name) ⇒ Object
- .print_end_msg(subdir_name) ⇒ Object
- .remove_badges(subdir_name) ⇒ Object
- .remove_dot_git(subdir_name) ⇒ Object
- .remove_heroku_name(subdir_name) ⇒ Object
- .update_origin(subdir_name) ⇒ Object
- .update_pg_setup(subdir_name) ⇒ Object
-
.update_titles(subdir_name, title) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
.update_todo(subdir_name) ⇒ Object
rubocop:enable Metrics/AbcSize.
Class Method Details
.create_new(subdir_name, email, title) ⇒ Object
Create app, stick with SQLite database in development
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/generic_app.rb', line 13 def self.create_new(subdir_name, email, title) t1 = Thread.new { git_clone(subdir_name) } t1.join remove_dot_git(subdir_name) update_pg_setup(subdir_name) remove_heroku_name(subdir_name) email_update(subdir_name, email) remove_badges(subdir_name) update_titles(subdir_name, title) update_todo(subdir_name) update_origin(subdir_name) print_end_msg(subdir_name) end |
.email_update(subdir_name, email) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/generic_app.rb', line 46 def self.email_update(subdir_name, email) email_orig = '[email protected]' path1 = "#{subdir_name}/config/initializers/devise.rb" path2 = "#{subdir_name}/app/views/static_pages/contact.html.erb" path3 = "#{subdir_name}/test/integration/static_pages_test.rb" StringInFile.replace(email_orig, email, path1) StringInFile.replace(email_orig, email, path2) StringInFile.replace(email_orig, email, path3) end |
.git_clone(subdir_name) ⇒ Object
40 41 42 43 44 |
# File 'lib/generic_app.rb', line 40 def self.git_clone(subdir_name) puts '------------------------------------' puts 'Downloading the Generic App Template' system("git clone #{URL_TEMPLATE} #{subdir_name}") end |
.print_end_msg(subdir_name) ⇒ Object
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/generic_app.rb', line 123 def self.print_end_msg(subdir_name) puts '-------------------------' puts 'Rails Neutrino timestamp:' system("cd #{subdir_name} && cat config/rails_neutrino_timestamp.txt") puts '' puts "Your new app is at #{subdir_name}" puts '' puts 'Instructions on how to get started are in the file' puts 'README-to_do.txt within your new app.' end |
.remove_badges(subdir_name) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/generic_app.rb', line 56 def self.remove_badges(subdir_name) path_readme = "#{subdir_name}/README.md" LineContaining.delete_between('BEGIN: badges', 'END: badges', path_readme) LineContaining.delete('[![CircleCI](https://circleci.com', path_readme) LineContaining.delete('[![Build Status](https://travis-ci.org', path_readme) LineContaining.delete('[![Dependency Status](https://gemnasium.com', path_readme) LineContaining.delete('[![security](https://hakiri.io', path_readme) LineContaining.delete('[![Code Climate](https://codeclimate.com', path_readme) LineContaining.delete('[![Maintainability](https://api.codeclimate.com', path_readme) RemoveDoubleBlank.update(path_readme) end |
.remove_dot_git(subdir_name) ⇒ Object
27 28 29 |
# File 'lib/generic_app.rb', line 27 def self.remove_dot_git(subdir_name) FileUtils.rm_rf("#{subdir_name}/.git") end |
.remove_heroku_name(subdir_name) ⇒ Object
31 32 33 |
# File 'lib/generic_app.rb', line 31 def self.remove_heroku_name(subdir_name) File.delete("#{subdir_name}/config/heroku_name.txt") end |
.update_origin(subdir_name) ⇒ Object
68 69 70 71 72 |
# File 'lib/generic_app.rb', line 68 def self.update_origin(subdir_name) path_readme = "#{subdir_name}/README.md" StringInFile.replace('[Rails Neutrino]', '[Generic App]', path_readme) StringInFile.replace('(https://github.com/rubyonracetracks/rails_neutrino_5)', '(https://github.com/rubyonracetracks/generic_app)', path_readme) end |
.update_pg_setup(subdir_name) ⇒ Object
35 36 37 38 |
# File 'lib/generic_app.rb', line 35 def self.update_pg_setup(subdir_name) dir_gem_lib = File.(File.(__dir__)) FileUtils.cp("#{dir_gem_lib}/pg_setup.sh", subdir_name) end |
.update_titles(subdir_name, title) ⇒ Object
rubocop:disable Metrics/AbcSize
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/generic_app.rb', line 75 def self.update_titles(subdir_name, title) array_files = [] array_files << "#{subdir_name}/README.md" array_files << "#{subdir_name}/app/helpers/application_helper.rb" array_files << "#{subdir_name}/app/views/layouts/_header.html.erb" array_files << "#{subdir_name}/app/views/layouts/_footer.html.erb" array_files << "#{subdir_name}/app/views/static_pages/home.html.erb" array_files << "#{subdir_name}/test/helpers/application_helper_test.rb" array_files << "#{subdir_name}/test/integration/static_pages_test.rb" array_files << "#{subdir_name}/app/views/admins/mailer/confirmation_instructions.html.erb" array_files << "#{subdir_name}/app/views/admins/mailer/email_changed.html.erb" array_files << "#{subdir_name}/app/views/admins/mailer/unlock_instructions.html.erb" array_files << "#{subdir_name}/app/views/admins/mailer/reset_password_instructions.html.erb" array_files << "#{subdir_name}/app/views/admins/mailer/password_change.html.erb" array_files << "#{subdir_name}/app/views/users/mailer/confirmation_instructions.html.erb" array_files << "#{subdir_name}/app/views/users/mailer/email_changed.html.erb" array_files << "#{subdir_name}/app/views/users/mailer/unlock_instructions.html.erb" array_files << "#{subdir_name}/app/views/users/mailer/reset_password_instructions.html.erb" array_files << "#{subdir_name}/app/views/users/mailer/password_change.html.erb" array_files << "#{subdir_name}/config/locales/devise.en.yml" array_files << "#{subdir_name}/test/integration/user_resend_conf_test.rb" array_files << "#{subdir_name}/test/integration/user_password_reset_test.rb" array_files << "#{subdir_name}/test/integration/user_login_test.rb" array_files << "#{subdir_name}/test/integration/user_lock_test.rb" array_files << "#{subdir_name}/test/integration/user_edit_test.rb" array_files << "#{subdir_name}/test/integration/admin_resend_conf_test.rb" array_files << "#{subdir_name}/test/integration/admin_password_reset_test.rb" array_files << "#{subdir_name}/test/integration/admin_lock_test.rb" array_files << "#{subdir_name}/test/integration/admin_edit_test.rb" array_files.each do |f| StringInFile.replace('Generic App Template', title, f) StringInFile.replace('GENERIC APP TEMPLATE', title, f) end end |
.update_todo(subdir_name) ⇒ Object
rubocop:enable Metrics/AbcSize
117 118 119 120 121 |
# File 'lib/generic_app.rb', line 117 def self.update_todo(subdir_name) url_todo = 'https://github.com/rubyonracetracks/cheat_sheets/blob/master/post_generic_app.md' msg_todo = "Go to #{url_todo} for further instructions." StringInFile.write("#{msg_todo}\n", "#{subdir_name}/README-to_do.txt") end |