Class: Lono::Registration::Temp
- Inherits:
-
Base
- Object
- Base
- Lono::Registration::Temp
show all
- Defined in:
- lib/lono/registration/temp.rb
Instance Method Summary
collapse
Methods inherited from Base
#api, #get_temp_key, #initialize, #request_verification, #say, #with_safety
Instance Method Details
#check ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/lono/registration/temp.rb', line 4
def check
info = read_registration
if info
resp = request_verification(info)
puts "request_verification resp #{resp.inspect}" if ENV['LONO_DEBUG_REGISTRATION']
return true if resp.nil?
end
prompt unless resp && resp[:valid]
true
end
|
#prompt ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/lono/registration/temp.rb', line 21
def prompt
return if ENV['LONO_TEST']
puts <<~EOL
Looks like lono is not registered. Lono registration is optional and free.
If you like lono though, please register to help support it. You can register at:
https://register.lono.cloud
This prompt appears every 24 hours when lono is not registered. Registration removes
this message. Registered users can also optionally receive updates and special offers,
including discounts to BoltOps Pro:
https://lono.cloud/docs/boltops-pro/
EOL
resp = get_temp_key
save_temp_key(resp) unless resp.nil? end
|
#read_registration ⇒ Object
17
18
19
|
# File 'lib/lono/registration/temp.rb', line 17
def read_registration
YAML.load_file(temp_path) if File.exist?(temp_path)
end
|
#save_temp_key(info) ⇒ Object
44
45
46
47
|
# File 'lib/lono/registration/temp.rb', line 44
def save_temp_key(info)
FileUtils.mkdir_p(File.dirname(temp_path))
IO.write(temp_path, YAML.dump(info.deep_stringify_keys))
end
|
#temp_path ⇒ Object
49
50
51
|
# File 'lib/lono/registration/temp.rb', line 49
def temp_path
"#{ENV['HOME']}/.lono/temp.yml"
end
|