Class: Solargraph::Metagem
- Inherits:
-
Object
- Object
- Solargraph::Metagem
show all
- Includes:
- Equality
- Defined in:
- lib/solargraph/metagem.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Equality
#==, #eql?, #freeze, #hash
Constructor Details
#initialize(name:, full_path:, spec_file:, source:, version:, require_paths:, dependencies:) ⇒ Metagem
Returns a new instance of Metagem.
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/solargraph/metagem.rb', line 31
def initialize name:, full_path:, spec_file:, source:, version:, require_paths:, dependencies:
@name = name
@full_path = full_path
@spec_file = spec_file
@source = source
@version = version
@require_paths = require_paths
@dependencies = dependencies
@cache_name = File.basename(full_path) unless source.start_with?('source at') || source.to_s.end_with?('::Path')
end
|
Instance Attribute Details
#cache_name ⇒ String
29
30
31
|
# File 'lib/solargraph/metagem.rb', line 29
def cache_name
@cache_name
end
|
#dependencies ⇒ Array<String>
26
27
28
|
# File 'lib/solargraph/metagem.rb', line 26
def dependencies
@dependencies
end
|
#full_path ⇒ String
Also known as:
full_gem_path
11
12
13
|
# File 'lib/solargraph/metagem.rb', line 11
def full_path
@full_path
end
|
#name ⇒ String
8
9
10
|
# File 'lib/solargraph/metagem.rb', line 8
def name
@name
end
|
#require_paths ⇒ Array<String>
23
24
25
|
# File 'lib/solargraph/metagem.rb', line 23
def require_paths
@require_paths
end
|
#source ⇒ String
17
18
19
|
# File 'lib/solargraph/metagem.rb', line 17
def source
@source
end
|
#spec_file ⇒ String
14
15
16
|
# File 'lib/solargraph/metagem.rb', line 14
def spec_file
@spec_file
end
|
#version ⇒ String
20
21
22
|
# File 'lib/solargraph/metagem.rb', line 20
def version
@version
end
|
Class Method Details
.from_specification(gem) ⇒ Metagem
70
71
72
73
74
75
76
77
78
|
# File 'lib/solargraph/metagem.rb', line 70
def self.from_specification gem
Metagem.new(name: gem.name,
full_path: gem.full_gem_path,
spec_file: gem.spec_file,
source: gem.source.to_s,
version: gem.version,
require_paths: gem.require_paths,
dependencies: gem.runtime_dependencies.map(&:name))
end
|
Instance Method Details
#cacheable? ⇒ Boolean
45
46
47
|
# File 'lib/solargraph/metagem.rb', line 45
def cacheable?
!!@cache_name
end
|
#equality_fields ⇒ Array
62
63
64
65
66
|
# File 'lib/solargraph/metagem.rb', line 62
def equality_fields
[name, version.to_s, full_path, source]
end
|
#require?(path) ⇒ Boolean
49
50
51
52
53
|
# File 'lib/solargraph/metagem.rb', line 49
def require? path
require_paths.any? do |req|
File.file?(File.join(full_path, req, "#{path}.rb"))
end
end
|
#to_specification ⇒ Object
55
56
57
|
# File 'lib/solargraph/metagem.rb', line 55
def to_specification
Gem::Specification.load(spec_file)
end
|