Module: CultomePlayer::Environment

Included in:
CultomePlayer
Defined in:
lib/cultome_player/environment.rb

Instance Method Summary collapse

Instance Method Details

#command_pipeString

Get the command_pipe environment configuration value.

Returns:

  • (String)

    The command_pipe value for teh selected environment.



44
45
46
# File 'lib/cultome_player/environment.rb', line 44

def command_pipe
  env_config['command_pipe'] || raise('environment problem:environment information not loaded')
end

#config_fileString

Get the config_file environment configuration value.

Returns:

  • (String)

    The config_file value for teh selected environment.



37
38
39
# File 'lib/cultome_player/environment.rb', line 37

def config_file
  env_config['config_file'] || raise('environment problem:environment information not loaded')
end

#current_envSymbol

Get the current environment name.

Returns:

  • (Symbol)

    The current environment name.



79
80
81
# File 'lib/cultome_player/environment.rb', line 79

def current_env
  @current_env
end

#db_adapterString

Get the db_adapter environment configuration value.

Returns:

  • (String)

    The db_adapter value for teh selected environment.



9
10
11
# File 'lib/cultome_player/environment.rb', line 9

def db_adapter
  env_config['db_adapter'] || raise('environment problem:environment information not loaded')
end

#db_fileString

Get the db_file environment configuration value.

Returns:

  • (String)

    The db_file value for teh selected environment.



16
17
18
# File 'lib/cultome_player/environment.rb', line 16

def db_file
  env_config['db_file'] || raise('environment problem:environment information not loaded')
end

#db_log_fileString

Get the db_log_file environment configuration value.

Returns:

  • (String)

    The db_log_file value for teh selected environment.



23
24
25
# 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

#env_configHash

Gets the environment configurations.

Returns:

  • (Hash)

    Environment configuration.



72
73
74
# File 'lib/cultome_player/environment.rb', line 72

def env_config
  @env_config ||= {}
end

#file_typesString

Get the file_types environment configuration value.

Returns:

  • (String)

    The file_types value for teh selected environment.



30
31
32
# File 'lib/cultome_player/environment.rb', line 30

def file_types
  env_config['file_types'] || raise('environment problem:environment information not loaded')
end

#load_environment_properties(env) ⇒ Object



83
84
85
86
87
88
89
# 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

#mplayer_pipeString

Get the mplayer_pipe environment configuration value.

Returns:

  • (String)

    The mplayer_pipe value for teh selected environment.



51
52
53
# File 'lib/cultome_player/environment.rb', line 51

def mplayer_pipe
  env_config['mplayer_pipe'] || raise('environment problem:environment information not loaded')
end

#player_configHash

Gets the player configurations.

Returns:

  • (Hash)

    Player configuration.



65
66
67
# File 'lib/cultome_player/environment.rb', line 65

def player_config
  @player_config ||= {}
end

#prepare_environment(env) ⇒ Object

Extract the configuration for the environment and setup valriables.

Parameters:

  • env (Symbol)

    The name of the environment to load.

  • check_db (Boolean)

    Flag to decide if the database schema should be checked.



95
96
97
98
99
100
# 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

#save_player_configurationsObject



102
103
104
# File 'lib/cultome_player/environment.rb', line 102

def save_player_configurations
  open(config_file, 'w'){|f| f.write player_config.to_yaml }
end

#stdoutIO

Get the stdout (not STDOUT) for the player.

Returns:

  • (IO)

    The stdout for the player.



58
59
60
# File 'lib/cultome_player/environment.rb', line 58

def stdout
  STDOUT
end