Module: Ghaki::Account::UserDomain
Constant Summary collapse
- USERDOMAIN_RETRY_MAX =
CONSTANTS
3
Instance Attribute Summary collapse
-
#userdomain ⇒ Object
OBJECT METHODS.
Class Method Summary collapse
-
.get_env ⇒ Object
———————————————————————.
Instance Method Summary collapse
-
#ask_userdomain(opts = {}) ⇒ Object
———————————————————————.
-
#valid_userdomain? ⇒ Boolean
———————————————————————.
Methods included from SynOpts
Instance Attribute Details
#userdomain ⇒ Object
OBJECT METHODS
32 33 34 |
# File 'lib/ghaki/account/userdomain.rb', line 32 def userdomain @userdomain end |
Class Method Details
.get_env ⇒ Object
25 26 27 |
# File 'lib/ghaki/account/userdomain.rb', line 25 def UserDomain.get_env ENV['USERDOMAIN'] end |
Instance Method Details
#ask_userdomain(opts = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ghaki/account/userdomain.rb', line 55 def ask_userdomain opts={} o_prompt,r_prompt = _userdomain_prompt(opts), nil defval = opts[:default] || @userdomain defval = UserDomain.get_env if defval == :env (1 .. (opts[:retry_max] || USERDOMAIN_RETRY_MAX) ).each do self.userdomain = HighLine.new.ask( r_prompt||o_prompt ) do |q| q.echo = true q.default = defval unless defval.nil? end return @userdomain if valid_userdomain? r_prompt ||= '* TRY AGAIN * ' + o_prompt end raise InvalidUserDomainError, "Invalid User Domain: #{@userdomain}" end |
#valid_userdomain? ⇒ Boolean
47 48 49 50 51 52 |
# File 'lib/ghaki/account/userdomain.rb', line 47 def valid_userdomain? return false if @userdomain.nil? return false if @userdomain.empty? return false unless @userdomain =~ %r{\A\w+\z}o return true end |