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 36 37 38 39 40 |
# 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 and ~/.lono/registration.yml file does not exist." return false end unless info[:content].is_a?(Hash) say "Lono is not registered." say "#{info[:path]} does not have the right structure" return false end @resp = request_verification(info[:content]) # 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 @options[: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 #{info[:path]}" say @resp[:message] end false end |
#read_registration ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/lono/registration/user.rb', line 42 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 @options[:debug] puts "Debug mode enabled. Here's the lono registration info being used:" puts "Using: #{found}" puts content puts end {path: found, content: YAML.load(content)} end |