Class: Webbynode::Commands::User

Inherits:
Webbynode::Command show all
Defined in:
lib/webbynode/commands/user.rb

Constant Summary

Constants inherited from Webbynode::Command

Webbynode::Command::Aliases, Webbynode::Command::CommandError, Webbynode::Command::InvalidCommand, Webbynode::Command::InvalidOption, Webbynode::Command::Settings

Instance Method Summary collapse

Methods inherited from Webbynode::Command

add_alias, #api, class_for, command, command_class_name, description, for, #gemfile, #git, help, inherited, #initialize, #io, #no?, #notify, option, #option, #options, options_help, #param, #param_values, parameter, #params, #params_hash, params_help, #pushand, #remote_executor, requires_initialization!, requires_options!, requires_pushed_application!, #run, #server, setting, #settings, summary, summary_help, usage, #validate_initialization, #validate_options, #yes?

Constructor Details

This class inherits a constructor from Webbynode::Command

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
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
# File 'lib/webbynode/commands/user.rb', line 6

def execute
  io.log "Rapp Trial - http://rapp.webbynode.com"
  io.log ""
  
  if user = io.general_settings['rapp_username']
    io.log "User #{user} is already configured for Rapp Trial."
    if ask('Do you want to overwrite this settings (y/n)?') != 'y'
      io.log ""
      io.log "Aborted."
      return
    end 
  end
  
  io.log "Rapp Trial is a good way to try Webbynode's Rapp Engine without being a subscriber."
  io.log "You can deploy your application and it will be online for up to 24 hours. We delete"
  io.log "all applications at 2AM EST, but your user will remain valid."
  io.log ""
  io.log "Please enter your email below."
  io.log ""

  begin
    email = ask('Email: ') 
  end until valid_email?(email)
  
  io.log ""
  io.log "Enter an username and password to start using Rapp Trial."
  io.log ""
  
  begin
    user = ask('         Username: ') 
  end until valid_user?(user)
  
  begin
    begin
      pass = ask('Choose a password: ') { |q| q.echo = "*" }
    end until valid_pass?(pass)
    conf = ask('   Enter it again: ') { |q| q.echo = "*" }
  end until valid_conf?(pass, conf)

  response = Webbynode::Trial.add_user(user, pass, email)
  
  io.log ""
  
  if response["success"]
    io.add_general_setting "rapp_username", user
    puts response["message"]
  else
    puts "ERROR: #{response["message"]}"
  end
end