Class: Gel::PathCatalog

Inherits:
Object
  • Object
show all
Defined in:
lib/gel/path_catalog.rb

Constant Summary collapse

DEFAULT_GLOB =
'{,*,*/*}.gemspec'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PathCatalog

Returns a new instance of PathCatalog.



10
11
12
13
14
# File 'lib/gel/path_catalog.rb', line 10

def initialize(path)
  @path = path
  @cache = {}
  @gemspecs = nil
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/gel/path_catalog.rb', line 6

def path
  @path
end

Instance Method Details

#_info(name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gel/path_catalog.rb', line 24

def _info(name)
  gemspec = gemspecs.detect { |path| File.basename(path) == "#{name}.gemspec" }
  return unless gemspec
  gemspec = gemspec_from(gemspec)

  info = {}
  info[gemspec.version] = {
    dependencies: gemspec.runtime_dependencies,
    ruby: gemspec.required_ruby_version,
  }

  info
end

#gem_info(name) ⇒ Object



20
21
22
# File 'lib/gel/path_catalog.rb', line 20

def gem_info(name)
  @cache.fetch(name) { @cache[name] = _info(name) }
end

#gemspec_from(filename) ⇒ Object



38
39
40
# File 'lib/gel/path_catalog.rb', line 38

def gemspec_from(filename)
  Gel::GemspecParser.parse(File.read(filename), filename)
end

#gemspecsObject



16
17
18
# File 'lib/gel/path_catalog.rb', line 16

def gemspecs
  @gemspecs ||= Dir["#{@path}/#{DEFAULT_GLOB}"]
end

#prepareObject



42
43
# File 'lib/gel/path_catalog.rb', line 42

def prepare
end