Sha256: 054da3c55637203e2b3c2cff1075b4f6a1c936a2819eb1668348c6eebb08399d

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

require 'pty'
require 'fanforce/cli'

module Fanforce::AppFactory::CLI::Utils
  extend self
  def self.included(base) base.extend(self) end

  include Fanforce::CLI::Utils

  @@config = nil

  def console_command(command, print_now=true)
    output = []
    PTY.spawn(command) do |stdin, stdout, pid|
      stdin.each { |line| output << line; print line if print_now }
    end
    output.join("\n")
  end

  def config
    return @@config if @@config
    require 'yaml'
    if Fanforce::CLI::TYPE == :directory_of_apps
      config_path = "#{Fanforce::CLI::DIR}/.fanforce-app-factory"
      config_filename = '.fanforce-app-factory'
    elsif Fanforce::CLI::TYPE == :single_app
      config_path = "#{Fanforce::CLI::DIR}/../.fanforce-app-factory"
      config_filename = '../.fanforce-app-factory'
    end
    error "The required config file was not found: #{config_filename}" if !File.exists?(config_path)
    @@config = format_config(YAML.load_file(config_path))
  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

11 entries across 11 versions & 1 rubygems

Version Path
fanforce-app-factory-2.0.0.rc17 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc16 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc15 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc14 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc13 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc12 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc11 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc10 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc9 lib/fanforce/app_factory/cli/lib/utils.rb
fanforce-app-factory-2.0.0.rc8 lib/fanforce/app_factory/cli/utils.rb
fanforce-app-factory-2.0.0.rc7 lib/fanforce/app_factory/cli/utils.rb