Sha256: 6b8cb7f70d0452b1db45e27160716a6f4525dea9ea71d35bad21047036cfb225
Contents?: true
Size: 1.36 KB
Versions: 17
Compression:
Stored size: 1.36 KB
Contents
require 'pty' require 'fanforce/cli' module Fanforce::PluginFactory::CLI::Utils extend self def self.included(base) base.extend(self) end include Fanforce::CLI::Utils @@config = nil def console_command(command, print_now=false) output = [] PTY.spawn(command) do |stdin, stdout, pid| stdin.each { |line| output << line; print line if print_now } end output.join("\n") end def silence_warnings require 'stringio' old_stderr = $stderr $stderr = StringIO.new yield ensure $stderr = old_stderr end def config_filepath if Fanforce::CLI::TYPE == :directory_of_plugins "#{Fanforce::CLI::DIR}/.fanforce-plugin-factory" elsif Fanforce::CLI::TYPE == :single_plugin "#{Fanforce::CLI::DIR}/../.fanforce-plugin-factory" end end def config_relativepath if Fanforce::CLI::TYPE == :directory_of_plugins '.fanforce-plugin-factory' elsif Fanforce::CLI::TYPE == :single_plugin '../.fanforce-plugin-factory' end end def config return @@config if @@config require 'yaml' error "The required config file was not found: #{config_relativepath}" if !File.exists?(config_filepath) @@config = format_config(YAML.load_file(config_filepath)) end def format_config(hash) hash.values.select{|v| v.is_a? Hash}.each{|h| format_config(h)} hash.symbolize_keys! end end
Version data entries
17 entries across 17 versions & 1 rubygems