lib/yoda/store/objects/library/gem.rb in yoda-language-server-0.9.0 vs lib/yoda/store/objects/library/gem.rb in yoda-language-server-0.10.0
- old
+ new
@@ -1,37 +1,45 @@
+require 'yoda/store/objects/library/path_resolvable'
+
module Yoda
module Store
module Objects
module Library
class Gem
include Serializable
+ include PathResolvable
# @return [String]
attr_reader :name, :version, :source_path, :full_gem_path, :doc_dir
+ # @return [Array<String>]
+ attr_reader :require_paths
+
# @return [Symbol, nil]
attr_reader :source_type
class << self
- # @param spec [Bundler::LazySpecification]
+ # @param spec [Bundler::LazySpecification, Gem::Specification]
def from_gem_spec(spec)
if spec.respond_to?(:full_gem_path)
# Installed
new(
name: spec.name,
version: spec.version.version,
source_path: spec.source.respond_to?(:path) ? spec.source.path : nil,
+ require_paths: spec.full_require_paths,
full_gem_path: spec.full_gem_path,
doc_dir: spec.doc_dir,
source_type: source_type_of(spec.source),
)
else
# Not installed
new(
name: spec.name,
version: spec.version.version,
source_path: nil,
+ require_paths: [],
full_gem_path: nil,
doc_dir: nil,
source_type: nil,
)
end
@@ -55,15 +63,16 @@
nil
end
end
end
- def initialize(name:, version:, source_path:, full_gem_path:, doc_dir:, source_type:)
+ def initialize(name:, version:, source_path:, full_gem_path:, require_paths:, doc_dir:, source_type:)
@name = name
@version = version
@source_path = source_path
@full_gem_path = full_gem_path
+ @require_paths = require_paths
@doc_dir = doc_dir
@source_type = source_type&.to_sym
end
def id
@@ -78,10 +87,11 @@
{
name: name,
version: version,
source_path: source_path,
full_gem_path: full_gem_path,
+ require_paths: require_paths,
doc_dir: doc_dir,
source_type: source_type,
}
end
@@ -101,12 +111,13 @@
class Connected
extend ConnectedDelegation
include WithRegistry
- delegate_to_object :name, :version, :source_path, :full_gem_path, :doc_dir, :source_type
+ delegate_to_object :name, :version, :source_path, :full_gem_path, :doc_dir, :source_type, :require_paths
delegate_to_object :id, :local?, :to_h, :installed?, :managed_by_rubygems?, :with_project_connection
delegate_to_object :hash, :eql?, :==, :to_json, :derive
+ delegate_to_object :contain_requirable_file?, :find_requirable_file
# @return [Gem]
attr_reader :object
# @return [Project]