# encoding: ascii-8bit # Copyright 2014 Ball Aerospace & Technologies Corp. # All Rights Reserved. # # This program is free software; you can modify and/or redistribute it # under the terms of the GNU General Public License # as published by the Free Software Foundation; version 3 with # attribution addendums as found in the LICENSE.txt require 'cosmos' require 'cosmos/config/config_parser' require 'ostruct' require 'bundler' module Cosmos # Reads and interprets the Launcher configuration file class LauncherConfig # Launcher title attr_reader :title # Array for tool font settings [font_name, font_size] attr_reader :tool_font_settings # Array for label font settings [font_name, font_size] attr_reader :label_font_settings # Array of [[item_type, text, shell command, icon filename, variable params], ...] # Where variable params is nil or an array of [[parameter name, parameter value], ...] attr_reader :items # Number of columns per row attr_reader :num_columns # Processes a file and adds in the configuration defined in the file # # @param filename [String] Name of the configuration file to parse def initialize(filename) @title = 'COSMOS Launcher' @tool_font_settings = ['Arial', 12] @label_font_settings = ['Arial', 16] @num_columns = 4 @items = [] if File.exist?(filename.to_s) parse_file(filename) else raise "Launcher configuration file does not exist: #{filename}" end end # def initialize # Create a ConfigParser and parse all the lines in the configuration file # # @param filename [String] Name of the configuration file to parse def parse_file(filename) multitool = nil # Loop over each line of the configuration file parser = ConfigParser.new("http://cosmosrb.com/docs/tools/#launcher-configuration") parser.parse_file(filename) do |keyword, params| # Handle each keyword case keyword when 'AUTO_GEM_TOOLS' parse_gem_tool(parser) when 'TOOL' parse_tool(parser, params, multitool) when 'MULTITOOL_START' parser.verify_num_parameters(1, 2, "MULTITOOL_START