Sha256: 9776c00492b620bd767ac4447eb1241f9956f3ee4cb664511506db361b36ebca

Contents?: true

Size: 953 Bytes

Versions: 4

Compression:

Stored size: 953 Bytes

Contents

module Mack
  module Portlet
    class Unpacker < Mack::Utils::RegistryMap
      
      def unpack(key, force = false)
        m = self.registered_items[key.to_sym]
        if m
          m.call((force || false))
        else
          Mack.search_path(key.to_sym, false).each do |path|
            Dir.glob(File.join(path, '**/*')).each do |f|
              f = File.expand_path(f)
              dest = f.gsub(path, Mack::Paths.send(key))
              FileUtils.mkdir_p(File.dirname(dest))
              if File.file?(f)
                cp = File.exists?(dest) ? force : true
                if cp
                  FileUtils.cp(f, f.gsub(path, Mack::Paths.send(key)), :verbose => true) if cp
                else
                  puts "Skipping: #{dest}"
                end
              end
            end
          end
        end
      end
      
      def initial_state
        {}
      end
      
    end # Unpacker
  end # Portlet
end # Mack

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mack-0.8.1 lib/mack/portlets/unpacker.rb
mack-0.8.2 lib/mack/portlets/unpacker.rb
mack-0.8.3 lib/mack/portlets/unpacker.rb
mack-0.8.3.1 lib/mack/portlets/unpacker.rb