Class: Lono::Registration::User
- Includes:
- Template::Context::Helpers
- Defined in:
- lib/lono/registration/user.rb
Instance Method Summary collapse
Methods included from Template::Context::Helpers
Methods inherited from Base
#api, #get_temp_key, #initialize, #request_verification, #say, #with_safety
Constructor Details
This class inherits a constructor from Lono::Registration::Base
Instance Method Details
#check ⇒ Object
5 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 |
# File 'lib/lono/registration/user.rb', line 5 def check info = read_registration unless info say "Lono is not registered." say "The .lono/registration.yml file does not exist." return false end @resp = request_verification(info) # A non-200 response means there was a non-200 http response. Failsafe behavior is to continue. # Unless called from the cli: lono registration check if @resp.nil? if [:cli] puts "There was an error with the API. Unable to confirm lono registration." return false else return true end end if @resp[:valid] say "Lono registration looks good!" return true end if @resp[:message] say "Lono is not correctly registered. Unable to confirm info in #{@found}" say @resp[:message] end false end |
#read_registration ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lono/registration/user.rb', line 37 def read_registration folders = [Lono.root, ENV['HOME']] files = folders.map { |f| "#{f}/.lono/registration.yml" } @found = files.find do |path| File.exist?(path) end return unless @found content = RenderMePretty.result(@found, context: self) if [:debug] puts "Debug mode enabled. Here's the lono registration info being used:" puts content puts end YAML.load(content) end |