Sha256: 7b16f9daf9035b6f0bf5cf91a68651f6fd500eaae1b35efdf7d3e0a4be4a5512
Contents?: true
Size: 1.29 KB
Versions: 4
Compression:
Stored size: 1.29 KB
Contents
# lib/aia/directives.rb require 'hashie' class AIA::Directives def initialize( prompt: ) @prompt = prompt # PromptManager::Prompt instance AIA.config.directives = @prompt.directives end def execute_my_directives return if AIA.config.directives.nil? || AIA.config.directives.empty? not_mine = [] AIA.config.directives.each do |entry| directive = entry[0].to_sym parameters = entry[1] if respond_to? directive send(directive, parameters) else not_mine << entry end end AIA.config.directives = not_mine end def box(what) f = what[0] bar = "#{f}"*what.size puts "#{bar}\n#{what}\n#{bar}" end # Allows a prompt to change its configuration environment def config(what) parts = what.split(' ') item = parts.shift parts.shift if %w[:= =].include? parts[0] if '<<' == parts[0] parts.shift value = parts.join if AIA.config(item).is_a?(Array) AIA.config[item] << value else AIA.config[item] = [ value ] end else value = parts.join if item.end_with?('?') AIA.config[item] = %w[1 y yea yes t true].include?(value.downcase) else AIA.config[item] = "STDOUT" == value ? STDOUT : value end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
aia-0.5.3 | lib/aia/directives.rb |
aia-0.5.2 | lib/aia/directives.rb |
aia-0.5.1 | lib/aia/directives.rb |
aia-0.5.0 | lib/aia/directives.rb |