Class: FPM::Fry::Source::Dir

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/fry/source/dir.rb

Defined Under Namespace

Classes: Cache

Constant Summary collapse

REGEX =
%r!\A(?:file:|/|\.)!

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Dir

Returns a new instance of Dir.



46
47
48
49
50
51
52
53
# File 'lib/fpm/fry/source/dir.rb', line 46

def initialize( url, options = {} )
  @url = URI(url)
  if @url.relative?
    @url.path = File.expand_path(@url.path)
  end
  @logger = options.fetch(:logger){ Cabin::Channel.get }
  @file_map = options.fetch(:file_map){ {'' => ''} }
end

Instance Attribute Details

#file_mapObject (readonly)

Returns the value of attribute file_map.



44
45
46
# File 'lib/fpm/fry/source/dir.rb', line 44

def file_map
  @file_map
end

#loggerObject (readonly)

Returns the value of attribute logger.



44
45
46
# File 'lib/fpm/fry/source/dir.rb', line 44

def logger
  @logger
end

#urlObject (readonly)

Returns the value of attribute url.



44
45
46
# File 'lib/fpm/fry/source/dir.rb', line 44

def url
  @url
end

Class Method Details

.guess(url) ⇒ Object



13
14
15
# File 'lib/fpm/fry/source/dir.rb', line 13

def self.guess( url )
  Source::guess_regex(REGEX, url)
end

.nameObject



9
10
11
# File 'lib/fpm/fry/source/dir.rb', line 9

def self.name
  :dir
end

Instance Method Details

#build_cache(_) ⇒ Object



55
56
57
# File 'lib/fpm/fry/source/dir.rb', line 55

def build_cache(_)
  Cache.new(self, url.path)
end