Class: BundlerMCP::GemResource

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bundler_mcp/gem_resource.rb

Overview

Represents a Ruby gem and its associated data

Instance Method Summary collapse

Constructor Details

#initialize(gem) ⇒ GemResource

Returns a new instance of GemResource.

Parameters:

  • gem (Gem::Specification)


15
16
17
18
19
20
21
22
# File 'lib/bundler_mcp/gem_resource.rb', line 15

def initialize(gem)
  @gem = gem

  @version = gem.version.to_s
  @base_path = Pathname(@gem.full_gem_path)
  @doc_paths = @base_path.glob("{README,CHANGELOG}*").map!(&:to_s)
  @lib_path = @base_path.join("lib").to_s
end

Instance Method Details

#to_h(include_source_files: false) ⇒ Hash

Returns A hash containing the gem’s details.

Returns:

  • (Hash)

    A hash containing the gem’s details



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

def to_h(include_source_files: false)
  base_hash = { name:,
                version:,
                description:,
                full_gem_path:,
                lib_path:,
                top_level_documentation_paths: doc_paths }

  base_hash[:source_files] = @base_path.glob("**/*.{rb,c,rake}").map!(&:to_s) if include_source_files

  base_hash
end