Class: Gel::PathCatalog
- Inherits:
-
Object
- Object
- Gel::PathCatalog
- Defined in:
- lib/gel/path_catalog.rb
Constant Summary collapse
- DEFAULT_GLOB =
'{,*,*/*}.gemspec'
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #_info(name) ⇒ Object
- #gem_info(name) ⇒ Object
- #gemspec_from(filename) ⇒ Object
- #gemspecs ⇒ Object
-
#initialize(path) ⇒ PathCatalog
constructor
A new instance of PathCatalog.
- #prepare ⇒ Object
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
#path ⇒ Object (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 |
#gemspecs ⇒ Object
16 17 18 |
# File 'lib/gel/path_catalog.rb', line 16 def gemspecs @gemspecs ||= Dir["#{@path}/#{DEFAULT_GLOB}"] end |
#prepare ⇒ Object
42 43 |
# File 'lib/gel/path_catalog.rb', line 42 def prepare end |