Class: Source::Gem::Factory

Inherits:
Base::Factory show all
Defined in:
lib/gpm/source/gem.rb

Direct Known Subclasses

Bundler::Factory

Constant Summary

Constants inherited from Base::Factory

Base::Factory::GLOB_REGEXP

Instance Attribute Summary collapse

Attributes inherited from Base::Factory

#directory

Instance Method Summary collapse

Methods inherited from Base::Factory

#files_provider

Methods included from HasOptionMethods

included

Constructor Details

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

Returns a new instance of Factory.



57
58
59
60
# File 'lib/gpm/source/gem.rb', line 57

def initialize(gem_file, options = {})
  super(File.expand_path(File.dirname(gem_file)), options)
  @gem_file = gem_file
end

Instance Attribute Details

#gem_fileObject (readonly)

Returns the value of attribute gem_file.



56
57
58
# File 'lib/gpm/source/gem.rb', line 56

def gem_file
  @gem_file
end

#optionsObject (readonly)

Returns the value of attribute options.



56
57
58
# File 'lib/gpm/source/gem.rb', line 56

def options
  @options
end

Instance Method Details

#createObject



67
68
69
# File 'lib/gpm/source/gem.rb', line 67

def create
  Source::Gem.new(, files_provider, options)
end

#files_providersObject



71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/gpm/source/gem.rb', line 71

def files_providers
  fp = nil
  Dir.chdir(File.dirname(gem_file)) do
    if gemspec.end_with?('.gem')
      File.open(gem_file, 'r') do |f|
        fp = FilesFromGemProvider.new(f.read)
      end
    elsif gemspec.end_with?('.gemspec')
      fp = FilesFromDirectoryProvider.new(directory, .files+[File.basename(gem_file)])
    end
  end
  super + [fp]
end

#gemspecObject



61
62
63
# File 'lib/gpm/source/gem.rb', line 61

def gemspec
  @gem_file
end

#metadataObject



64
65
66
# File 'lib/gpm/source/gem.rb', line 64

def 
  Source::Gem.(gemspec)
end