Sha256: b3a55941761323150cea7b0adf5be32c234e942bd3e60a26b660cfe28449f1e7
Contents?: true
Size: 1.73 KB
Versions: 19
Compression:
Stored size: 1.73 KB
Contents
# Author:: Eric Crane (mailto:eric.crane@mac.com) # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved. # # Show a system notification. # module Gloo module Verbs class Alert < GlooLang::Core::Verb KEYWORD = 'alert'.freeze KEYWORD_SHORT = '!'.freeze MISSING_EXPR_ERR = 'Missing Expression!'.freeze NO_RESULT_ERR = 'Expression evaluated with no result!'.freeze # # Run the verb. # def run unless @tokens.token_count > 1 @engine.err MISSING_EXPR_ERR return end expr = GlooLang::Expr::Expression.new( @engine, @tokens.params ) result = expr.evaluate if result @engine.heap.it.set_to result post_alert result else @engine.err NO_RESULT_ERR end end # # Get the Verb's keyword. # def self.keyword return KEYWORD end # # Get the Verb's keyword shortcut. # def self.keyword_shortcut return KEYWORD_SHORT end # --------------------------------------------------------------------- # Private functions # --------------------------------------------------------------------- private # # Post the alert for the specific platform. # Notice is not posted if we're in quiet mode. # def post_alert( msg ) @engine.log.info msg return if @engine.args.quiet? post_osx msg end # # Post the alert on the Mac OSX. # def post_osx( msg ) cmd1 = '/usr/bin/osascript -e "display notification \"' cmd2 = '\" with title \"Gloo\" "' system( cmd1 + msg.to_s + cmd2 ) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems