lib/gloo/verbs/run.rb in gloo-0.6.1 vs lib/gloo/verbs/run.rb in gloo-0.7.0
- old
+ new
@@ -10,40 +10,29 @@
class Run < Gloo::Core::Verb
KEYWORD = 'run'.freeze
KEYWORD_SHORT = 'r'.freeze
EVALUATE_RUN = '~>'.freeze
+ MISSING_EXPR_ERR = 'Missing Expression!'.freeze
#
# Run the verb.
#
def run
+ if @tokens.token_count < 2
+ $engine.err MISSING_EXPR_ERR
+ return
+ end
+
if @tokens.second == EVALUATE_RUN
run_expression
else
run_script
end
end
#
- # Run a script specified by pathname
- #
- def run_script
- Gloo::Exec::Runner.run @tokens.second
- end
-
- #
- # Evaluate an expression and run that.
- #
- def run_expression
- return unless @tokens.token_count > 2
-
- expr = Gloo::Expr::Expression.new( @tokens.params[ 1..-1 ] )
- $engine.parser.run expr.evaluate
- end
-
- #
# Get the Verb's keyword.
#
def self.keyword
return KEYWORD
end
@@ -54,37 +43,32 @@
def self.keyword_shortcut
return KEYWORD_SHORT
end
# ---------------------------------------------------------------------
- # Help
+ # Private functions
# ---------------------------------------------------------------------
+ private
+
#
- # Get help for this verb.
+ # Run a script specified by pathname
#
- def self.help
- return <<~TEXT
- RUN VERB
- NAME: run
- SHORTCUT: r
+ def run_script
+ Gloo::Exec::Runner.run @tokens.second
+ end
- DESCRIPTION
- Run a script or other object.
- This is the same as sending a 'run' message to the object.
+ #
+ # Evaluate an expression and run that.
+ #
+ def run_expression
+ unless @tokens.token_count > 2
+ $engine.err MISSING_EXPR_ERR
+ return
+ end
- SYNTAX
- run <path.to.object>
-
- PARAMETERS
- path.to.object - Reference to the object which will be run.
-
- RESULT
- The result depends on the object that is run.
-
- ERRORS
- The errors depend on the object that is run.
- TEXT
+ expr = Gloo::Expr::Expression.new( @tokens.params[ 1..-1 ] )
+ $engine.parser.run expr.evaluate
end
end
end
end