Class: GamesAndRpgParadise::InstallBaldursGate

Inherits:
Base
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/games/baldurs_gate/install_baldurs_gate.rb

Overview

GamesAndRpgParadise::InstallBaldursGate

Constant Summary

Constants included from Base::Extensions::Colours

Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base::Extensions::Colours

ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow

Methods included from Base::Extensions::CommandlineArguments

#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Constructor Details

#initialize(commandline_arguments = nil, run_already = true) ⇒ InstallBaldursGate

#

initialize

#


26
27
28
29
30
31
32
33
34
35
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/install_baldurs_gate.rb', line 26

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

GamesAndRpgParadise::InstallBaldursGate[]

#


103
104
105
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/install_baldurs_gate.rb', line 103

def self.[](i = ARGV)
  new(i)
end

Instance Method Details

#install_the_entries_from_this_yaml_file(i) ⇒ Object

#

install_the_entries_from_this_yaml_file

#


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/install_baldurs_gate.rb', line 60

def install_the_entries_from_this_yaml_file(i)
  if i and File.file?(i)
    # ===================================================================== #
    # Load up the files that are to be installed next:
    # ===================================================================== #
    dataset = YAML.load_file(i)
    starting_directory = return_pwd
    # ===================================================================== #
    # Process all registered entries next:
    # ===================================================================== #
    dataset.each {|this_entry|
      e rev+'Now trying to install '+steelblue(this_entry)+
        rev+'.'
      appropriate_target = Dir['*'+this_entry+'*'].first
      # =================================================================== #
      # This should be improved.
      # =================================================================== #
      e steelblue('The appropriate target was: '+appropriate_target)
      if File.directory?(appropriate_target)
        cd(appropriate_target) # Enter the directory in this case.
        # ================================================================= #
        # Find all .exe files there:
        # ================================================================= #
        appropriate_target = Dir['*.exe'].first
      end
      case appropriate_target
      # =================================================================== #
      # Is an .exe file.
      # =================================================================== #
      when /\.exe$/i
        esystem(appropriate_target)
      else
        e 'UNHANDLED SITUATION.'
        exit
      end
      cd(starting_directory) # And go back again.
    }
  end
end

#resetObject

#

reset (reset tag)

#


40
41
42
43
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/install_baldurs_gate.rb', line 40

def reset
  super()
  infer_the_namespace
end

#runObject

#

run (run tag)

#


48
49
50
51
52
53
54
55
# File 'lib/games_and_rpg_paradise/games/baldurs_gate/install_baldurs_gate.rb', line 48

def run
  _ = project_yaml_directory?+'games/baldurs_gate_2/mod_installation_order.yml'
  if File.exist? _
    install_the_entries_from_this_yaml_file(_)
  else
    opnn; no_file_exists_at(_)
  end
end