module CultomePlayer::Environment
Public Instance Methods
Get the command_pipe
environment configuration value.
@return [String] The command_pipe
value for teh selected environment.
# File lib/cultome_player/environment.rb, line 44 def command_pipe env_config['command_pipe'] || raise('environment problem:environment information not loaded') end
Get the config_file
environment configuration value.
@return [String] The config_file
value for teh selected environment.
# File lib/cultome_player/environment.rb, line 37 def config_file env_config['config_file'] || raise('environment problem:environment information not loaded') end
Get the current environment name.
@return [Symbol] The current environment name.
# File lib/cultome_player/environment.rb, line 79 def current_env @current_env end
Get the db_adapter
environment configuration value.
@return [String] The db_adapter
value for teh selected environment.
# File lib/cultome_player/environment.rb, line 9 def db_adapter env_config['db_adapter'] || raise('environment problem:environment information not loaded') end
Get the db_log_file
environment configuration value.
@return [String] The db_log_file
value for teh selected environment.
# File lib/cultome_player/environment.rb, line 23 def db_log_file env_config['db_log_file'] || raise('environment problem:environment information not loaded') end
Gets the environment configurations.
@return [Hash] Environment
configuration.
# File lib/cultome_player/environment.rb, line 72 def env_config @env_config ||= {} end
Get the file_types
environment configuration value.
@return [String] The file_types
value for teh selected environment.
# File lib/cultome_player/environment.rb, line 30 def file_types env_config['file_types'] || raise('environment problem:environment information not loaded') end
# File lib/cultome_player/environment.rb, line 83 def load_environment_properties(env) env_config = YAML.load_file File.expand_path('config/environment.yml', File.join(File.dirname(__FILE__), "../..")) @env_config = env_config[env.to_s] expand_paths @env_config @current_env = env.to_sym return @env_config end
Get the mplayer_pipe
environment configuration value.
@return [String] The mplayer_pipe
value for teh selected environment.
# File lib/cultome_player/environment.rb, line 51 def mplayer_pipe env_config['mplayer_pipe'] || raise('environment problem:environment information not loaded') end
Gets the player configurations.
@return [Hash] Player
configuration.
# File lib/cultome_player/environment.rb, line 65 def player_config @player_config ||= {} end
Extract the configuration for the environment and setup valriables.
@param env [Symbol] The name of the environment to load. @param check_db [Boolean] Flag to decide if the database schema should be checked.
# File lib/cultome_player/environment.rb, line 95 def prepare_environment(env) load_environment_properties(env) raise 'environment problem:environment not found' if @env_config.nil? create_required_files @env_config load_master_config @env_config['config_file'] end
# File lib/cultome_player/environment.rb, line 102 def save_player_configurations open(config_file, 'w'){|f| f.write player_config.to_yaml } end
Get the stdout (not STDOUT) for the player.
@return [IO] The stdout for the player.
# File lib/cultome_player/environment.rb, line 58 def stdout STDOUT end
Private Instance Methods
# File lib/cultome_player/environment.rb, line 113 def create_required_files(env_config) env_config.each do |k,v| if k.end_with?('_file') unless File.exist?(v) %x[mkdir -p '#{File.dirname(v)}' && touch '#{v}'] raise 'environment problem:cannot create required files' unless $?.success? end elsif k.end_with?('_pipe') unless File.exist?(v) %x[mkfifo '#{v}'] raise 'environment problem:cannot create required pipe' unless $?.success? end end end end
# File lib/cultome_player/environment.rb, line 129 def expand_paths(env_config) env_config.each do |k,v| if k.end_with?('_file') || k.end_with?('_pipe') env_config[k] = File.expand_path(v) end end end
# File lib/cultome_player/environment.rb, line 108 def load_master_config(config_file) @player_config = YAML.load_file(config_file) || {} @player_config['main'] ||= {} end