Class: Swiftly::Init
- Inherits:
-
Thor
- Object
- Thor
- Swiftly::Init
- Includes:
- Helpers, Thor::Actions
- Defined in:
- lib/swiftly/init.rb
Instance Method Summary collapse
Methods included from Helpers
#find_and_replace, #find_and_replace_all, #fix_serialization, #fix_text, #mina, #return_cmd, #swiftly_shell, #unzip, #update_setting, #verifiy_mina_credentials, #zip
Instance Method Details
#init ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 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 115 116 117 118 119 120 121 122 123 |
# File 'lib/swiftly/init.rb', line 15 def init say # spacer say "\t\t#{APP_NAME} #{VERSION} Web Development Project Manager\n\n", :blue say_status "#{APP_NAME}:", "Thanks for trying out #{APP_NAME}. Lets get started!", :green settings = [] inside Dir.home do responses = ['y','Y',''] questions = { sites_path: "\n\n--> What is the absolute path to the folder \n\s\s\s\swhere you keep all of your sites? (\e[0;m#{Dir.home}\e[33;m):", db_host: "\n--> What is your local hostname? (\e[0;mlocalhost\e[33;m):", db_user: "\n--> What is your local mysql username? (\e[0;mroot\e[33;m):", db_pass: "\n--> What is your local mysql password?" } questions.each do |type, question| confirm = false until confirm == true do if type === :sites_path answer = File.( ask question, :yellow, :path => true ) elsif type === :db_pass answer = ask question, :yellow, :echo => false else answer = ask question, :yellow end if type === :sites_path && answer == '' answer = Dir.home elsif type === :db_pass password = ask "\n\n--> Please re-enter your password?", :yellow, :echo => false say #spacer until password == answer say_status "#{APP_NAME}:", "Passwords did not match please try again.\n", :yellow answer = ask question, :yellow, :echo => false password = ask "\n--> Please re-enter your password?\n", :yellow, :echo => false end if password == answer confirm = true end elsif answer == '' if question[/\e\[[0-9;]*[a-zA-Z](.*)\e\[[0-9;]*[a-zA-Z]/, 1] == '' answer = nil else answer = question[/\e\[[0-9;]*[a-zA-Z](.*)\e\[[0-9;]*[a-zA-Z]/, 1] end end unless type === :db_pass if responses.include? ask( "\n--> Got it! Is this correct? \e[32;m#{answer}\e[0;m [Y|n]") confirm = true end end end settings << answer end say_status "\n\s\s\s\sThats it!", "You can now run [#{APP_NAME} help] for more options." end Swiftly::ConfigGlobalGenerator.new([ settings[0] ]).invoke_all ConfigSwiftlyfileGenerator.new([ settings[1], settings[2], settings[3] ]).invoke_all end |