Class: Raxe::Installer
- Inherits:
-
Object
- Object
- Raxe::Installer
- Defined in:
- lib/raxe/installer.rb
Class Method Summary collapse
-
.get_haxe ⇒ Object
initialize.
-
.kill_conf_file ⇒ Object
self.install.
-
.make_conf_file ⇒ Object
self.kill_conf_file.
-
.make_content ⇒ Object
kill_content.
Instance Method Summary collapse
-
#initialize(raxe) ⇒ Installer
constructor
A new instance of Installer.
-
#install(install_data) ⇒ Object
check_haxe.
-
#kill_content ⇒ Object
self.raxe_conf.
Constructor Details
#initialize(raxe) ⇒ Installer
Returns a new instance of Installer.
7 8 9 |
# File 'lib/raxe/installer.rb', line 7 def initialize( raxe ) @raxe = raxe end |
Class Method Details
.get_haxe ⇒ Object
initialize
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/raxe/installer.rb', line 11 def self.get_haxe # TODO: figure out a better way of doing this... seriously... # FIXME: Actually test this method lol begin puts " Let's see if you have haxe installed..." sh "which haxe" puts " Great! It looks like haXe has already been installed." rescue puts " Grabbing the tar ball from haxe.org..." sh "wget http://haxe.org/file/hxinst-linux.tgz" puts " Extracting the tar ball..." sh "tar -xvf hxinst-linux.tgz" puts " Changing permission to run the installer executable" sh "chmod 755 hxinst-linux" puts " Running the executable" sh "./hxinst-linux" puts " Cleaning up" sh "rm hxinst-linux" sh "rm hxinst-linux.tgz" puts " Finished installing haxe" end # begin-rescue end |
.kill_conf_file ⇒ Object
self.install
46 47 48 49 |
# File 'lib/raxe/installer.rb', line 46 def self.kill_conf_file filename = File.join( Dir.pwd, ".raxeconf" ) File.delete( filename ) if FileTest.exists? filename end |
.make_conf_file ⇒ Object
self.kill_conf_file
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/raxe/installer.rb', line 51 def self.make_conf_file configurations = { "root" => "raxe" , "output" => "raxe/out" , "source" => "raxe/src", "tests" => "raxe/tests" } # configuration File.open( File.join( Dir.pwd, ".raxeconf" ), "w+" ) do |f| configurations.each do |key, val| f.puts key + "!!!" + val end # configurations.each end # File.open end |
.make_content ⇒ Object
kill_content
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/raxe/installer.rb', line 85 def self.make_content root_dir = "raxe" unless FileTest.exists? root_dir Dir.mkdir root_dir puts " Created directory " + root_dir else puts " Directory " + root_dir + " already exists. Skiping to next step." end # exists [ "src", "out", "tests" ].each do |f| folder = File.join( root_dir , f ) unless FileTest.exists? folder Dir.mkdir folder puts " Created directory " + folder else puts " Directory " + folder + " already exists. Skipping to next step." end # exists end # each File.open( File.join( root_dir, "build.hxml" ), "w+" ) do |f| f.puts "# haXe output instructions go here. Uncommented whatever you need" f.puts "# -js out/raxe.js" f.puts "# -main raxetest.RaxeFire" end # File.open puts " Wrote build.hxml" puts " Done!" end |
Instance Method Details
#install(install_data) ⇒ Object
check_haxe
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/raxe/installer.rb', line 34 def install( install_data ) case install_data[:req] when :install Installer.make_conf_file Installer.make_content when :uninstall Installer.kill_conf_file kill_content end # case req install_data[:callback].call end |
#kill_content ⇒ Object
self.raxe_conf
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/raxe/installer.rb', line 65 def kill_content kill_recursively = lambda do |dir| begin Dir.delete( dir ) unless Dir.entries( dir ).length > 2 rescue dir.foreach do |item| File.delete( item ) if File.file? item kill_recursively.call( item ) if Dir.directory? item && item != "." && item != ".." end # dir.foreach end # begin-rescue end # kill_recursively @raxe.paths.each do |type, location| next if type == "root" kill_recursively.call( location ) end # @raxe.paths File.delete( File.join( @raxe.paths['root'], "build.hxml" ) ) if FileTest.exists? File.join( @raxe.paths['root'], "build.hxml" ) puts " Deleted build.hxml" Dir.delete( @raxe.paths["root"] ) if Dir.entries( @raxe.paths["root"] ).length < 3 end |