Module: JWTear::Helpers::Utils
- Defined in:
- lib/jwtear/helpers/utils.rb
Instance Method Summary collapse
-
#banner ⇒ Object
JWTear’s logo.
-
#check_dependencies(deps = {}) ⇒ Object
check_dependencies check dependencies for plugins and throw a gentle error if not installed.
-
#latest_version ⇒ Object
Check latest version.
-
#read_key(key) ⇒ Object
read key as a string or from file(eg. pub_key.pem).
Instance Method Details
#banner ⇒ Object
JWTear’s logo
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jwtear/helpers/utils.rb', line 56 def %Q{\n 888888 888 888 88888888888 "88b 888 o 888 888 888 888 d8b 888 888 888 888 d888b 888 888 .d88b. 8888b. 888d888 888 888d88888b888 888 d8P Y8b "88b 888P" 888 88888P Y88888 888 88888888 .d888888 888 88P 8888P Y8888 888 Y8b. 888 888 888 888 888P Y888 888 "Y8888 "Y888888 888 .d88P v#{JWTear::VERSION} .d88P" 888P" } end |
#check_dependencies(deps = {}) ⇒ Object
check_dependencies
check dependencies for plugins and throw a gentle error if not installed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/jwtear/helpers/utils.rb', line 35 def check_dependencies(deps={}) return if deps.empty? or deps.nil? missing = [] deps.each do |gem, lib| begin require lib rescue LoadError missing << gem end end ensure unless missing.empty? print_error "Missing dependencies!" print_warning "Please install as follows:" puts "gem install #{missing.join(' ')}" exit! end end |
#latest_version ⇒ Object
Check latest version
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jwtear/helpers/utils.rb', line 6 def latest_version begin current_version = JWTear::VERSION rubygem_api = JSON.parse open("https://rubygems.org/api/v1/versions/jwtear.json").read remote_version = rubygem_api.first["number"] latest = remote_version.eql?(current_version)? true : false latest ? current_version : remote_version rescue Exception => e print_bad " Couldn't check the latest version, please check internet connectivity." exit! end end |
#read_key(key) ⇒ Object
read key as a string or from file(eg. pub_key.pem)
21 22 23 24 25 |
# File 'lib/jwtear/helpers/utils.rb', line 21 def read_key(key) if key File.file?(key)? File.read(key) : key end end |