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.



238
239
240
241
242
243
244
245
# File 'lib/buildr/packaging/ziptask.rb', line 238

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



255
256
257
258
259
# File 'lib/buildr/packaging/ziptask.rb', line 255

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

#include(*files) ⇒ Object

See UnzipTask#include



248
249
250
251
252
# File 'lib/buildr/packaging/ziptask.rb', line 248

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

#map(entries) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/buildr/packaging/ziptask.rb', line 261

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) } &&
         !excludes.any? { |pat| File.fnmatch(pat, short) }
        map[short] = entry
      end
    end
    map
  end
end

#rootObject

Documented in Unzip.



277
278
279
# File 'lib/buildr/packaging/ziptask.rb', line 277

def root
  @unzip
end

#targetObject

The target directory to extract to.



282
283
284
# File 'lib/buildr/packaging/ziptask.rb', line 282

def target
  @unzip.target
end