Skip to content

Commit a04f5d8

Browse files
committed
Gems command
1 parent f2e5387 commit a04f5d8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/solargraph/shell.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,34 @@ def uncache *gems
111111
end
112112
end
113113

114+
desc 'gems', 'Cache documentation for installed gems'
115+
option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false
116+
# @return [void]
117+
def gems *names
118+
if names.empty?
119+
Gem::Specification.to_a.each do |spec|
120+
next unless options.rebuild || !Yardoc.cached?(spec)
121+
122+
puts "Processing gem: #{spec.name} #{spec.version}"
123+
pins = GemPins.build(spec)
124+
Cache.save('gems', "#{spec.name}-#{spec.version}.ser", pins)
125+
end
126+
else
127+
names.each do |name|
128+
spec = Gem::Specification.find_by_name(name)
129+
if spec
130+
next unless options.rebuild || !Yardoc.cached?(spec)
131+
132+
puts "Processing gem: #{spec.name} #{spec.version}"
133+
pins = GemPins.build(spec)
134+
Cache.save('gems', "#{spec.name}-#{spec.version}.ser", pins)
135+
else
136+
warn "Gem '#{name}' not found"
137+
end
138+
end
139+
end
140+
end
141+
114142
desc 'reporters', 'Get a list of diagnostics reporters'
115143
# @return [void]
116144
def reporters

0 commit comments

Comments
 (0)