class Starter
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/r5/starter.rb, line 9 def initialize(*args) super unless File.exists? "#{Dir.home}/.r5.yml" say "Need to create config file - answer following question", :green create_config_file end if (system "rails -v").nil? or (%x[rails -v] =~ /Rails 5.2.*/).nil? say "You didn't install Rails or have version lower than 5.2 Please install proper version.", :red abort end if (system "yarn --version").nil? say "You need to install yarn on your system to manage javascript assets", :red abort end if (system "webpack").nil? say "You need to install webpack", :red abort end unless Config.check_settings.empty? say Config.check_settings, :green say 'Check structure of your config file - it seems you are missing required options mentioned above', :red abort end if ARGV[0] =~ /new/ @dir = `pwd`.gsub("\n", '') elsif ARGV[0] =~ /add/ if yes? 'Are you in right folder of your app?' @project_path = `pwd`.gsub("\n", '') @project_name = @project_path.split('/').last @project_label = @project_name.capitalize.gsub('_', ' ') else say 'Get to proper directory', :red abort end end end
Public Instance Methods
add_best_in_place()
click to toggle source
# File lib/r5/starter.rb, line 123 def add_best_in_place say 'Not ready yet!', :red #gem 'best_in_place' end
add_datatables()
click to toggle source
# File lib/r5/starter.rb, line 106 def add_datatables say 'Not ready yet!', :red #gem 'jquery-datatables-rails', '~> 2.2.3' end
add_exception_notification()
click to toggle source
# File lib/r5/starter.rb, line 112 def add_exception_notification apply 'recipes/exception_notification.rb' end
add_gem(name, version="")
click to toggle source
# File lib/r5/starter.rb, line 176 def add_gem name, version="" append_to_file "#{@project_path}/Gemfile" do version == "" ? "\ngem '#{name}'" : "\ngem '#{name}', '#{version}'" end end
add_lazy_charts()
click to toggle source
# File lib/r5/starter.rb, line 101 def add_lazy_charts apply 'recipes/lazy_high_charts.rb' end
add_mail_gem()
click to toggle source
# File lib/r5/starter.rb, line 129 def add_mail_gem say 'Not ready yet!', :red #gem 'mail' end
add_rack_mini_profiler()
click to toggle source
# File lib/r5/starter.rb, line 86 def add_rack_mini_profiler apply 'recipes/add_rack_mini_profiler.rb' end
add_skylight()
click to toggle source
# File lib/r5/starter.rb, line 117 def add_skylight say 'Not ready yet!', :red #gem 'skylight' end
add_timepress_specifics()
click to toggle source
# File lib/r5/starter.rb, line 81 def add_timepress_specifics apply 'recipes/timepress_specifics.rb' end
add_wicked_pdf()
click to toggle source
# File lib/r5/starter.rb, line 91 def add_wicked_pdf apply 'recipes/wicked_pdf.rb' end
add_xlsx_support()
click to toggle source
# File lib/r5/starter.rb, line 96 def add_xlsx_support apply 'recipes/xlsx_support.rb' end
check_gem_existence(name)
click to toggle source
# File lib/r5/starter.rb, line 182 def check_gem_existence name File.read("#{@project_path}/Gemfile") =~ /#{name}/ end
copy(filename, destination_name=nil)
click to toggle source
# File lib/r5/starter.rb, line 162 def copy filename, destination_name=nil new_name = destination_name ? destination_name : filename copy_file filename, "#{@project_path}/#{new_name}" end
create_config_file()
click to toggle source
# File lib/r5/starter.rb, line 137 def create_config_file settings = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) } settings['mysql']['user'] = ask("Insert name of mysql user:") settings['mysql']['password'] = ask("Insert password for mysql user:") settings['mysql']['host'] = ask("Host of mysql user:", default: 'localhost') settings['admin']['login'] = ask("Login of default admin user:", default: 'admin') settings['admin']['password'] = ask("Password of default password:", default: 'password') settings['admin']['email'] = ask("E-mail of default user:", default: 'admin@example.com') settings['admin']['lastname'] = ask("Lastname of default user:", default: 'administrator') settings['notifier']['email'] = ask("Email for exception notification:", default: 'code@example.com') settings['server']['name_prod'] = ask("Production server adddress:") settings['server']['name_stage'] = ask("Stage server address:") settings['server']['port'] = ask("SSH port for both:") settings['server']['user'] = ask("Name of user on servers:") File.open("#{Dir.home}/.r5.yml", 'w') do |file| file.write(settings.to_yaml) end end
my_directory(path)
click to toggle source
# File lib/r5/starter.rb, line 167 def my_directory path # rewriting thor directory method directory path, "#{@project_path}/#{path}" end
new(project_name)
click to toggle source
# File lib/r5/starter.rb, line 59 def new project_name @project_name = project_name run "rails new #{@project_name} -T --skip-bundle" @project_path = "#{@dir}/#{@project_name}" @project_label = @project_name.capitalize.gsub('_', ' ') Dir.chdir @project_path # TODO read some config folder in home directory for user customized installations types unless options[:type] apply 'installations/default.rb' else apply "installations/#{options[:type]}.rb" end # run 'gem install foreman' # copy 'Procfile' say 'Start your application with rails s', :green end
remove(filename)
click to toggle source
# File lib/r5/starter.rb, line 172 def remove filename remove_file "#{@project_path}/#{filename}" end
source_paths()
click to toggle source
# File lib/r5/starter.rb, line 157 def source_paths root_path = File.dirname __FILE__ [root_path + '/template', root_path] end