class RepoMate::Link
Class containing the main logic
Public Class Methods
new()
click to toggle source
Init
# File lib/repomate/link.rb, line 10 def initialize @repository = Repository.new @metafile = Metafile.new end
Public Instance Methods
cleanup()
click to toggle source
cleans up unused directories
# File lib/repomate/link.rb, line 54 def cleanup action = false @repository.categories.each do |category| next if category.eql?("stage") Architecture.dataset(category).each do |entry| directory = Architecture.new(entry[:architecture], entry[:component], entry[:suitename], category) if directory.is_unused?(entry[:fullpath]) action = true directory.destroy end end Component.dataset(category).each do |entry| directory = Component.new(entry[:component], entry[:suitename], category) if directory.is_unused?(entry[:fullpath]) action = true directory.destroy end end Suite.dataset(category).each do |entry| directory = Suite.new(entry[:suitename], category) if directory.is_unused?(entry[:fullpath]) action = true directory.destroy end end end @metafile.create if action end
create(workload)
click to toggle source
links the workload
# File lib/repomate/link.rb, line 21 def create(workload) workload.each do |entry| @repository.create(entry[:suitename], entry[:component], entry[:architecture]) unless File.exists?(entry[:destination_fullname]) package = Package.new(entry[:source_fullname], entry[:suitename], entry[:component]) package.create_checksums File.symlink(entry[:source_fullname], entry[:destination_fullname]) puts "Package: #{package.newbasename} linked to production => #{entry[:suitename]}/#{entry[:component]}" end end end
destroy(workload)
click to toggle source
unlinks workload
# File lib/repomate/link.rb, line 37 def destroy(workload) workload.each do |entry| package = Package.new(entry[:destination_fullname], entry[:suitename], entry[:component]) package.delete_checksums if File.exists?(entry[:destination_fullname]) File.unlink(entry[:destination_fullname]) puts "Package: #{package.newbasename} unlinked from #{entry[:category]} => #{entry[:suitename]}/#{entry[:component]}" else puts "Package: #{package.newbasename} was not linked" end end cleanup unless workload.empty? end
exist?(fullname)
click to toggle source
Checks if file exists
# File lib/repomate/link.rb, line 16 def exist?(fullname) File.exists?(fullname) end