Module: GenericApp
- Defined in:
- lib/generic_app.rb,
lib/generic_app/version.rb
Constant Summary collapse
- VERSION =
"1.0.1"
Class Method Summary collapse
- .add(subdir_name) ⇒ Object
- .copy_scripts(subdir_name) ⇒ Object
-
.create_new(subdir_name, email) ⇒ Object
Create app, stick with SQLite database in development.
- .email_update(subdir_name, email) ⇒ Object
- .git_clone(subdir_name) ⇒ Object
- .git_init(subdir_name) ⇒ Object
- .update_gitignore(subdir_name, str) ⇒ Object
Class Method Details
.add(subdir_name) ⇒ Object
47 48 49 50 51 |
# File 'lib/generic_app.rb', line 47 def self.add (subdir_name) self.update_gitignore(subdir_name, 'tmp*') self.update_gitignore(subdir_name, '.DS_Store') self.copy_scripts (subdir_name) end |
.copy_scripts(subdir_name) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/generic_app.rb', line 68 def self.copy_scripts (subdir_name) puts "----------------------------------------------" puts "Adding scripts and config/database-pg.yml file" dir_template = "#{ENV['DIR_PARENT']}/high_speed_rails_clobbers_not_exactly" self.git_clone (dir_template) system("cp -r #{dir_template}/*.sh #{subdir_name}") system("cp -r #{dir_template}/*.rb #{subdir_name}") system("cp -r #{dir_template}/config/database-pg.yml #{subdir_name}/config") system("rm -rf #{dir_template}") end |
.create_new(subdir_name, email) ⇒ Object
Create app, stick with SQLite database in development
12 13 14 15 16 |
# File 'lib/generic_app.rb', line 12 def self.create_new (subdir_name, email) self.git_clone (subdir_name) self.email_update(subdir_name, email) self.git_init (subdir_name) end |
.email_update(subdir_name, email) ⇒ Object
27 28 29 30 31 |
# File 'lib/generic_app.rb', line 27 def self.email_update (subdir_name, email) email_orig = '[email protected]' path_of_email = "#{subdir_name}/config/initializers/devise.rb" StringInFile.replace(email_orig, email, path_of_email) end |
.git_clone(subdir_name) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/generic_app.rb', line 18 def self.git_clone (subdir_name) puts "------------------------------------" puts "Downloading the Generic App Template" t1 = Thread.new { system("git clone https://github.com/jhsu802701/generic_app_template.git #{subdir_name}") } t1.join end |
.git_init(subdir_name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generic_app.rb', line 33 def self.git_init (subdir_name) puts "----------------" puts "Initializing Git" t1 = Thread.new { $stdout = File.new( '/dev/null', 'w' ) system("cd #{subdir_name} && rm -rf .git") system("cd #{subdir_name} && git init") system("cd #{subdir_name} && git add .") system("cd #{subdir_name} && git commit -m 'Initial commit' >/dev/null") $stdout = STDOUT } t1.join end |
.update_gitignore(subdir_name, str) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/generic_app.rb', line 53 def self.update_gitignore (subdir_name, str) puts '-----------------------------------' puts "Updating .gitignore (adding #{str})" if StringInFile.present(str, "#{subdir_name}/.gitignore") == false text_from_file = File.read("#{subdir_name}/.gitignore") last_char = text_from_file[-1] open("#{subdir_name}/.gitignore", 'a') { |f| if last_char != "\n" f.puts "\n" end f.puts "\n#{str}" } end end |