Class: GameMachine::Console::Install
- Inherits:
-
Object
- Object
- GameMachine::Console::Install
- Defined in:
- lib/game_machine/console/install.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#install_path ⇒ Object
readonly
Returns the value of attribute install_path.
-
#install_source_path ⇒ Object
readonly
Returns the value of attribute install_source_path.
Instance Method Summary collapse
- #bin_source ⇒ Object
- #config_source ⇒ Object
- #error(reason = '') ⇒ Object
- #games_source ⇒ Object
- #gemfile_source ⇒ Object
- #gemlockfile_source ⇒ Object
-
#initialize(command, argv, install_source_path) ⇒ Install
constructor
A new instance of Install.
- #install ⇒ Object
- #java_project_source ⇒ Object
- #java_source ⇒ Object
- #lib_source ⇒ Object
- #mono_source ⇒ Object
- #run! ⇒ Object
- #upgrade ⇒ Object
- #web_source ⇒ Object
Constructor Details
#initialize(command, argv, install_source_path) ⇒ Install
Returns a new instance of Install.
6 7 8 9 10 11 12 |
# File 'lib/game_machine/console/install.rb', line 6 def initialize(command,argv,install_source_path) @command = command @install_path = argv.shift @install_source_path = install_source_path puts "Installing from #{install_source_path}" end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/game_machine/console/install.rb', line 5 def command @command end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
5 6 7 |
# File 'lib/game_machine/console/install.rb', line 5 def help @help end |
#install_path ⇒ Object (readonly)
Returns the value of attribute install_path.
5 6 7 |
# File 'lib/game_machine/console/install.rb', line 5 def install_path @install_path end |
#install_source_path ⇒ Object (readonly)
Returns the value of attribute install_source_path.
5 6 7 |
# File 'lib/game_machine/console/install.rb', line 5 def install_source_path @install_source_path end |
Instance Method Details
#bin_source ⇒ Object
100 101 102 |
# File 'lib/game_machine/console/install.rb', line 100 def bin_source File.join(install_source_path,'bin') end |
#config_source ⇒ Object
108 109 110 |
# File 'lib/game_machine/console/install.rb', line 108 def config_source File.join(install_source_path,'config') end |
#error(reason = '') ⇒ Object
14 15 16 |
# File 'lib/game_machine/console/install.rb', line 14 def error(reason='') puts "Invalid install path #{install_path} (#{reason})" end |
#games_source ⇒ Object
112 113 114 |
# File 'lib/game_machine/console/install.rb', line 112 def games_source File.join(install_source_path,'games') end |
#gemfile_source ⇒ Object
84 85 86 |
# File 'lib/game_machine/console/install.rb', line 84 def gemfile_source File.join(install_source_path,'Gemfile') end |
#gemlockfile_source ⇒ Object
88 89 90 |
# File 'lib/game_machine/console/install.rb', line 88 def gemlockfile_source File.join(install_source_path,'Gemfile.lock') end |
#install ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/game_machine/console/install.rb', line 38 def install puts "Installing into #{install_path}" path = File.(install_path) FileUtils.mkdir(path) FileUtils.cp_r(config_source,path) FileUtils.cp_r(games_source,path) FileUtils.cp_r(java_source,path) FileUtils.cp_r(mono_source,path) FileUtils.cp_r(web_source,path) FileUtils.cp_r(lib_source,path) FileUtils.cp_r(bin_source,path) FileUtils.cp(gemfile_source,path) FileUtils.cp(gemlockfile_source,path) end |
#java_project_source ⇒ Object
116 117 118 |
# File 'lib/game_machine/console/install.rb', line 116 def java_project_source File.join(install_source_path,'java','project') end |
#java_source ⇒ Object
120 121 122 |
# File 'lib/game_machine/console/install.rb', line 120 def java_source File.join(install_source_path,'java') end |
#lib_source ⇒ Object
96 97 98 |
# File 'lib/game_machine/console/install.rb', line 96 def lib_source File.join(install_source_path,'lib') end |
#mono_source ⇒ Object
104 105 106 |
# File 'lib/game_machine/console/install.rb', line 104 def mono_source File.join(install_source_path,'mono') end |
#run! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/game_machine/console/install.rb', line 18 def run! if install_path.nil? || install_path.empty? error("Invalid input") return end if command == 'install' && File.exists?(install_path) error("Directory exists") return end if command == 'upgrade' && !File.exists?(install_path) error("Installation not found") return end @install_path = File.(install_path) send(command.to_sym) end |
#upgrade ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/game_machine/console/install.rb', line 55 def upgrade puts "Upgrading installation at #{install_path}" path = File.(install_path) puts "Upgrading mono" FileUtils.rm_rf(File.join(path,'mono')) FileUtils.cp_r(mono_source,path) puts 'Upgrading java' FileUtils.rm_rf(File.join(path,'java','project')) FileUtils.cp_r(java_project_source, File.join(path,'java','project')) puts 'Upgrading Gemfile' FileUtils.rm_rf(File.join(path,'Gemfile')) FileUtils.cp(gemfile_source,path) FileUtils.rm_rf(File.join(path,'Gemfile.lock')) FileUtils.cp(gemlockfile_source,path) puts 'Upgrading lib' FileUtils.rm_rf(File.join(path,'lib')) FileUtils.cp_r(lib_source,path) puts 'Upgrading bin' FileUtils.rm_rf(File.join(path,'bin')) FileUtils.cp_r(bin_source,path) end |
#web_source ⇒ Object
92 93 94 |
# File 'lib/game_machine/console/install.rb', line 92 def web_source File.join(install_source_path,'web') end |