Class: Buildr::Unzip::FromPath

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(unzip, path) ⇒ FromPath

Returns a new instance of FromPath.



235
236
237
238
239
240
241
242
# File 'lib/buildr/packaging/ziptask.rb', line 235

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



252
253
254
255
256
# File 'lib/buildr/packaging/ziptask.rb', line 252

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

#include(*files) ⇒ Object

See UnzipTask#include



245
246
247
248
249
# File 'lib/buildr/packaging/ziptask.rb', line 245

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

#map(entries) ⇒ Object



258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/buildr/packaging/ziptask.rb', line 258

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.



274
275
276
# File 'lib/buildr/packaging/ziptask.rb', line 274

def root
  @unzip
end

#targetObject

The target directory to extract to.



279
280
281
# File 'lib/buildr/packaging/ziptask.rb', line 279

def target
  @unzip.target
end