Sha256: bcb2b426e63167f2e2f8900e7c42348faf324842f762fc6c6ec44f76282ca0de
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module Mayl # Public: The class responsible for reading user input, interpreting it and # executing associated commands. class Repl attr_reader :parser # Public: Initializes a new REPL from a given path. # # path - The path to get the locales from (defaults to 'config/locales'). def initialize(path) path ||= 'config/locales' @env = Env.new(path) @parser = Parser.new(@env) end # Public: Fires up the REPL that parses and executes given commands. # # Returns nothing. def start locales = @env.locales.map(&:name) prompt = "> " puts "Detected locales: #{locales.join(', ')}" while (print prompt; input = $stdin.gets) begin value = @parser.parse(input.chomp).execute @env.last_value = value @env.commit prompt = [@env.namespace, '> '].reject(&:empty?).join ' ' rescue => e print "Error: #{e.message}" ensure print "\n" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mayl-0.1.0 | lib/mayl/repl.rb |