Class: Jah::Install
Instance Method Summary collapse
-
#do_reports? ⇒ Boolean
REPORTS.
-
#duck_talk ⇒ Object
DUCK TALK.
-
#fail! ⇒ Object
FAIL.
-
#get_acl ⇒ Object
ACL.
-
#get_groups ⇒ Object
GROUPS.
-
#get_host ⇒ Object
HOST.
-
#get_jid ⇒ Object
JID.
-
#get_key ⇒ Object
KEY.
-
#get_mode ⇒ Object
MODE.
-
#get_pass ⇒ Object
PASS.
-
#initialize ⇒ Install
constructor
A new instance of Install.
-
#show_crontab ⇒ Object
CRONTAB.
-
#success! ⇒ Object
SUCCESS!.
-
#use_eval? ⇒ Boolean
EVAL.
-
#use_god? ⇒ Boolean
GOD.
- #write_down ⇒ Object
Methods inherited from Cli
Constructor Details
#initialize ⇒ Install
Returns a new instance of Install.
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/jah/install.rb', line 283 def initialize abort usage unless $stdin.tty? puts "No config file found.. running install.." @config = {} @config[:host] = Opt.hostname get_mode if @config[:mode] == 'xmpp' @config[:host] = '' get_jid get_pass end if @config[:mode] == 'post' @config[:jid] = '' get_key end # FIXME: when god support happens @config[:god] = false # unless use_god? # unless daemonize? # show_crontab # end # end get_host get_acl get_groups use_eval? duck_talk do_reports? @config[:debug] = :info puts "" puts "== Writing Config File ==" puts "" write_down success! exit #puts "\nAttempting to contact the server..." #begin # Jah::Server.new # rescue SystemExit # end end |
Instance Method Details
#do_reports? ⇒ Boolean
REPORTS
176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/jah/install.rb', line 176 def do_reports? puts <<-END_INTRO.gsub(/^ {8}/, "") == Reports == Report my status from time to time to ppl on the roster? END_INTRO print "Report interval in seconds (0 to disable): " @config[:report] = gets.to_s.strip.to_i end |
#duck_talk ⇒ Object
DUCK TALK
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/jah/install.rb', line 224 def duck_talk locs = I18n.available_locales.map { |l| l.to_s.downcase } puts <<-END_I18N.gsub(/^ {10}/, "") == Machine Personality == Jah goes a lil further than localization, you can make your machine talk to you like a lady, R2D2, el chespirito, who knows... fork me and add one! Available options: * #{locs.join("\n* ")} END_I18N print "Choose one (#{Opt.locale}): " @config[:i18n] = gets.to_s.strip.downcase @config[:i18n] = Opt.locale if @config[:i18n] == "" end |
#fail! ⇒ Object
FAIL
265 266 267 268 269 270 271 272 273 274 |
# File 'lib/jah/install.rb', line 265 def fail! puts <<-END_ERROR.gsub(/^ {10}/, "") Could not contact server. The client key may be incorrect. For more help, please visit: http://jahurl.com/help END_ERROR end |
#get_acl ⇒ Object
ACL
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/jah/install.rb', line 111 def get_acl puts <<-END_INTRO.gsub(/^ {8}/, "") == Access Control List == Please enter the JIDs you want Jah to talk to. Use commas to separate multiple ones. END_INTRO print "ACL: " @config[:acl] = gets.split(",").map(&:strip) end |
#get_groups ⇒ Object
GROUPS
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/jah/install.rb', line 128 def get_groups puts <<-END_INTRO.gsub(/^ {8}/, "") == Groups (Chats) == Please enter the conference room(s) Jah should log in. Use commas to separate multiple ones. END_INTRO print "Groups: " @config[:groups] = gets.split(",").map(&:strip) end |
#get_host ⇒ Object
HOST
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/jah/install.rb', line 91 def get_host puts <<-END_INTRO.gsub(/^ {8}/, "") == Domain == Enter the domain Jah will use for XMPP connect and conference search. END_INTRO d = @config[:jid].split("@")[1] print "Your host address" print d ? " (#{d}): " : ": " @config[:host] = gets.strip @config[:host] = d if @config[:host] == "" end |
#get_jid ⇒ Object
JID
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jah/install.rb', line 37 def get_jid puts <<-END_INTRO.gsub(/^ {8}/, "") == XMPP JID == Good choice! Now we need this server JID. Tip: You can create it on God Web. It looks like: [email protected] END_INTRO print "Enter the Client JID: " @config[:jid] = gets.to_s.strip end |
#get_key ⇒ Object
KEY
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/jah/install.rb', line 72 def get_key puts <<-END_INTRO.gsub(/^ {8}/, "") == Jah Web Key == You need the Key displayed in the server page. It looks like: 5e89c3c3035c8c1ee1b52dce81eee6 END_INTRO print "Enter the Client Key: " @config[:key] = gets.to_s.strip end |
#get_mode ⇒ Object
MODE
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jah/install.rb', line 13 def get_mode puts <<-END_MODE.gsub(/^ {8}/, "") === Jah Gem Install === Hello, thanks for trying Jah! Looks like #{Opt.hostname} doesn`t have a config file, shall we create one? Jah needs to know how it will run: xmpp, post or dump. END_MODE mode = nil print "Enter mode: " while mode !~ /xmpp|post|dump/i print "Valid: xmpp, post or dump: " mode = gets.strip end @config[:mode] = mode end |
#get_pass ⇒ Object
PASS
58 59 60 61 62 63 64 65 66 |
# File 'lib/jah/install.rb', line 58 def get_pass puts <<-END_INTRO.gsub(/^ {8}/, "") == XMPP Password == END_INTRO print "Your XMPP client password: " @config[:key] = gets.to_s.strip end |
#show_crontab ⇒ Object
CRONTAB
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/jah/install.rb', line 194 def show_crontab puts <<-CRON If you are using the system crontab (usually located at /etc/crontab): ****** START CRONTAB SAMPLE ****** */30 * * * * #{user} #{program_path} #{key} ****** END CRONTAB SAMPLE ****** If you are using this current user's crontab (using crontab -e to edit): ****** START CRONTAB SAMPLE ****** */30 * * * * #{program_path} #{key} ****** END CRONTAB SAMPLE ****** For help setting up Scout with crontab, please visit: http://scoutapp.com/help#cron CRON end |
#success! ⇒ Object
SUCCESS!
247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/jah/install.rb', line 247 def success! puts <<-END_SUCCESS.gsub(/^ {10}/, "") == Success! == Jah config file was written to #{@outfile}. Just run `jah` to start it! END_SUCCESS daemon = gets.to_s.strip end |
#use_eval? ⇒ Boolean
EVAL
160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/jah/install.rb', line 160 def use_eval? puts <<-END_INTRO.gsub(/^ {8}/, "") == Eval Ruby == Do you want to eval ruby code, using an ! in front of a command? END_INTRO print "Use Eval? (Y/n): " @config[:eval] = gets.to_s.strip == "n" ? false : true end |
#use_god? ⇒ Boolean
GOD
146 147 148 149 150 151 152 153 154 |
# File 'lib/jah/install.rb', line 146 def use_god? puts <<-END_INTRO.gsub(/^ {8}/, "") == God Config == END_INTRO print "Use God? (Y/n): " @config[:god] = gets.to_s.strip == "n" ? false : true end |
#write_down ⇒ Object
276 277 278 279 280 281 |
# File 'lib/jah/install.rb', line 276 def write_down outfile = "jah.yaml" @outfile = File.writable?("/etc/") ? "/etc/" + outfile : HOME + outfile puts "Writing config to #{@outfile}.." File.open(@outfile, "w") { |f| f.write @config.to_yaml } end |