Class: Bonethug::Installer
- Inherits:
-
Object
- Object
- Bonethug::Installer
- Includes:
- Digest, FileUtils
- Defined in:
- lib/bonethug/installer.rb
Constant Summary collapse
- @@bonthug_gem_dir =
File.(File.dirname(__FILE__)) + '/../..'
- @@skel_dir =
@@bonthug_gem_dir + '/skel'
- @@conf =
Conf.new.add(@@skel_dir + '/skel.yml')
- @@project_config_files =
{editable: ['cnf.yml','schedule.rb'], generated: ['backup.rb','deploy.rb']}
Class Method Summary collapse
Class Method Details
.clean(target) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/bonethug/installer.rb', line 99 def self.clean(target) manifest_path = target + '/.bonethug/manifest' if File.exists? manifest_path puts 'Reading manifest...' manifest = File.read(manifest_path).split("\n") puts 'Cleaning up ' + manifest.count.to_s + ' files' not_removed = [] manifest.each do |file| not_removed.push file unless self.try_delete file end if not_removed.count > 0 puts 'Retrying removal of ' + not_removed.count.to_s + ' files' failed = [] not_removed.each do |file| failed.push file unless self.try_delete file end puts 'Removal of the following' + failed.count.to_s + ' files failed' puts failed.join("\n") end else puts 'Nothing to do' end self end |
.install(type, target = '.') ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/bonethug/installer.rb', line 29 def self.install(type, target = '.') # @@conf = Conf.new.add(@@skel_dir + '/skel.yml') # create full path target = File. target # let the user know we are installing puts 'Installing '+ type + ' to ' + target + '...' # load the configuration unless @@conf.get('project_types').has_key? type.to_s puts "Unsupported type: " + type.to_s exit end conf = @@conf.node_merge 'base', 'project_types.' + type # set the tmp dir tmp_dir = File. target + '/.bonethug-tmp' # clean up any exisitng install tmp files if File.directory? tmp_dir puts 'Cleaning up old installer temporary files...' FileUtils.rm_rf tmp_dir end # create tmp dir puts 'Creating build directory at ' + tmp_dir FileUtils.mkdir tmp_dir FileUtils.mkdir tmp_dir + '/.bonethug' # build the file set puts 'Building ' + type + ' skeleton...' FileUtils.cp_r @@skel_dir + '/base/.', tmp_dir FileUtils.cp_r @@skel_dir + '/project_types/' + type + '/.', tmp_dir # build the manifest puts 'Creating manifest...' self.build_manifest tmp_dir # modify the manifest root manifest_path = tmp_dir + '/.bonethug/manifest' File.open(manifest_path,'w') do |file| file.puts File.read(manifest_path).gsub(/\.bonethug-tmp/,'') end # clean up the target dir puts 'Cleaning up install directory...' self.clean target # copy the files puts 'Installing build to ' + target + '...' FileUtils.cp_r tmp_dir + '/.', target # try to update the configuration files puts 'Updating build informtation...' self.(target) # clean up any exisitng install tmp files puts 'Cleaning up temporary files...' FileUtils.rm_rf tmp_dir puts "Installation Complete" # try to update the configuration files puts 'Updating configs...' self.bonethugise(target, :init) end |