Class: Source::Base::Factory

Inherits:
Object
  • Object
show all
Includes:
HasOptionMethods
Defined in:
lib/gpm/source.rb

Direct Known Subclasses

Gem::Factory, Maven::Factory, War::Factory

Constant Summary collapse

GLOB_REGEXP =
/(?:\(([^)]+)\))?(.*)/

Instance Attribute Summary collapse

Attributes included from HasOptionMethods

#options

Instance Method Summary collapse

Methods included from HasOptionMethods

included

Constructor Details

#initialize(directory, options = {}) ⇒ Factory

Returns a new instance of Factory.



12
13
14
15
# File 'lib/gpm/source.rb', line 12

def initialize(directory, options = {})
  @directory = directory
  @options = options
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



10
11
12
# File 'lib/gpm/source.rb', line 10

def directory
  @directory
end

Instance Method Details

#createObject



16
17
18
# File 'lib/gpm/source.rb', line 16

def create
  raise "Cannot instantiate source type base."
end

#files_providerObject



19
20
21
# File 'lib/gpm/source.rb', line 19

def files_provider
  Source::CompositeFilesProvider.new(*files_providers)
end

#files_providersObject



23
24
25
26
27
28
29
30
31
# File 'lib/gpm/source.rb', line 23

def files_providers
  base_providers = [Source::FilesFromDirectoryProvider.create_from_directory(File.join(directory, '_package_'), directory)]
  include_files.each do |include_files_entry|
    directory, glob = include_files_entry.match(GLOB_REGEXP).to_a[1..-1]
    directory = File.expand_path(directory || "", self.directory)
    base_providers << Source::FilesFromDirectoryProvider.create_from_glob(directory ,glob)
  end
  base_providers
end