Class: Buildr::Unzip::FromPath

Inherits:
Object
  • Object
show all
Defined in:
lib/buildr/packaging/zip.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(unzip, path) ⇒ FromPath

Returns a new instance of FromPath.



630
631
632
633
634
635
636
637
# File 'lib/buildr/packaging/zip.rb', line 630

def initialize(unzip, path)
  @unzip = unzip
  if path
    @path = path[-1] == ?/ ? path : path + '/'
  else
    @path = ''
  end
end

Instance Method Details

#exclude(*files) ⇒ Object

See UnzipTask#exclude



647
648
649
650
651
# File 'lib/buildr/packaging/zip.rb', line 647

def exclude(*files) #:doc:
  @exclude ||= []
  @exclude |= files
  self
end

#include(*files) ⇒ Object

See UnzipTask#include



640
641
642
643
644
# File 'lib/buildr/packaging/zip.rb', line 640

def include(*files) #:doc:
  @include ||= []
  @include |= files
  self
end

#map(entries) ⇒ Object



653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/buildr/packaging/zip.rb', line 653

def map(entries)
  includes = @include || ['**/*']
  excludes = @exclude || []
  entries.inject({}) do |map, entry|
    if entry.name =~ /^#{@path}/
      short = entry.name.sub(@path, '')
      if includes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) } &&
         !excludes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) }
        map[short] = entry
      end
    end
    map
  end
end

#rootObject

Documented in Unzip.



669
670
671
# File 'lib/buildr/packaging/zip.rb', line 669

def root()
  @unzip
end

#targetObject

The target directory to extract to.



674
675
676
# File 'lib/buildr/packaging/zip.rb', line 674

def target()
  @unzip.target
end